File size: 732 Bytes
a4816a5
 
 
 
 
 
 
 
 
 
 
770cb3e
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def query_deepseek(prompt):
    payload = {
        "inputs": f"<|system|>You are a helpful assistant.<|user|>{prompt}<|assistant|>",
        "parameters": {"max_new_tokens": 200}
    }
    response = requests.post(
        f"https://api-inference.huggingface.co/models/{DEEPSEEK_MODEL}",
        headers=headers,
        json=payload
    )
    
    try:
        result = response.json()
        # Debug output if response is not a list
        if isinstance(result, dict) and "error" in result:
            return f"⚠️ DeepSeek API error: {result['error']}"
        return result[0]["generated_text"].split("<|assistant|>")[-1].strip()
    except Exception as e:
        return f"⚠️ Failed to parse DeepSeek response: {e}"