import gradio as gr
import requests
def jnya(message, history):
ls=list(history)
ls.append({"role":"user","content":message})
rs = requests.post("https://vedayuga.com/api/",json={"q":ls},headers = {'Accept': 'application/json',"Content-Type":"application/json; charset=utf-8"}).json()
console.log(rs)
return rs.content if (rs and rs.content) else "There was an error. Please try again."
gr.ChatInterface(
jnya,
type="messages",
chatbot=gr.Chatbot(height=300),
textbox=gr.Textbox(placeholder="Type your message here...", container=False, scale=7),
title="Vedayuga",
description="Privacy first AI",
theme="ocean",
examples=["Ask multiple-choice quiz for grade II", "Best thriller movies with unique storyline", "Tell me a Panchatantra like short-story","Write javascript code to make a calculator"],
cache_examples=False,
).launch()