Spaces:
Sleeping
Sleeping
File size: 832 Bytes
1901454 f69d529 1901454 9c22f51 1901454 |
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 |
from openai import OpenAI
import gradio as gr
messages = [
{"role": "system", "content": "You are AI specialized in Legal. Please don't answer questions other than legal"},
]
client = OpenAI(api_key="DEEPSEEK_API_KEY", base_url="https://openrouter.ai/api/v1")
def chatbot(input):
if input:
messages.append({"role": "user", "content": input})
chat = client.chat.completions.create(
model="deepseek/deepseek-r1:free", messages=messages
)
reply = chat.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
return reply
inputs = gr.Textbox(lines=7, label="Query")
outputs = gr.Textbox(label="Response")
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Legal Prodigy",
theme="compact").launch(share=True)
|