Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import functions as fn | |
| import json | |
| data = fn.load_embeddings() | |
| num_documents = data['num_documents'] | |
| num_segment_contents = data['num_segment_contents'] | |
| with open("gradio.json", encoding='utf-8') as f: | |
| config = json.load(f) | |
| config['description'] = config['description'].format(num_documents=num_documents, num_segment_contents=num_segment_contents) | |
| def on_submit(query, history): | |
| response = fn.rag_response(query, data=data, detailed_response=False) | |
| return gr.HTML(response.replace("\n", "<br>")) | |
| demo = gr.ChatInterface(fn=on_submit, cache_examples= False, **config) | |
| demo.launch() |