Spaces:
Sleeping
Sleeping
John Graham Reynolds
commited on
Commit
·
5dc4034
1
Parent(s):
80dda63
grab date with fn inside runnable lambda
Browse files
chain.py
CHANGED
@@ -160,9 +160,13 @@ class ChainBuilder:
|
|
160 |
# vector_search_as_retriever = self.get_retriever()
|
161 |
# query_rewrite_prompt = self.get_query_rewrite_prompt()
|
162 |
|
|
|
|
|
|
|
163 |
# RAG Chain
|
164 |
chain = (
|
165 |
{
|
|
|
166 |
"question": itemgetter("messages") | RunnableLambda(self.extract_user_query_string), # set 'question' to the result of: grabbing the ["messages"] component of the dict we 'invoke()' or 'stream()', then passing to extract_user_query_string()
|
167 |
"chat_history": itemgetter("messages") | RunnableLambda(self.extract_chat_history),
|
168 |
"formatted_chat_history": itemgetter("messages")
|
@@ -180,8 +184,7 @@ class ChainBuilder:
|
|
180 |
| self.get_retriever() # set 'context' to the result of passing either the base question, or the reformatted question to the retriever for semantic search
|
181 |
| RunnableLambda(self.format_context),
|
182 |
"formatted_chat_history": itemgetter("formatted_chat_history"),
|
183 |
-
"question": itemgetter("question")
|
184 |
-
"date_str": datetime.datetime.now().strftime("%B %d, %Y"), # date to be passed to system prompt for context of when knowledge base was last updated
|
185 |
}
|
186 |
| self.get_prompt() # 'context', 'formatted_chat_history', and 'question' passed to prompt
|
187 |
| self.get_model() # prompt passed to model
|
|
|
160 |
# vector_search_as_retriever = self.get_retriever()
|
161 |
# query_rewrite_prompt = self.get_query_rewrite_prompt()
|
162 |
|
163 |
+
def get_date():
|
164 |
+
return {"today": datetime.datetime.now().strftime("%B %d, %Y")}
|
165 |
+
|
166 |
# RAG Chain
|
167 |
chain = (
|
168 |
{
|
169 |
+
"date_str": RunnableLambda(get_date), # date to be passed to system prompt for context of when knowledge base was last updated
|
170 |
"question": itemgetter("messages") | RunnableLambda(self.extract_user_query_string), # set 'question' to the result of: grabbing the ["messages"] component of the dict we 'invoke()' or 'stream()', then passing to extract_user_query_string()
|
171 |
"chat_history": itemgetter("messages") | RunnableLambda(self.extract_chat_history),
|
172 |
"formatted_chat_history": itemgetter("messages")
|
|
|
184 |
| self.get_retriever() # set 'context' to the result of passing either the base question, or the reformatted question to the retriever for semantic search
|
185 |
| RunnableLambda(self.format_context),
|
186 |
"formatted_chat_history": itemgetter("formatted_chat_history"),
|
187 |
+
"question": itemgetter("question")
|
|
|
188 |
}
|
189 |
| self.get_prompt() # 'context', 'formatted_chat_history', and 'question' passed to prompt
|
190 |
| self.get_model() # prompt passed to model
|