Skip to content

1.Add Local Models #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ UNBOUND_API_KEY=
SiliconFLOW_ENDPOINT=https://api.siliconflow.cn/v1/
SiliconFLOW_API_KEY=

LOCAL_ENDPOINT=http://localhost:8000/v1
LOCAL_API_KEY=

# Set to false to disable anonymized telemetry
ANONYMIZED_TELEMETRY=false

Expand Down
2 changes: 2 additions & 0 deletions src/agent/custom_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import base64
import io
import re
import asyncio
import time
import platform
Expand Down Expand Up @@ -223,6 +224,7 @@ async def get_next_action(self, input_messages: list[BaseMessage]) -> AgentOutpu
ai_content = ai_message.content

try:
ai_content = re.sub(r"<think>.*?</think>", "", ai_content, flags=re.DOTALL).strip()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comment explaining the purpose of removing tags from the AI response

ai_content = ai_content.replace("```json", "").replace("```", "")
ai_content = repair_json(ai_content)
parsed_json = json.loads(ai_content)
Expand Down
21 changes: 19 additions & 2 deletions src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"google": "Google",
"alibaba": "Alibaba",
"moonshot": "MoonShot",
"unbound": "Unbound AI"
"unbound": "Unbound AI",
"local": "Local Model"
}


Expand Down Expand Up @@ -180,7 +181,22 @@ def get_llm_model(provider: str, **kwargs):
return ChatOpenAI(
api_key=api_key,
base_url=base_url,
model_name=kwargs.get("model_name", "Qwen/QwQ-32B"),
model=kwargs.get("model_name", "Qwen/QwQ-32B"),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter name changed from model_name to model for the siliconflow provider, indicating a bug fix. This suggests there may be other inconsistencies in other providers.

temperature=kwargs.get("temperature", 0.0),
)
elif provider == "local":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local provider implementation duplicates API key and base_url extraction logic

if not kwargs.get("api_key", ""):
api_key = os.getenv("LOCAL_API_KEY", "")
else:
api_key = kwargs.get("api_key")
if not kwargs.get("base_url", ""):
base_url = os.getenv("LOCAL_ENDPOINT", "")
else:
base_url = kwargs.get("base_url")
return ChatOpenAI(
api_key=api_key,
base_url=base_url,
model=kwargs.get("model_name", ""),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty string as default model name for local provider could cause API errors if the model name is required

temperature=kwargs.get("temperature", 0.0),
)
else:
Expand All @@ -201,6 +217,7 @@ def get_llm_model(provider: str, **kwargs):
"alibaba": ["qwen-plus", "qwen-max", "qwen-turbo", "qwen-long"],
"moonshot": ["moonshot-v1-32k-vision-preview", "moonshot-v1-8k-vision-preview"],
"unbound": ["gemini-2.0-flash", "gpt-4o-mini", "gpt-4o", "gpt-4.5-preview"],
"local": ["local-model"],
"siliconflow": [
"deepseek-ai/DeepSeek-R1",
"deepseek-ai/DeepSeek-V3",
Expand Down