imagen / app.py
focusit's picture
Update app.py
c0f6f3e
raw
history blame
1.26 kB
import gradio
import requests
import os
import json
from hugchat import hugchat
from bardapi import Bard
auth = os.environ.get('Authorization')
API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-xl"
headers = {"Authorization": auth}
#Replace XXXX with the values you get from __Secure-1PSID
os.environ['_BARD_API_KEY']="XXXX"
def huggChat(data):
# start a new huggingchat connection
chatbot = hugchat.ChatBot(cookie_path="cookies.json")
# start a new conversation
id = chatbot.new_conversation()
chatbot.change_conversation(id)
# print the response
result = chatbot.chat(data)
print(result)
return 'Hello Sir'
def bardChat(data):
print(Bard().get_answer(data)['content'])
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
print(response.json())
return 'Aakash is KING'
#return json.dumps({'message':response.json()['answer'],'action':'null'})
def responsenew(data):
return bardChat(data)
#return huggChat(data)
#return query({"inputs": "The answer to the universe is",})
gradio_interface = gradio.Interface(
fn = responsenew,
inputs = "text",
outputs = "text"
)
gradio_interface.launch()