File size: 965 Bytes
6649cea
59368e0
 
7f1f8e6
6649cea
39131cb
6649cea
59368e0
6649cea
 
 
 
7567357
65fb13c
5e09403
7567357
 
 
 
6649cea
 
 
 
59368e0
6649cea
 
59368e0
7567357
6649cea
7e1c21b
7f1f8e6
 
 
 
 
 
 
 
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
34
35
36
37
38
39
import openai
import gradio as gr

openai.api_key = "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"
messages = [
    {"role": "system", "content": "You are a helpful and kind AI Assistant for content and blog writing"},
]

def chatbot(input):
    if input:
        messages.append({"role": "user", "content": input})
        chat = openai.ChatCompletion.create(
        model="gpt-3.5-turbo", messages=messages,
           temperature=0.7,
      max_tokens=500,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0

        )
        reply = chat.choices[0].message.content
        messages.append({"role": "assistant", "content": reply})
        return reply

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

gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Lisa's AI Chatbot",
             description="Ask anything you want",
             theme="compact").launch()