commit code
Some checks failed
Gitea Actions Demo / deploy (push) Failing after 2s

This commit is contained in:
2025-12-29 19:34:39 +08:00
parent 87160c5265
commit 6772699cfe
22 changed files with 2268 additions and 70 deletions

View File

@ -11,14 +11,14 @@ from utils.logger import logger
BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
MODEL = "deepseek-v3.2-exp"
MODEL = "deepseek-v3.2"
def _make_client() -> OpenAI:
return OpenAI(api_key=settings.DASHSCOPE_API_KEY, base_url=BASE_URL)
def _call_model(system_prompt: Optional[str], user_prompt: str, stream: bool = False) -> Any:
def _call_model(system_prompt: Optional[str], user_prompt: str, stream: bool = False, enable_search: bool = False) -> Any:
client = _make_client()
messages = []
if system_prompt:
@ -26,7 +26,7 @@ def _call_model(system_prompt: Optional[str], user_prompt: str, stream: bool = F
messages.append({"role": "user", "content": user_prompt})
# Non-streaming call for simplicity
resp = client.chat.completions.create(model=MODEL, messages=messages, stream=stream)
resp = client.chat.completions.create(model=MODEL, messages=messages, stream=stream, extra_body={"enable_search": enable_search})
# When stream=False the SDK typically returns a full object; content location may vary.
# We'll try common access patterns.
try:
@ -118,7 +118,7 @@ def generate_topics(start_time: Optional[str] = None, end_time: Optional[str] =
logger.debug(f"prompt for generate_topics:\n{user_prompt}")
content = _call_model(system_prompt=None, user_prompt=user_prompt)
content = _call_model(system_prompt=None, user_prompt=user_prompt, enable_search=True)
logger.debug(f"raw output from generate_topics:\n{content}")
if isinstance(content, (dict, list)):
return content