Spaces:
Runtime error
Runtime error
File size: 724 Bytes
80769bf 5301720 80769bf 5301720 80769bf 5301720 80769bf 5301720 80769bf 5301720 80769bf 5301720 80769bf 5301720 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from pyChatGPT import ChatGPT
import os
from loguru import logger
def chat(text):
try:
session_token = os.environ.get('SessionToken')
api = ChatGPT(session_token)
resp = api.send_message(text)
api.refresh_auth()
api.reset_conversation()
response = resp['message']
logger.info(f"response_: {response}")
except:
response = "Sorry, I'm am tired."
return response
import gradio as gr
demo = gr.Interface(chat,
inputs = [gr.Textbox(label = 'Input: ')],
outputs = gr.outputs.Textbox(type="text",label="from ChatGPT:"),
title = "talk with ChatGPT",
description= "")
demo.launch(debug = True) |