Spaces:
Sleeping
Sleeping
| 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() | |