File size: 960 Bytes
6649cea
59368e0
 
51723b0
59368e0
2df22da
b23f08d
6649cea
39131cb
6649cea
59368e0
6649cea
 
 
 
7567357
 
 
 
 
 
 
6649cea
 
 
 
59368e0
6649cea
 
59368e0
7567357
6649cea
c9165ff
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 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=1.2,
      max_tokens=2500,
      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()