File size: 601 Bytes
05835bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b0349e
05835bd
a793254
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import openai

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

def GenerateResponse(input_text):
    response = openai.Completion.create(model="text-davinci-003", prompt=input_text,max_tokens= 50,temperature=0.1)
    output = response.choices[0].text
    return output.strip()

def chatbot(input,history=[]):
    result=GenerateResponse(input)
    history.append((input,result))
    return history,history

import gradio as gr

app = gr.Interface(fn=chatbot,inputs=["text","state"],outputs=["chatbot","state"],title="ChatGPT Demo")

app.launch(debug=True, share=True)