Shreyas094
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -174,14 +174,14 @@ def scrape_with_trafilatura(url, max_chars=None, timeout=5, use_beautifulsoup=Fa
|
|
174 |
return ""
|
175 |
|
176 |
def rephrase_query(chat_history, query, temperature=0.2):
|
177 |
-
system_prompt = """You are a highly intelligent conversational
|
178 |
-
1.
|
179 |
-
2. If it
|
180 |
-
3. If it
|
181 |
-
4.
|
182 |
|
183 |
user_prompt = f"""
|
184 |
-
|
185 |
{chat_history}
|
186 |
|
187 |
New query: {query}
|
@@ -269,7 +269,7 @@ def is_content_unique(new_content, existing_contents, similarity_threshold=0.8):
|
|
269 |
return True
|
270 |
|
271 |
def assess_relevance_and_summarize(llm_client, query, document, temperature=0.2):
|
272 |
-
system_prompt = """You are a
|
273 |
|
274 |
user_prompt = f"""
|
275 |
Query: {query}
|
@@ -278,7 +278,7 @@ Document Content:
|
|
278 |
{document['content']}
|
279 |
|
280 |
Instructions:
|
281 |
-
1. Assess if the document is relevant to the
|
282 |
2. If relevant, summarize the main points in 1-2 sentences.
|
283 |
3. If not relevant, simply state "Not relevant".
|
284 |
|
@@ -582,6 +582,7 @@ iface = gr.ChatInterface(
|
|
582 |
chat_function,
|
583 |
title="SearXNG Scraper for Financial News",
|
584 |
description="Enter your query, and I'll search the web for the most recent and relevant financial news, scrape content, and provide summarized results.",
|
|
|
585 |
additional_inputs=[
|
586 |
gr.Slider(5, 20, value=10, step=1, label="Number of initial results"),
|
587 |
gr.Dropdown(["bs4", "trafilatura", "scrapy", "newspaper"], value="bs4", label="Scraping Method"),
|
@@ -607,7 +608,7 @@ iface = gr.ChatInterface(
|
|
607 |
show_copy_button=True,
|
608 |
likeable=True,
|
609 |
layout="bubble",
|
610 |
-
height=
|
611 |
)
|
612 |
)
|
613 |
|
|
|
174 |
return ""
|
175 |
|
176 |
def rephrase_query(chat_history, query, temperature=0.2):
|
177 |
+
system_prompt = """You are a highly intelligent and context-aware conversational assistant. Your task is to accurately rephrase the given query based on the provided conversation context. Follow these steps:
|
178 |
+
1. Assess whether the new query logically follows from the conversation context or introduces a new, unrelated topic.
|
179 |
+
2. If it is a continuation, incorporate the most relevant details from the context to make the rephrased query more specific and aligned with the ongoing conversation.
|
180 |
+
3. If it introduces a new topic, rewrite the query to ensure clarity, precision, and suitability for a standalone search, avoiding any irrelevant context from the conversation.
|
181 |
+
4. Return ONLY the rephrased query, ensuring it is concise, clear, and contextually accurate, without any additional commentary or explanation."""
|
182 |
|
183 |
user_prompt = f"""
|
184 |
+
Conversation context:
|
185 |
{chat_history}
|
186 |
|
187 |
New query: {query}
|
|
|
269 |
return True
|
270 |
|
271 |
def assess_relevance_and_summarize(llm_client, query, document, temperature=0.2):
|
272 |
+
system_prompt = """You are a world class AI assistant. Your task is to assess whether the given text is relevant to the user's query and provide a brief summary if it is relevant."""
|
273 |
|
274 |
user_prompt = f"""
|
275 |
Query: {query}
|
|
|
278 |
{document['content']}
|
279 |
|
280 |
Instructions:
|
281 |
+
1. Assess if the document is relevant to the QUERY made by the user.
|
282 |
2. If relevant, summarize the main points in 1-2 sentences.
|
283 |
3. If not relevant, simply state "Not relevant".
|
284 |
|
|
|
582 |
chat_function,
|
583 |
title="SearXNG Scraper for Financial News",
|
584 |
description="Enter your query, and I'll search the web for the most recent and relevant financial news, scrape content, and provide summarized results.",
|
585 |
+
theme=gr.Theme.from_hub("allenai/gradio-theme"),
|
586 |
additional_inputs=[
|
587 |
gr.Slider(5, 20, value=10, step=1, label="Number of initial results"),
|
588 |
gr.Dropdown(["bs4", "trafilatura", "scrapy", "newspaper"], value="bs4", label="Scraping Method"),
|
|
|
608 |
show_copy_button=True,
|
609 |
likeable=True,
|
610 |
layout="bubble",
|
611 |
+
height=600,
|
612 |
)
|
613 |
)
|
614 |
|