File size: 752 Bytes
4440f5f
 
 
 
 
 
 
 
 
 
bd604ec
 
4440f5f
 
6d42934
 
 
 
 
 
 
 
 
4440f5f
bd604ec
4440f5f
 
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
from ragatouille import RAGPretrainedModel
import os 
import gradio as gr


path_to_index = 'colbert/indexes/akhooli/Arabic-ColBERT-100knew_index'
message = "waiting to load index ..."
if os.path.exists(path_to_index):
    RAG = RAGPretrainedModel.from_index(path_to_index)
    message = "index loaded!"
    print(message)
    
import gradio as gr

def process_results(results):
  for r in results:
    print(f"Sura: {r['document_id']} ({r['document_metadata']}) \n Text:{r['content']}")

k = 3 # How many documents you want to retrieve

def answer_fn(query):
    results = RAG.search(query= query)
    return process_results(results)

qapp = gr.Interface(fn=answer_fn, inputs="textbox", outputs="textbox")
if __name__ == "__main__":
    qapp.launch()