-
Notifications
You must be signed in to change notification settings - Fork 81
/
RAGAndLLM_Sample.cs
40 lines (36 loc) · 1.1 KB
/
RAGAndLLM_Sample.cs
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
using UnityEngine.UI;
using LLMUnity;
namespace LLMUnitySamples
{
public class RAGAndLLMSample : RAGSample
{
public LLMCharacter llmCharacter;
public Toggle ParaphraseWithLLM;
protected async override 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;
AIReplyComplete();
}
else
{
_ = llmCharacter.Chat("Paraphrase the following phrase: " + similarPhrase, SetAIText, AIReplyComplete);
}
}
public void CancelRequests()
{
llmCharacter.CancelRequests();
AIReplyComplete();
}
protected override void CheckLLMs(bool debug)
{
base.CheckLLMs(debug);
CheckLLM(llmCharacter, debug);
}
}
}