Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,24 +104,10 @@ def rag_response(query):
|
|
| 104 |
# Define tools using LangChain's `tool` decorator
|
| 105 |
@tool
|
| 106 |
def knowledge_base_tool(query: str):
|
| 107 |
-
"""
|
| 108 |
-
Tool function to query the knowledge base and retrieve a response.
|
| 109 |
-
Args:
|
| 110 |
-
query (str): The query to search the knowledge base.
|
| 111 |
-
Returns:
|
| 112 |
-
str: The response retrieved from the knowledge base.
|
| 113 |
-
"""
|
| 114 |
return rag_response(query)
|
| 115 |
|
| 116 |
@tool
|
| 117 |
def google_search_tool(query: str):
|
| 118 |
-
"""
|
| 119 |
-
Tool function to perform a Google search using the SERPER API.
|
| 120 |
-
Args:
|
| 121 |
-
query (str): The query to search on Google.
|
| 122 |
-
Returns:
|
| 123 |
-
list: List of snippets extracted from search results.
|
| 124 |
-
"""
|
| 125 |
return google_search(query)
|
| 126 |
|
| 127 |
tools = [knowledge_base_tool, google_search_tool]
|
|
@@ -185,9 +171,10 @@ def chatbot_response(message, history):
|
|
| 185 |
|
| 186 |
# Streamlit app
|
| 187 |
|
| 188 |
-
#
|
| 189 |
user_input = st.text_input("You:", "")
|
| 190 |
|
|
|
|
| 191 |
if st.button("Submit"):
|
| 192 |
if user_input:
|
| 193 |
response = chatbot_response(user_input, chat_history)
|
|
|
|
| 104 |
# Define tools using LangChain's `tool` decorator
|
| 105 |
@tool
|
| 106 |
def knowledge_base_tool(query: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
return rag_response(query)
|
| 108 |
|
| 109 |
@tool
|
| 110 |
def google_search_tool(query: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
return google_search(query)
|
| 112 |
|
| 113 |
tools = [knowledge_base_tool, google_search_tool]
|
|
|
|
| 171 |
|
| 172 |
# Streamlit app
|
| 173 |
|
| 174 |
+
# Create input field for user message
|
| 175 |
user_input = st.text_input("You:", "")
|
| 176 |
|
| 177 |
+
# Create a button for submitting the message
|
| 178 |
if st.button("Submit"):
|
| 179 |
if user_input:
|
| 180 |
response = chatbot_response(user_input, chat_history)
|