Spaces:
Running
Running
File size: 827 Bytes
f65a6d5 a58941d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
import requests
# DeepSeek Chat API details
API_URL = "https://api.deepseek.com/v1/chat/completions" # Adjust if needed
API_KEY = "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" # Replace with your actual API key
def chat_with_deepseek(user_input):
headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
payload = {
"model": "deepseek-chat", # Adjust the model name if needed
"messages": [{"role": "user", "content": user_input}]
}
response = requests.post(API_URL, json=payload, headers=headers)
return response.json().get("choices", [{}])[0].get("message", {}).get("content", "No response.")
iface = gr.Interface(fn=chat_with_deepseek, inputs="text", outputs="text", title="DeepSeek Chatbot")
iface.launch()
|