Wow, lots of things going on here. I swear I did my best to understand and contribute. After reformatting your code and evaluating the scenario you presented, these are my considerations:
- The
context
parameter does indeed exist in aTask
. However, let’s look at what the documentation says about this parameter: “Other tasks whose outputs will be used as context for this task.” Basically, you’ll use it when your current task depends on the output of a previous task (it can be omitted in the case ofProcess.sequential
). I suggest you review the documentation on tasks, especially the “Task Attributes” section. - The
config
parameter does indeed exist in aTask
. However, I don’t see the point of using it in your use case, since the information you were trying to pass can simply be included in thedescription
of your task (see how I included it in the reformatted version that I present below). - It wasn’t clear if you’re trying to implement a hierarchical
Process
. If that’s the case, I suggest you review the documentation on processes, especially on “Hierarchical Process”. I also suggest reading this thread on the subject. - As for the use of
Memory
, I suggest you review the documentation on the subject, especially the sections that exemplify customizations. - Finally, I suggest that you first successfully execute a super simplified version of the solution you’re proposing, trying to ensure that each small part of your solution is working as you want, and then increase the complexity to meet your effective use case.
Here’s the version of your code that I reformatted as I understood it:
def create_autonomous_task(user_query: str):
has_document = "collection" in st.session_state
document_status = "Uploaded" if has_document else "Not Uploaded"
return Task(
description=(f"""
Analyze and process the user query:
User Query: {user_query}
Available agent specializations:
1. Document Summarization Expert - .docx/.pdf summaries
2. Document Analysis Specialist - Document content questions
3. Conversational Assistant - General chat
Routing Rules:
1. If query contains "summarize" and document exists -> Summarizer
2. If document exists and question references content -> Document Analyst
3. All other cases -> General Chat
Context:
- Document Status: {document_status}
- Document Exists: {has_document}
"""),
expected_output="Immediate, final response prefixed with 'Final Answer:'"
)
chat_task = create_autonomous_task(user_input)