@@ -28,7 +28,7 @@ def initialize(bot_user, persona, model = nil)
2828 attr_accessor :persona
2929
3030 def llm
31- @llm ||= DiscourseAi ::Completions ::Llm . proxy ( model )
31+ DiscourseAi ::Completions ::Llm . proxy ( model )
3232 end
3333
3434 def force_tool_if_needed ( prompt , context )
@@ -51,7 +51,7 @@ def force_tool_if_needed(prompt, context)
5151 end
5252 end
5353
54- def reply ( context , &update_blk )
54+ def reply ( context , llm_args : { } , &update_blk )
5555 unless context . is_a? ( BotContext )
5656 raise ArgumentError , "context must be an instance of BotContext"
5757 end
@@ -67,6 +67,7 @@ def reply(context, &update_blk)
6767 llm_kwargs = { user : user }
6868 llm_kwargs [ :temperature ] = persona . temperature if persona . temperature
6969 llm_kwargs [ :top_p ] = persona . top_p if persona . top_p
70+ llm_kwargs [ :max_tokens ] = llm_args [ :max_tokens ] if llm_args [ :max_tokens ] . present?
7071
7172 needs_newlines = false
7273 tools_ran = 0
@@ -84,7 +85,7 @@ def reply(context, &update_blk)
8485 result =
8586 current_llm . generate (
8687 prompt ,
87- feature_name : "bot" ,
88+ feature_name : context . feature_name ,
8889 partial_tool_calls : allow_partial_tool_calls ,
8990 output_thinking : true ,
9091 **llm_kwargs ,
@@ -246,13 +247,8 @@ def process_tool(
246247 raw_context << [ invocation_result_json , tool_call_id , "tool" , tool . name ]
247248 end
248249
249- <<<<<<< HEAD
250- def invoke_tool ( tool , llm , cancel , context , &update_blk )
251- show_placeholder = !context . skip_tool_details && !tool . class . allow_partial_tool_calls?
252- =======
253250 def invoke_tool ( tool , cancel , context , &update_blk )
254- show_placeholder = !context [ :skip_tool_details ] && !tool . class . allow_partial_tool_calls?
255- >>>>>>> 5 bfe2314 ( REFACTOR : Move personas into it 's own module . )
251+ show_placeholder = !context . skip_tool_details && !tool . class . allow_partial_tool_calls?
256252
257253 update_blk . call ( "" , cancel , build_placeholder ( tool . summary , "" ) ) if show_placeholder
258254
0 commit comments