@@ -23,6 +23,7 @@ internal AgentContext(IAgentService agentService)
2323 Behaviours = new Dictionary < string , string > ( ) ,
2424 Name = $ "Agent-{ Guid . NewGuid ( ) } ",
2525 Description = "Agent created by MaIN" ,
26+ CurrentBehaviour = "Default" ,
2627 Flow = false ,
2728 Context = new AgentData ( )
2829 {
@@ -40,7 +41,7 @@ internal AgentContext(IAgentService agentService, Agent existingAgent)
4041 _agent = existingAgent ;
4142 }
4243
43- public AgentContext WithId ( string ? id )
44+ public AgentContext WithId ( string id )
4445 {
4546 _agent . Id = id ;
4647 return this ;
@@ -71,7 +72,7 @@ public AgentContext WithName(string name)
7172 return this ;
7273 }
7374
74- public AgentContext WithModel ( string model )
75+ public AgentContext WithModel ( string ? model )
7576 {
7677 _agent . Model = model ;
7778 return this ;
@@ -83,7 +84,7 @@ public AgentContext WithInferenceParams(InferenceParams inferenceParams)
8384 return this ;
8485 }
8586
86- public AgentContext WithCustomModel ( string model , string path )
87+ public AgentContext WithCustomModel ( string ? model , string path )
8788 {
8889 KnownModels . AddModel ( model , path ) ;
8990 _agent . Model = model ;
@@ -103,7 +104,7 @@ public AgentContext WithSteps(List<string>? steps)
103104 return this ;
104105 }
105106
106- public AgentContext WithBehaviour ( string ? name , string instruction )
107+ public AgentContext WithBehaviour ( string name , string instruction )
107108 {
108109 _agent . Behaviours ??= new Dictionary < string , string > ( ) ;
109110 _agent . Behaviours [ name ] = instruction ;
@@ -123,7 +124,7 @@ public AgentContext Create(bool flow = false, bool interactiveResponse = false)
123124 return this ;
124125 }
125126
126- public async Task < ChatResult > ProcessAsync ( Chat ? chat , bool translate = false )
127+ public async Task < ChatResult > ProcessAsync ( Chat chat , bool translate = false )
127128 {
128129 var result = await _agentService . Process ( chat , _agent . Id , translate ) ;
129130 var message = result ! . Messages ! . LastOrDefault ( ) ! . ToDto ( ) ;
@@ -139,7 +140,7 @@ public async Task<ChatResult> ProcessAsync(Chat? chat, bool translate = false)
139140 public async Task < ChatResult > ProcessAsync ( string message , bool translate = false )
140141 {
141142 var chat = await _agentService . GetChatByAgent ( _agent . Id ) ;
142- chat . Messages ? . Add ( new Message ( )
143+ chat ? . Messages . Add ( new Message ( )
143144 {
144145 Content = message ,
145146 Role = "User" ,
@@ -159,9 +160,9 @@ public async Task<ChatResult> ProcessAsync(string message, bool translate = fals
159160 public async Task < ChatResult > ProcessAsync ( Message message , bool translate = false )
160161 {
161162 var chat = await _agentService . GetChatByAgent ( _agent . Id ) ;
162- chat . Messages ? . Add ( message ) ;
163+ chat ? . Messages . Add ( message ) ;
163164 var result = await _agentService . Process ( chat , _agent . Id , translate ) ;
164- var messageResult = result ! . Messages ! . LastOrDefault ( ) ! . ToDto ( ) ;
165+ var messageResult = result ! . Messages . LastOrDefault ( ) ! . ToDto ( ) ;
165166 return new ChatResult ( )
166167 {
167168 Done = true ,
@@ -171,12 +172,12 @@ public async Task<ChatResult> ProcessAsync(Message message, bool translate = fal
171172 } ;
172173 }
173174
174- public async Task < Chat ? > GetChat ( )
175+ public async Task < Chat > GetChat ( )
175176 {
176177 return await _agentService . GetChatByAgent ( _agent . Id ) ;
177178 }
178179
179- public async Task < Chat ? > RestartChat ( )
180+ public async Task < Chat > RestartChat ( )
180181 {
181182 return await _agentService . Restart ( _agent . Id ) ;
182183 }
0 commit comments