File size: 1,769 Bytes
89b989d
 
 
 
 
 
ba088f5
f9477dd
ba088f5
91d1376
ba088f5
 
 
89b989d
d7043af
89b989d
6dffda9
 
d7043af
89b989d
 
 
 
c5dd9d7
89b989d
 
c5dd9d7
89b989d
 
d544bc4
20c148a
e2976eb
20c148a
a18f1cf
ba088f5
89b989d
20c148a
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
from gradio_client import Client
import json

import gradio as gr
import os

custom_css = """
#component-11{
    border: 2px solid #0074d9; 
    background: #0074d9; 
}
footer {visibility: hidden}
"""

def generate_answer(Question=""):
    try:
        client = Client(os.getenv("host"), hf_token=os.getenv("nekot"))
        json_path = client.predict(fn_index=1)  # Auto-detect the path
        response = client.predict(Question, json_path, fn_index=0)
        with open(response[1], 'r') as json_file:
            data = json.load(json_file)[0]
            prompt = data[0]
            answer = data[1]
        return answer
    except Exception as e:
        print("An error has occurred: ", e)
        return "Sorry, we are not available right now."


examples = ["Is Nigerian Senator, Enyinnaya Abaribe, shot dead?", "Liberia has the world's highest rainfall rate: true or false"]
description = "Ask your question"
article = "<p><strong>Disclaimer:</strong> Dubawa Chatbot is designed to assist users with fact-checked information and answer questions related to Dubawa and fact-checked articles. While we strive to provide accurate and reliable information, please be aware that the chatbot's responses are generated based on available data and may not always reflect the most up-to-date information. Users are encouraged to cross-verify information for critical decisions and consult trusted sources for any specific or sensitive inquiries.</p>"
title = "Dubawa Chatbot"
thumbnail = 'Dubawa'
demo = gr.Interface(fn=generate_answer, inputs="text", outputs="text", title=title, description=description,cache_examples=True, examples=examples, article=article, thumbnail=thumbnail,allow_flagging=True, css=custom_css   )

demo.launch(show_api=False, show_tips=True)