原始代码

This commit is contained in:
xxm
2025-12-05 07:11:25 +00:00
parent 045e777a11
commit dd5339de32
46 changed files with 5848 additions and 0 deletions

19
ollama_client.py Normal file
View File

@@ -0,0 +1,19 @@
import requests
OLLAMA_URL = "http://127.0.0.1:11434/api/generate"
MODEL_NAME = "qwen3:8b"
def call_qwen(prompt: str, temperature: float = 0.8, max_tokens: int = 512) -> str:
payload = {
"model": MODEL_NAME,
"prompt": prompt,
"stream": False,
"options": {
"temperature": temperature,
"num_predict": max_tokens
}
}
resp = requests.post(OLLAMA_URL, json=payload, timeout=60)
resp.raise_for_status()
data = resp.json()
return data.get("response", "") or data.get("text", "")