Skip to content

Commit ed276ca

Browse files
committed
update Samples to v3
1 parent 7726186 commit ed276ca

15 files changed

Lines changed: 393 additions & 527 deletions

File tree

Samples~/ChatBot/ChatBot.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Bubble AddBubble(string message, bool isPlayerMessage)
6868

6969
void ShowLoadedMessages()
7070
{
71-
for (int i = 1; i < llmAgent.chat.Count; i++) AddBubble(llmAgent.chat[i].Content, i % 2 == 1);
71+
for (int i = 1; i < llmAgent.chat.Count; i++) AddBubble(llmAgent.chat[i].content, i % 2 == 1);
7272
}
7373

7474
void onInputFieldSubmit(string newText)
@@ -85,7 +85,7 @@ void onInputFieldSubmit(string newText)
8585

8686
AddBubble(message, true);
8787
Bubble aiBubble = AddBubble("...", false);
88-
Task chatTask = llmAgent.ChatAsync(message, aiBubble.SetText, AllowInput);
88+
Task chatTask = llmAgent.Chat(message, aiBubble.SetText, AllowInput);
8989
inputBubble.SetText("");
9090
}
9191

Samples~/ChatBot/Scene.unity

Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ MonoBehaviour:
178178
font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
179179
fontSize: 16
180180
bubbleWidth: 600
181-
llmCharacter: {fileID: 1844795171}
181+
llmAgent: {fileID: 1844795172}
182182
textPadding: 10
183183
bubbleSpacing: 10
184184
sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
@@ -658,26 +658,22 @@ MonoBehaviour:
658658
m_Name:
659659
m_EditorClassIdentifier:
660660
advancedOptions: 0
661-
remote: 0
662-
port: 13333
663-
numThreads: -1
664-
numGPULayers: 0
665-
debug: 0
666-
parallelPrompts: -1
661+
_remote: 0
662+
_port: 13333
663+
_APIKey:
664+
_SSLCert:
665+
_SSLKey:
666+
_numThreads: -1
667+
_numGPULayers: 0
668+
_parallelPrompts: -1
669+
_contextSize: 8192
670+
_batchSize: 512
671+
_model:
672+
_flashAttention: 0
673+
_reasoning: 0
674+
_lora:
675+
_loraWeights:
667676
dontDestroyOnLoad: 1
668-
contextSize: 8192
669-
batchSize: 512
670-
basePrompt:
671-
model:
672-
chatTemplate: chatml
673-
lora:
674-
loraWeights:
675-
flashAttention: 0
676-
APIKey:
677-
SSLCert:
678-
SSLCertPath:
679-
SSLKey:
680-
SSLKeyPath:
681677
minContextLength: 0
682678
maxContextLength: 0
683679
--- !u!1 &1051131186
@@ -1100,9 +1096,9 @@ GameObject:
11001096
serializedVersion: 6
11011097
m_Component:
11021098
- component: {fileID: 1844795170}
1103-
- component: {fileID: 1844795171}
1099+
- component: {fileID: 1844795172}
11041100
m_Layer: 0
1105-
m_Name: LLMCharacter
1101+
m_Name: LLMAgent
11061102
m_TagString: Untagged
11071103
m_Icon: {fileID: 0}
11081104
m_NavMeshLayer: 0
@@ -1123,7 +1119,7 @@ Transform:
11231119
m_Children: []
11241120
m_Father: {fileID: 0}
11251121
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1126-
--- !u!114 &1844795171
1122+
--- !u!114 &1844795172
11271123
MonoBehaviour:
11281124
m_ObjectHideFlags: 0
11291125
m_CorrespondingSourceObject: {fileID: 0}
@@ -1132,51 +1128,41 @@ MonoBehaviour:
11321128
m_GameObject: {fileID: 1844795168}
11331129
m_Enabled: 1
11341130
m_EditorHideFlags: 0
1135-
m_Script: {fileID: 11500000, guid: 3f6c87a428fd5d0be9bbc686bdc8c3c2, type: 3}
1131+
m_Script: {fileID: 11500000, guid: b4326d5ae3b03ff55847035351559f4e, type: 3}
11361132
m_Name:
11371133
m_EditorClassIdentifier:
11381134
advancedOptions: 0
1139-
remote: 0
1140-
llm: {fileID: 817827756}
1141-
host: localhost
1142-
port: 13333
1143-
numRetries: 10
1144-
APIKey:
1145-
save:
1146-
saveCache: 0
1147-
debugPrompt: 0
1148-
stream: 1
1149-
grammar:
1135+
_remote: 0
1136+
_llm: {fileID: 817827756}
1137+
_APIKey:
1138+
_host: localhost
1139+
_port: 13333
1140+
numRetries: 5
1141+
_grammar:
1142+
numPredict: -1
11501143
cachePrompt: 1
1151-
slot: -1
11521144
seed: 0
1153-
numPredict: -1
11541145
temperature: 0.2
11551146
topK: 40
11561147
topP: 0.9
11571148
minP: 0.05
11581149
repeatPenalty: 1.1
11591150
presencePenalty: 0
11601151
frequencyPenalty: 0
1161-
tfsZ: 1
11621152
typicalP: 1
11631153
repeatLastN: 64
1164-
penalizeNl: 1
1165-
penaltyPrompt:
11661154
mirostat: 0
11671155
mirostatTau: 5
11681156
mirostatEta: 0.1
11691157
nProbs: 0
11701158
ignoreEos: 0
1171-
nKeep: -1
1172-
stop: []
1173-
playerName: user
1174-
AIName: assistant
1175-
prompt: A chat between a curious human and an artificial intelligence assistant.
1159+
save:
1160+
debugPrompt: 0
1161+
_slot: -1
1162+
_userRole: user
1163+
_assistantRole: assistant
1164+
_systemPrompt: A chat between a curious human and an artificial intelligence assistant.
11761165
The assistant gives helpful, detailed, and polite answers to the human's questions.
1177-
setNKeepToPrompt: 1
1178-
chat: []
1179-
grammarString:
11801166
--- !u!1 &2011827136
11811167
GameObject:
11821168
m_ObjectHideFlags: 0

