-
-
Notifications
You must be signed in to change notification settings - Fork 180
Expand file tree
/
Copy pathRAGAndLLM_Sample.cs
More file actions
42 lines (38 loc) · 1.14 KB
/
RAGAndLLM_Sample.cs
File metadata and controls
42 lines (38 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using UnityEngine.UI;
using LLMUnity;
using System.Threading.Tasks;
namespace LLMUnitySamples
{
public class RAGAndLLMSample : RAGSample
{
public LLMAgent llmAgent;
public Toggle ParaphraseWithLLM;
protected override async void onInputFieldSubmit(string message)
{
playerText.interactable = false;
AIText.text = "...";
(string[] similarPhrases, float[] distances) = await rag.Search(message, 1);
string similarPhrase = similarPhrases[0];
if (!ParaphraseWithLLM.isOn)
{
AIText.text = similarPhrase;
await Task.Yield();
AIReplyComplete();
}
else
{
_ = llmAgent.Chat("Paraphrase the following phrase: " + similarPhrase, SetAIText, AIReplyComplete);
}
}
public void CancelRequests()
{
llmAgent.CancelRequests();
AIReplyComplete();
}
protected override void CheckLLMs(bool debug)
{
base.CheckLLMs(debug);
CheckLLM(llmAgent, debug);
}
}
}