Spaces:
Runtime error
Runtime error
import gradio as gr | |
from random import randint | |
import os | |
from openai import OpenAI | |
tok = os.getenv('deepseekapi') | |
client = OpenAI(api_key=tok, base_url="https://api.deepseek.com") | |
def response(message, history): | |
if message=="How do I buy a yacht?": | |
response="You don't" | |
elif message=="你会说中文吗": | |
response="我是一只鸡" | |
else: | |
response = client.chat.completions.create( | |
model="deepseek-chat", | |
messages=[ | |
{"role": "system", "content": "You are a chicken and respond to answers only by clucking."}, | |
{"role": "user", "content": message}, | |
], | |
max_tokens=144, | |
temperature=0.7, | |
stream=False) | |
response = response.choices[0].message.content | |
return response | |
gr.ChatInterface(response).launch() |