Samples~/FunctionCalling/FunctionCalling.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ string CallFunction(string functionName)
7272
async void onInputFieldSubmit(string message)
7373
{
7474
playerText.interactable = false;
75-
string functionName = await llmAgent.ChatAsync(ConstructPrompt(message));
75+
string functionName = await llmAgent.Chat(ConstructPrompt(message));
7676
string result = CallFunction(functionName);
7777
AIText.text = $"Calling {functionName}\n{result}";
7878
playerText.interactable = true;

Samples~/FunctionCalling/Scene.unity

Lines changed: 40 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ OcclusionCullingSettings:
1313
--- !u!104 &2
1414
RenderSettings:
1515
m_ObjectHideFlags: 0
16-
serializedVersion: 10
16+
serializedVersion: 9
1717
m_Fog: 0
1818
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
1919
m_FogMode: 3
@@ -38,12 +38,13 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41+
m_IndirectSpecularColor: {r: 0.44657832, g: 0.49641222, b: 0.57481664, a: 1}
4142
m_UseRadianceAmbientProbe: 0
4243
--- !u!157 &3
4344
LightmapSettings:
4445
m_ObjectHideFlags: 0
45-
serializedVersion: 13
46-
m_BakeOnSceneLoad: 0
46+
serializedVersion: 12
47+
m_GIWorkflowMode: 1
4748
m_GISettings:
4849
serializedVersion: 2
4950
m_BounceScale: 1
@@ -66,6 +67,9 @@ LightmapSettings:
6667
m_LightmapParameters: {fileID: 0}
6768
m_LightmapsBakeMode: 1
6869
m_TextureCompression: 1
70+
m_FinalGather: 0
71+
m_FinalGatherFiltering: 1
72+
m_FinalGatherRayCount: 256
6973
m_ReflectionCompression: 2
7074
m_MixedBakeMode: 2
7175
m_BakeBackend: 1
@@ -163,7 +167,7 @@ MonoBehaviour:
163167
m_Script: {fileID: 11500000, guid: 162e77d443c2df77b8297c1dcdfbfdce, type: 3}
164168
m_Name:
165169
m_EditorClassIdentifier:
166-
llmCharacter: {fileID: 498662973}
170+
llmAgent: {fileID: 498662973}
167171
playerText: {fileID: 1966107897}
168172
AIText: {fileID: 887085510}
169173
--- !u!1 &158550913
@@ -441,7 +445,7 @@ GameObject:
441445
- component: {fileID: 498662972}
442446
- component: {fileID: 498662973}
443447
m_Layer: 0
444-
m_Name: LLMCharacter
448+
m_Name: LLMAgent
445449
m_TagString: Untagged
446450
m_Icon: {fileID: 0}
447451
m_NavMeshLayer: 0
@@ -471,22 +475,18 @@ MonoBehaviour:
471475
m_GameObject: {fileID: 498662970}
472476
m_Enabled: 1
473477
m_EditorHideFlags: 0
474-
m_Script: {fileID: 11500000, guid: 3f6c87a428fd5d0be9bbc686bdc8c3c2, type: 3}
478+
m_Script: {fileID: 11500000, guid: b4326d5ae3b03ff55847035351559f4e, type: 3}
475479
m_Name:
476480
m_EditorClassIdentifier:
477481
advancedOptions: 0
478-
remote: 0
482+
_remote: 0
479483
_llm: {fileID: 1047848254}
480-
APIKey:
481-
host: localhost
482-
port: 13333
483-
numRetries: 10
484-
save:
485-
saveCache: 0
486-
debugPrompt: 0
484+
_APIKey:
485+
_host: localhost
486+
_port: 13333
487+
numRetries: 5
488+
_grammar:
487489
numPredict: -1
488-
slot: -1
489-
grammar:
490490
cachePrompt: 1
491491
seed: 0
492492
temperature: 0.2
@@ -496,25 +496,20 @@ MonoBehaviour:
496496
repeatPenalty: 1.1
497497
presencePenalty: 0
498498
frequencyPenalty: 0
499-
tfsZ: 1
500499
typicalP: 1
501500
repeatLastN: 64
502-
penalizeNl: 1
503-
penaltyPrompt:
504501
mirostat: 0
505502
mirostatTau: 5
506503
mirostatEta: 0.1
507504
nProbs: 0
508505
ignoreEos: 0
509-
nKeep: -1
510-
stop: []
511-
stream: 1
512-
playerName: user
513-
AIName: assistant
514-
prompt: You are an AI assistant and your task is to answer multiple choice question
515-
setNKeepToPrompt: 1
516-
chat: []
517-
grammarString:
506+
save:
507+
debugPrompt: 0
508+
_slot: -1
509+
_userRole: user
510+
_assistantRole: assistant
511+
_systemPrompt: You are an AI assistant and your task is to answer multiple choice
512+
questions
518513
--- !u!1 &724531319
519514
GameObject:
520515
m_ObjectHideFlags: 0
@@ -936,8 +931,9 @@ Light:
936931
m_PrefabAsset: {fileID: 0}
937932
m_GameObject: {fileID: 909474451}
938933
m_Enabled: 1
939-
serializedVersion: 11
934+
serializedVersion: 10
940935
m_Type: 1
936+
m_Shape: 0
941937
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
942938
m_Intensity: 1
943939
m_Range: 10
@@ -987,12 +983,8 @@ Light:
987983
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
988984
m_UseBoundingSphereOverride: 0
989985
m_UseViewFrustumForShadowCasterCull: 1
990-
m_ForceVisible: 0
991986
m_ShadowRadius: 0
992987
m_ShadowAngle: 0
993-
m_LightUnit: 1
994-
m_LuxAtDistance: 1
995-
m_EnableSpotReflector: 1
996988
--- !u!4 &909474453
997989
Transform:
998990
m_ObjectHideFlags: 0
@@ -1038,29 +1030,24 @@ MonoBehaviour:
10381030
m_Name:
10391031
m_EditorClassIdentifier:
10401032
advancedOptions: 0
1041-
remote: 0
1042-
port: 13333
1043-
numThreads: -1
1044-
numGPULayers: 0
1045-
debug: 0
1046-
parallelPrompts: -1
1033+
_remote: 0
1034+
_port: 13333
1035+
_APIKey:
1036+
_SSLCert:
1037+
_SSLKey:
1038+
_numThreads: -1
1039+
_numGPULayers: 0
1040+
_parallelPrompts: -1
1041+
_contextSize: 8192
1042+
_batchSize: 512
1043+
_model:
1044+
_flashAttention: 0
1045+
_reasoning: 0
1046+
_lora:
1047+
_loraWeights:
10471048
dontDestroyOnLoad: 1
1048-
contextSize: 8192
1049-
batchSize: 512
1050-
model:
1051-
chatTemplate: chatml
1052-
lora:
1053-
loraWeights:
1054-
flashAttention: 0
1055-
APIKey:
1056-
SSLCert:
1057-
SSLCertPath:
1058-
SSLKey:
1059-
SSLKeyPath:
10601049
minContextLength: 0
10611050
maxContextLength: 0
1062-
embeddingsOnly: 0
1063-
embeddingLength: 0
10641051
--- !u!4 &1047848255
10651052
Transform:
10661053
m_ObjectHideFlags: 0

Samples~/KnowledgeBaseGame/KnowledgeBaseGame.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,20 @@ public async Task CreateEmbeddings()
9595
}
9696
}
9797

98-
public List<string> Retrieval(string question)
98+
public async Task<List<string>> Retrieval(string question)
9999
{
100100
// find similar questions for the current bot using the RAG
101-
(string[] similarQuestions, _) = rag.Search(question, numRAGResults, currentBotName);
101+
(string[] similarQuestions, _) = await rag.Search(question, numRAGResults, currentBotName);
102102
// get the answers of the similar questions
103103
List<string> similarAnswers = new List<string>();
104104
foreach (string similarQuestion in similarQuestions) similarAnswers.Add(botQuestionAnswers[currentBotName][similarQuestion]);
105105
return similarAnswers;
106106
}
107107

108-
public string ConstructPrompt(string question)
108+
public async Task<string> ConstructPrompt(string question)
109109
{
110110
// get similar answers from the RAG
111-
List<string> similarAnswers = Retrieval(question);
111+
List<string> similarAnswers = await Retrieval(question);
112112
// create the prompt using the user question and the similar answers
113113
string answers = "";
114114
foreach (string similarAnswer in similarAnswers) answers += $"\n- {similarAnswer}";
@@ -118,12 +118,12 @@ public string ConstructPrompt(string question)
118118
return prompt;
119119
}
120120

121-
protected override void OnInputFieldSubmit(string question)
121+
protected override async void OnInputFieldSubmit(string question)
122122
{
123123
PlayerText.interactable = false;
124124
SetAIText("...");
125-
string prompt = ConstructPrompt(question);
126-
_ = llmAgent.ChatAsync(prompt, SetAIText, AIReplyComplete);
125+
string prompt = await ConstructPrompt(question);
126+
_ = llmAgent.Chat(prompt, SetAIText, AIReplyComplete);
127127
}
128128

129129
protected override void DropdownChange(int selection)

0 commit comments

Comments
 (0)