Spaces:
Running
Running
displays index updated date
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import transformers
|
|
| 3 |
import gradio as gr
|
| 4 |
from ragatouille import RAGPretrainedModel
|
| 5 |
from huggingface_hub import InferenceClient
|
|
|
|
|
|
|
| 6 |
|
| 7 |
retrieve_results = 10
|
| 8 |
|
|
@@ -22,6 +24,17 @@ except:
|
|
| 22 |
gr.Warning("Retriever not working!")
|
| 23 |
|
| 24 |
mark_text = '# π Search Results\n'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
def rag_cleaner(inp):
|
| 27 |
rank = inp['rank']
|
|
@@ -44,7 +57,7 @@ def get_rag(message):
|
|
| 44 |
return get_references(message, RAG)
|
| 45 |
|
| 46 |
with gr.Blocks(theme = gr.themes.Soft()) as demo:
|
| 47 |
-
header = gr.Markdown(
|
| 48 |
with gr.Group():
|
| 49 |
msg = gr.Textbox(label = 'Search')
|
| 50 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
from ragatouille import RAGPretrainedModel
|
| 5 |
from huggingface_hub import InferenceClient
|
| 6 |
+
import re
|
| 7 |
+
from datetime import datetime
|
| 8 |
|
| 9 |
retrieve_results = 10
|
| 10 |
|
|
|
|
| 24 |
gr.Warning("Retriever not working!")
|
| 25 |
|
| 26 |
mark_text = '# π Search Results\n'
|
| 27 |
+
header_text = "# ArXiv RAG\n"
|
| 28 |
+
try:
|
| 29 |
+
with open("README.md", "r") as f:
|
| 30 |
+
mdfile = f.read()
|
| 31 |
+
date_pattern = r'Index Last Updated : \d{4}-\d{2}-\d{2}'
|
| 32 |
+
match = re.search(date_pattern, mdfile)
|
| 33 |
+
date = match.group().split(': ')[1]
|
| 34 |
+
formatted_date = datetime.strptime(date, '%Y-%m-%d').strftime('%d %b %Y')
|
| 35 |
+
header_text += f'Index Last Updated: {formatted_date}\n'
|
| 36 |
+
except:
|
| 37 |
+
pass
|
| 38 |
|
| 39 |
def rag_cleaner(inp):
|
| 40 |
rank = inp['rank']
|
|
|
|
| 57 |
return get_references(message, RAG)
|
| 58 |
|
| 59 |
with gr.Blocks(theme = gr.themes.Soft()) as demo:
|
| 60 |
+
header = gr.Markdown(header_text)
|
| 61 |
with gr.Group():
|
| 62 |
msg = gr.Textbox(label = 'Search')
|
| 63 |
with gr.Accordion("Advanced Settings", open=False):
|