Lesson_6_Student - AttributeError: 'NoneType' object has no attribute 'queries'

Hi, I have downloaded the notebook on my computer (Ubuntu 22.04) and try to run it using Ollama and mistral:

from langchain_ollama import ChatOllama
# Replace ChatOpenAI with ChatOllama
model = ChatOllama(
    model="mistral",
    temperature=0.0,
    # other params ...
)

I receive an AttributeError message: AttributeError: 'NoneType' object has no attribute 'queries', pointing to the following part in the research_plan_node:

for q in queries.queries:
        response = tavily.search(query=q, max_results=2)
        for r in response['results']:
            content.append(r['content'])

Someone encountered this error?

Here is the full error message:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[31], line 2
      1 thread = {"configurable": {"thread_id": "1"}}
----> 2 for s in graph.stream({
      3     'task': "what is the difference between langchain and langsmith",
      4     "max_revisions": 2,
      5     "revision_number": 1,
      6 }, thread):
      7     print(s)

File ~/anaconda3/envs/kg/lib/python3.9/site-packages/langgraph/pregel/__init__.py:1029, in Pregel.stream(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug)
   1026         break
   1028 # panic on failure or timeout
-> 1029 _panic_or_proceed(done, inflight, loop.step)
   1030 # don't keep futures around in memory longer than needed
   1031 del done, inflight, futures

File ~/anaconda3/envs/kg/lib/python3.9/site-packages/langgraph/pregel/__init__.py:1456, in _panic_or_proceed(done, inflight, step, timeout_exc_cls)
   1454             inflight.pop().cancel()
   1455         # raise the exception
-> 1456         raise exc
   1458 if inflight:
   1459     # if we got here means we timed out
   1460     while inflight:
...
----> 7 for q in queries.queries:
      8     response = tavily.search(query=q, max_results=2)
      9     for r in response['results']:

AttributeError: 'NoneType' object has no attribute 'queries'
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

Somehow, the for loop is receiving an invalid queries object. You need to check your code and see how the queries object is being generated.
Keep learning!

1 Like

can you share screenshot of the error.

Also please confirm if you download all the files you got with the assignment codes.

Hi, I have added the full text of the error in the first message of this post

@Omer_Tzuk what about this? when I mention all the files, I meant check files==> open section where you will find other files with the assignment files.

also notice in the response code line under q loop, you mentioned query=q, where as for loop mentions q in queries.queries. So isn’t in the response it should be queries=q?? check the metadata how that query has been recalled in utils.py file

I have downloaded the helper.py file that is supplied with this assignment, but the error that I mention occurs in the block before the function from this file is called.