File size: 1,032 Bytes
6594e21
 
 
 
 
 
f536b5d
6594e21
 
 
 
 
 
f536b5d
 
6594e21
 
 
 
 
 
045bbff
6594e21
88b9d9d
de55809
6594e21
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
import openai
import gradio as gr

openai.api_key = "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"

messages = [
    {"role": "system", "content": "You are a chatbot that is very happy and kind."},
]

def chatbot(input):
    if input:
        messages.append({"role": "user", "content": input})
        chat = openai.ChatCompletion.create(
            model="gpt-3.5-turbo", messages=messages
            #model="gpt-4o", messages=messages
        )
        reply = chat.choices[0].message.content
        messages.append({"role": "assistant", "content": reply})
        return reply

inputs = gr.Textbox(lines=7, label="Chat with AI")
outputs = gr.Textbox(label="Reply_app_1")

gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="The AI Patch & Sparks Chatbot - App 1--- no doc ",
             description="Ask anything you want about Patch&Sparks",
             theme="compact").launch(share=True)