|
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) |
|
|
|
|
|
|