Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AstraDB + Tool Calling Agent + Retriever tool - does not work after upgrade to v1.1 #5294

Open
TOWaB opened this issue Dec 16, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@TOWaB
Copy link

TOWaB commented Dec 16, 2024

Bug Description

I am using a tool calling agent to retrieve information from 3 tools based on logic.

If Q is about X got to tool X and so on...

This worked absolutely fine until I upgraded to v1.1

I have managed to get it tested it and working in Datastax environment before moving to my own environment. In Datastax environment still works fine, but in my environment I get the following error in the tool calling agent:

TypeError: AstraDBVectorStore.asimilarity_search() got multiple values for argument 'query'

  • I have checked the workflows, they are identical.
  • I have checked the endpoints/tokens/settings - all identical
  • I had an error in Datastax environment where it would not accept the Azure OpenAI embeddings node on the DX Astra DB node, and had to use Astra vectorise option. I have tried both options on my environment, both build successfully, but still the same error.
  • I have rebuild and created all the nodes, as I had problems before and this solved the problem.
  • I have a separate instance with the old version in parallel that works with the database, so there is no problem there.
  • I have checked the code on both instances, it is identical.

This is the fool error on the node:


Error building Component Context and Logic Agent:

Traceback (most recent call last):
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/base/agents/events.py", line 258, in process_agent_events
async for event in agent_executor:
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1388, in astream_events
async for event in event_stream:
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tracers/event_stream.py", line 1012, in _astream_events_implementation_v2
await task
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tracers/event_stream.py", line 967, in consume_astream
async for _ in event_streamer.tap_output_aiter(run_id, stream):
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tracers/event_stream.py", line 203, in tap_output_aiter
async for chunk in output:
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain/agents/agent.py", line 1805, in astream
async for step in iterator:
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain/agents/agent_iterator.py", line 266, in aiter
async for chunk in self.agent_executor._aiter_next_step(
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain/agents/agent.py", line 1551, in _aiter_next_step
result = await asyncio.gather(
^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain/agents/agent.py", line 1584, in _aperform_agent_action
observation = await tool.arun(
^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tools/base.py", line 839, in arun
raise error_to_raise
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tools/base.py", line 805, in arun
response = await asyncio.create_task(coro, context=context) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tools/simple.py", line 111, in _arun
return await self.coroutine(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tools/retriever.py", line 45, in _aget_relevant_documents
docs = await retriever.ainvoke(query, config={"callbacks": callbacks})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/retrievers.py", line 329, in ainvoke
raise e
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/retrievers.py", line 322, in ainvoke
result = await self._aget_relevant_documents(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/vectorstores/base.py", line 1101, in _aget_relevant_documents
docs = await self.vectorstore.asimilarity_search(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AstraDBVectorStore.asimilarity_search() got multiple values for argument 'query'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 709, in _build_results
result = await initialize.loading.get_instance_results(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 68, in get_instance_results
return await build_component(params=custom_params, custom_component=custom_component)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 145, in build_component
build_results, artifacts = await custom_component.build_results()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 837, in build_results
return await self._build_with_tracing()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 819, in _build_with_tracing
_results, _artifacts = await self._build_results()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 883, in _build_results
result = await method()
^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/base/agents/agent.py", line 82, in message_response
message = await self.run_agent(agent=agent)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/base/agents/agent.py", line 158, in run_agent
result = await process_agent_events(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/base/agents/events.py", line 269, in process_agent_events
raise ExceptionWithMessageError(agent_message) from e
langflow.base.agents.events.ExceptionWithMessageError

Reproduction

  1. I upgraded the Lanflow version to 1.1.1
  2. Same setup as before
  3. Added my credentials
  4. Upgraded the nodes
  5. Errors in Retreival tools nodes => solved by deleting and readding the node and setting it up again
  6. All nodes tested and work imdividually
  7. Agent node spits out the error: Error building Component Context and Logic Agent

Expected behavior

Use logic to select the correct tools to perform a search and retrieve data to give an answer

Who can help?

No response

Operating System

Windows

Langflow Version

1.1.1

Python Version

None

Screenshot

No response

Flow File

No response

@TOWaB TOWaB added the bug Something isn't working label Dec 16, 2024
Copy link

dosubot bot commented Dec 16, 2024

Hello @TOWaB! I'm here to help you solve bugs, answer questions, and become a contributor.

The error you're encountering, TypeError: AstraDBVectorStore.asimilarity_search() got multiple values for argument 'query', suggests that there might be an issue with how the arguments are being passed to the asimilarity_search() method in your environment. This could be due to changes in how arguments are handled in the Langflow v1.1.1 update.

In the updated version, argument passing to the asimilarity_search() method is managed by the _build_search_args() method, which constructs a dictionary of arguments. This includes the "query" key, among others, and these arguments are then passed to the search method [1][2].

Here are a few steps you can take to troubleshoot and resolve the issue:

  1. Check Argument Construction: Ensure that the _build_search_args() method is correctly constructing the arguments in your environment. There might be a duplication or misconfiguration causing the query argument to be passed multiple times.

  2. Review Code Changes: Compare the code related to argument handling in both environments. Even though you mentioned the code is identical, there might be subtle differences in how the environments handle the code execution.

  3. Environment Differences: Since the issue does not occur in the Datastax environment, there might be differences in the Python environment or dependencies. Ensure that all dependencies are the same version in both environments.

  4. Debugging: Add logging or print statements in the _build_search_args() method to see what arguments are being constructed and passed to the asimilarity_search() method. This can help identify where the duplication is occurring.

By focusing on how the arguments are constructed and passed, you should be able to identify the source of the error and make the necessary adjustments.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@TOWaB
Copy link
Author

TOWaB commented Dec 17, 2024

Dear @erichare, I am sorry to chase, but did you have a chance to look at the above, I have exhausted all the avenues and ideas I have on how to fix it.

@erichare
Copy link
Collaborator

@TOWaB not yet, but would you be able to provide your flow file by exporting it in the Langflow UI? (if there's anything proprietary or sensitive please remove it first, minimal example of the error is ideal). I'll check it out today!

@TOWaB
Copy link
Author

TOWaB commented Dec 17, 2024

@erichare I have attached a basic version of the flow. If you need more details, happy to share on an email or similar.
B2B Event Assistant V0.2 (PLAYGROUND).json

Really appreciate the help, thank you very much.

@erichare
Copy link
Collaborator

@TOWaB sorry, i might be missing something, but i loaded the flow, and im not actually seeing an Astra DB / similarity search component in the flow between the input and output? I see a couple that are isolated. could you highlight for me, maybe in a screenshot, where you're getting that error in the flow diagram you attached? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants