chatty / app.py
anisotropies's picture
Update app.py
623d123 verified
raw
history blame
915 Bytes
import gradio as gr
import os
def yes_man(message, history):
# if message.endswith("?"):
# return "Yes"
#else:
# return "Ask me anything!"
import requests
headers = {"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"}
API_URL = "https://api-inference.huggingface.co/models/gpt2"
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
data = query({"inputs": message})
return data
gr.ChatInterface(
yes_man,
chatbot=gr.Chatbot(height=300),
textbox=gr.Textbox(placeholder="Ask me a yes or no question", container=False, scale=7),
title="Yes Man",
description="Ask Yes Man any question",
theme="soft",
examples=["Hello", "Am I cool?", "Are tomatoes vegetables?"],
cache_examples=True,
retry_btn=None,
undo_btn="Delete Previous",
clear_btn="Clear",
).launch()