File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,22 @@ public class OllamaApiTest : MonoBehaviour
6
6
{
7
7
[ SerializeField ] private NeocortexChatPanel chatPanel ;
8
8
[ SerializeField ] private NeocortexTextChatInput chatInput ;
9
+ [ SerializeField ] private OllamaModelDropdown modelDropdown ;
9
10
10
11
private OllamaRequest request ;
11
12
12
13
void Start ( )
13
14
{
14
15
request = new OllamaRequest ( ) ;
15
16
request . OnChatResponseReceived += OnChatResponseReceived ;
17
+ request . ModelName = modelDropdown . options [ 0 ] . text ;
16
18
chatInput . OnSendButtonClicked . AddListener ( OnUserMessageSent ) ;
19
+ modelDropdown . onValueChanged . AddListener ( OnDropdownValueChanged ) ;
20
+ }
21
+
22
+ private void OnDropdownValueChanged ( int index )
23
+ {
24
+ request . ModelName = modelDropdown . options [ index ] . text ;
17
25
}
18
26
19
27
private void OnChatResponseReceived ( ChatResponse response )
Original file line number Diff line number Diff line change 8
8
public class OllamaRequest : WebRequest
9
9
{
10
10
private const string BASE_URL = "http://localhost:11434/api/chat" ;
11
+
12
+ private readonly List < Message > messages = new ( ) ;
11
13
14
+ public string ModelName { get ; set ; }
12
15
public event Action < ChatResponse > OnChatResponseReceived ;
13
-
14
- private readonly List < Message > messages = new List < Message > ( ) ;
15
-
16
+
16
17
public async void Send ( string input )
17
18
{
19
+ if ( string . IsNullOrEmpty ( ModelName ) )
20
+ {
21
+ throw new Exception ( "ModelName property is not set." ) ;
22
+ }
23
+
18
24
Headers = new Dictionary < string , string > ( )
19
25
{
20
26
{ "Content-Type" , "application/json" } ,
@@ -24,7 +30,7 @@ public async void Send(string input)
24
30
25
31
var data = new
26
32
{
27
- model = "llama3.2:3b" ,
33
+ model = ModelName ,
28
34
messages = messages . ToArray ( ) ,
29
35
stream = false
30
36
} ;
You can’t perform that action at this time.
0 commit comments