Shreyas094
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -67,14 +67,23 @@ similarity_model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
67 |
|
68 |
|
69 |
def determine_query_type(query: str, chat_history: str, llm_client) -> str:
|
70 |
-
system_prompt = """You are an intelligent agent tasked with determining whether a user query requires a web search or can be answered using
|
71 |
|
72 |
-
Instructions:
|
73 |
1. If the query is a general conversation starter, greeting, or can be answered without real-time information, classify it as "knowledge_base".
|
74 |
2. If the query requires up-to-date information, news, or specific data that might change over time, classify it as "web_search".
|
75 |
3. Consider the chat history when making your decision.
|
76 |
4. Respond with ONLY "knowledge_base" or "web_search".
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
Examples:
|
79 |
- "Hi, how are you?" -> "knowledge_base"
|
80 |
- "What's the latest news in the US?" -> "web_search"
|
@@ -106,7 +115,7 @@ def determine_query_type(query: str, chat_history: str, llm_client) -> str:
|
|
106 |
return "web_search" if decision == "web_search" else "knowledge_base"
|
107 |
except Exception as e:
|
108 |
logger.error(f"Error determining query type: {e}")
|
109 |
-
return "web_search" # Default to web search if there's an error
|
110 |
|
111 |
def generate_ai_response(query: str, chat_history: str, llm_client, model: str) -> str:
|
112 |
system_prompt = """You are a helpful AI assistant. Provide a concise and informative response to the user's query based on your existing knowledge. Do not make up information or claim to have real-time data."""
|
|
|
67 |
|
68 |
|
69 |
def determine_query_type(query: str, chat_history: str, llm_client) -> str:
|
70 |
+
system_prompt = """You are Sentinel, an intelligent AI agent tasked with determining whether a user query requires a web search or can be answered using your existing knowledge base. Your task is to analyze the query and decide on the appropriate action.
|
71 |
|
72 |
+
Instructions for Sentinel:
|
73 |
1. If the query is a general conversation starter, greeting, or can be answered without real-time information, classify it as "knowledge_base".
|
74 |
2. If the query requires up-to-date information, news, or specific data that might change over time, classify it as "web_search".
|
75 |
3. Consider the chat history when making your decision.
|
76 |
4. Respond with ONLY "knowledge_base" or "web_search".
|
77 |
|
78 |
+
Instructions for users (include this in your first interaction):
|
79 |
+
"Hello! I'm Sentinel, your AI assistant. I can help you with various tasks and answer your questions. Here's how to get the best results:
|
80 |
+
- For general knowledge questions or conversational topics, just ask normally.
|
81 |
+
- For recent news, current events, or real-time data, mention that you need up-to-date information.
|
82 |
+
- If you're unsure, you can ask 'Do you need to search the web for this?'
|
83 |
+
- Feel free to ask follow-up questions or request clarification on any topic.
|
84 |
+
|
85 |
+
How can I assist you today?"
|
86 |
+
|
87 |
Examples:
|
88 |
- "Hi, how are you?" -> "knowledge_base"
|
89 |
- "What's the latest news in the US?" -> "web_search"
|
|
|
115 |
return "web_search" if decision == "web_search" else "knowledge_base"
|
116 |
except Exception as e:
|
117 |
logger.error(f"Error determining query type: {e}")
|
118 |
+
return "web_search" # Default to web search if there's an error # Default to web search if there's an error
|
119 |
|
120 |
def generate_ai_response(query: str, chat_history: str, llm_client, model: str) -> str:
|
121 |
system_prompt = """You are a helpful AI assistant. Provide a concise and informative response to the user's query based on your existing knowledge. Do not make up information or claim to have real-time data."""
|