Variables implementation #559
Replies: 4 comments 12 replies
-
Some important scenarios we need to consider for variables, all closely related:
Dynamic variables would be variables that can have their value set or updated during a session. For example, a process app may have a task description that uses a variable e.g. {question_answer} where that answer is taken from a previous tasks human input question, see next point.
Human input tasks should allow the selection of a named variable (or a variable per question for "form" human inputs) that the response to the human input will be saved into, and be accessible throughout the rest of the sessions prompts (tasks, agent role/goal, tool descriptions etc).
Variables may need to change after a crew is "built" or after tools, etc are instantiated. i.e we can't just
And as a side note, we should consider how to improve human input in chat apps to allow more formatted inputs and the ability to direct outputs for some responses to variables. This is difficult because of the lack of tasks in chat apps. @anada10 |
Beta Was this translation helpful? Give feedback.
-
What is the advantage of using dynamic session variables vs using human input/task output as context for the next tasks? Can we have some examples on when we would want to update the session variables mid-session? |
Beta Was this translation helpful? Give feedback.
-
RE:
I did some experimenting of where to pass the filters and got it working. It was a little tricky because of multiple versions of docs with similar/confusing param names, and that we don't call the method which takes the filter directly in the self query retriever, but we can fix that. For "similarity search", this POC works: diff --git a/agent-backend/src/tools/retrievers/similarity_search.py b/agent-backend/src/tools/retrievers/similarity_search.py
index 214231a1..3120391f 100644
--- a/agent-backend/src/tools/retrievers/similarity_search.py
+++ b/agent-backend/src/tools/retrievers/similarity_search.py
@@ -15,5 +15,13 @@ class SimilaritySearchRetriever(BaseRetriever):
def _get_relevant_documents(self, query: str, *, run_manager: CallbackManagerForRetrieverRun):
embedded_question = self.embedding.embed_query(query)
if isinstance(self.vector_store, Qdrant):
- return self.vector_store.similarity_search_with_score_by_vector(embedded_question, k=self.k)
+ from qdrant_client.http import models
+ return self.vector_store.similarity_search_with_score_by_vector(embedded_question, k=self.k, filter=models.Filter(
+ must=[
+ models.FieldCondition(
+ key="Retweets",
+ match=models.MatchValue(value="11097"),
+ )
+ ]
+ ))
return self.vector_store.similarity_search_by_vector_with_score(embedded_question, k=self.k) Just hardcodes to find a specific value, uses Must. So we could construct those filter field conditions based on some configuration in the tool that incorporates variables 😎 |
Beta Was this translation helpful? Give feedback.
-
I tried using context in this example and it worked as expected. The final output took into consideration my name, address, and email when generating the final output
|
Beta Was this translation helpful? Give feedback.
-
re #490
Beta Was this translation helpful? Give feedback.
All reactions