ChatGPT / app.py
ChauhanV's picture
Update app.py
6af1475
raw
history blame contribute delete
589 Bytes
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)