vtiyyal1's picture
Upload 2 files
cde1f49 verified
raw
history blame
1.01 kB
import openai
import gradio as gr
from full_chain import get_response
import os
api_key = os.getenv("OPENAI_API_KEY")
client = openai.OpenAI(api_key=api_key)
def create_hyperlink(url, title, domain):
return f"<a href='{url}'>{title}</a>" + " (" + domain + ")"
def predict(message, history):
print("get_responses: ")
# print(get_response(message, rerank_type="crossencoder"))
responder, links, titles, domains = get_response(message, rerank_type="crossencoder")
for i in range(len(links)):
links[i] = create_hyperlink(links[i], titles[i], domains[i])
out = responder + "\n" + "\n".join(links)
return out
gr.ChatInterface(predict,
examples = [
"How many Americans Smoke?",
"What are some measures taken by the Indian Government to reduce the smoking population?",
"Does smoking negatively affect my health?"
]
).launch()