IMAGEIN / app.py
Bagda's picture
Update app.py
24f8339 verified
import gradio as gr
# यहाँ आप अपने AI मॉडल या API को कॉल करें
def respond_to_message(message, chat_history):
# सरल उदाहरण: यूजर मैसेज को एआई की तरह जवाब देता है
bot_message = f"AI: आपने पूछा: {message}"
chat_history.append((message, bot_message))
return "", chat_history
with gr.Blocks() as demo:
chatbot = gr.Chatbot(label="AI चैट बोर्ड")
msg = gr.Textbox(label="आपका मैसेज")
clear = gr.ClearButton([msg, chatbot])
msg.submit(respond_to_message, [msg, chatbot], [msg, chatbot])
demo.launch()
import openai
# OpenAI के लिए (उदाहरण)
openai.api_key = "YOUR_API_KEY"
def respond_to_message(message, chat_history):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": message}]
)
bot_message = response.choices[0].message['content']
chat_history.append((message, bot_message))
return "", chat_history