Spaces:
Runtime error
Runtime error
File size: 845 Bytes
7e6ed4a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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() |