Spaces:
Runtime error
Runtime error
File size: 2,834 Bytes
d2704de a7aa04c ce5ac72 2e2586b d2704de 56a371f 2e2586b 3fcfdf4 d2704de 7077627 170c43f c879b4e 7373c0a |
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 40 41 42 43 44 45 46 47 48 |
from pyChatGPT import ChatGPT
import os
# os.environ["SessionToken"] = SessionToken
# refresh the authorization token
session_token = os.environ.get('SessionToken')
def chat_hf(text,session_tokenz):
try:
api = ChatGPT(session_token)
resp = api.send_message(text)
api.refresh_auth() # refresh the authorization token
api.reset_conversation() # reset the conversation
xyz = resp['message']
except:
api = ChatGPT(session_tokenz)
resp = api.send_message(text)
api.refresh_auth() # refresh the authorization token
api.reset_conversation() # reset the conversation
xyz = resp['message']
return xyz
#@title GRadio for SDK api
import gradio as gr
gr.Interface(
chat_hf,
[gr.Textbox(label = ' Input custom text for ChatGPT! '),
gr.Textbox(label = ' If it fails enter custom session key ')],
outputs = gr.outputs.Textbox(type="text",label="chatGPT response"),
examples =[['Write poem on crypto'],['Write a sales pitch for social media app'],['Reverse string in python'] ]
, title = "" +' ChatGpt π€π¬π» on π€ huggingface. '+ "",
description="""ChatGPT π€π¬π» is a conversational AI app that allows users to engage in natural language conversations with a virtual assistant. The app uses advanced machine learning algorithms to understand and respond to user queries in a human-like manner. With its ability to answer follow-up questions, admit mistakes, and reject inappropriate requests, ChatGPT offers a highly interactive and engaging experience. Try ChatGPT now and experience the power of language modeling in dialogue built with β€οΈ @[Xhaheen](https://www.linkedin.com/in/sallu-mandya/) \n\nIf it fails enter cusom session key see video for reference refer @[Bhavesh bhat video](https://youtu.be/TdNSj_qgdFk)
<p>You can duplicating this space and use your own session token: <a style='display:inline-block' href='https://huggingface.co/spaces/Xhaheen/ChatGPT_HF?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14' alt='Duplicate Space'></a></p>
""").launch(debug = True) |