bug fixed in minimax
This commit is contained in:
2
main.py
2
main.py
@@ -87,7 +87,7 @@ class UAVAgentGUI:
|
||||
|
||||
self.provider_var = tk.StringVar(value="Ollama")
|
||||
self.model_var = tk.StringVar()
|
||||
self.uav_base_url_var = tk.StringVar(value="http://100.80.12.144:8000")
|
||||
self.uav_base_url_var = tk.StringVar(value="http://127.0.0.1:8000")
|
||||
self.uav_api_key_var = tk.StringVar(value="agent_secret_key_change_in_production") # UAV API key for authentication
|
||||
self.temperature_var = tk.DoubleVar(value=0.1)
|
||||
self.verbose_var = tk.BooleanVar(value=True)
|
||||
|
||||
18
uav_agent.py
18
uav_agent.py
@@ -20,23 +20,23 @@ import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class MiniMaxChatOpenAI(ChatOpenAI):
|
||||
"""Custom ChatOpenAI class to handle MiniMax's reasoning_split feature"""
|
||||
class EnhancedChatOpenAI(ChatOpenAI):
|
||||
"""ChatOpenAI subclass that captures reasoning_content if provided by the API"""
|
||||
|
||||
def _create_chat_result(self, response: Any) -> ChatResult:
|
||||
result = super()._create_chat_result(response)
|
||||
|
||||
if hasattr(response, "choices") and response.choices:
|
||||
for i, choice in enumerate(response.choices):
|
||||
# MiniMax puts reasoning in reasoning_details when reasoning_split=True
|
||||
# Handle MiniMax reasoning_details
|
||||
if hasattr(choice.message, "reasoning_details") and choice.message.reasoning_details:
|
||||
reasoning = choice.message.reasoning_details[0].get('text', '')
|
||||
if reasoning and i < len(result.generations):
|
||||
gen = result.generations[i]
|
||||
if isinstance(gen.message, AIMessage):
|
||||
# Store in additional_kwargs for later access if needed
|
||||
# Store in additional_kwargs
|
||||
gen.message.additional_kwargs["reasoning_content"] = reasoning
|
||||
# Prepend to content for ReAct agent compatibility
|
||||
# Prepend to content for ReAct agent visibility
|
||||
if "Thought:" not in gen.message.content:
|
||||
gen.message.content = f"Thought: {reasoning}\n" + gen.message.content
|
||||
return result
|
||||
@@ -290,9 +290,15 @@ class UAVControlAgent:
|
||||
|
||||
if llm_model.startswith("MiniMax"):
|
||||
# Enable reasoning_split for MiniMax models
|
||||
kwargs["model_kwargs"] = {"extra_body": {"reasoning_split": True}}
|
||||
kwargs["model_kwargs"] = {
|
||||
"extra_body": {"reasoning_split": True},
|
||||
"stop": ["\nObservation:"]
|
||||
}
|
||||
self.llm = MiniMaxChatOpenAI(**kwargs)
|
||||
else:
|
||||
kwargs["model_kwargs"] = {
|
||||
"stop": ["\nObservation:"]
|
||||
}
|
||||
self.llm = ChatOpenAI(**kwargs)
|
||||
|
||||
if self.debug:
|
||||
|
||||
Reference in New Issue
Block a user