File size: 1,125 Bytes
24f8339
8118795
24f8339
 
 
 
 
cbc7e45
8118795
24f8339
 
 
 
 
 
b848ccf
24f8339
 
b848ccf
24f8339
 
56726b2
24f8339
 
 
 
 
 
 
 
8118795
24f8339
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
29
30
31
32
33
 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