hjg 账号默认使用 DeepSeek Pro AI 配置

This commit is contained in:
2026-07-07 22:17:00 +08:00
parent 490fb7ac0a
commit 2f2b53e03e
12 changed files with 130 additions and 30 deletions
+4 -3
View File
@@ -50,7 +50,7 @@ class AIStrategyGenerator:
self._guide_cache = ""
return self._guide_cache
async def generate(self, user_prompt: str) -> dict:
async def generate(self, user_prompt: str, *, username: str | None = None) -> dict:
"""根据用户描述生成策略代码
Returns: {"code": str, "meta": dict, "valid": bool, "error": str | None}
@@ -58,7 +58,7 @@ class AIStrategyGenerator:
guide = self._get_guide()
# 调用 LLM
code = await self._call_llm(user_prompt, guide)
code = await self._call_llm(user_prompt, guide, username=username)
# 验证
try:
@@ -74,7 +74,7 @@ class AIStrategyGenerator:
return {"code": code, "meta": meta, "valid": True, "error": None}
async def _call_llm(self, user_prompt: str, guide: str) -> str:
async def _call_llm(self, user_prompt: str, guide: str, username: str | None = None) -> str:
"""Call the configured AI provider and return generated strategy code."""
from app.services.ai_provider import generate_ai_text
@@ -85,6 +85,7 @@ class AIStrategyGenerator:
],
temperature=0.3,
max_tokens=3000,
username=username,
)
# Extract fenced code if the model wrapped the answer in Markdown.
if "```python" in content: