Find answers from the community

Updated 3 months ago

Hello, I'm getting a very strange error

Hello, I'm getting a very strange error, is anyone able to help me with this?
Plain Text
--> 193         selected_query_engine = self._query_engines[result.ind]
    194         log_str = f"Selecting query engine {result.ind}: {result.reason}."
    195         logger.info(log_str)

IndexError: list index out of range


Below is the code that is causing it

Plain Text
query_engine = RouterQueryEngine(
    selector=LLMSingleSelector.from_defaults(),
    query_engine_tools=[
        vector_tool,
    ],
    verbose=True
)

response = query_engine.query(
    '''<|begin_of_text|><|start_header_id|>user<|end_header_id|>

Which pa of brachial plexus do not give branches
...
Cord
Trunk

Respond with the correct choice from the list above verbatim.  Do not include any explanation.<|eot_id|><|start_header_id|>assistant<|end_header_id|><|begin_of_text|><|start_header_id|>user<|end_header_id|>

Which pa of brachial plexus do not give branches
...
Cord
Trunk

Respond with the correct choice from the list above verbatim.  Do not include any explanation.<|eot_id|><|start_header_id|>assistant<|end_header_id|>'''
)
print(str(response))
W
S
11 comments
It seems that your self._query_engines does not contain the element at the request index.
yeah but how is that possible? theres only one tool so why would it try to select an index other than 0?
ok I just found out the bug is even stranger, the error is dependent on the prompt
the following prompt causes no problem:

Plain Text
Which pa of brachial plexus do not give branches Cord Trunk

but if I simply add a new line in the prompt:

Plain Text
Which pa of brachial plexus do not give branches Cord
Trunk

it breaks and gives the error above
Yeah that what router query engine does, it basically routes your query based on the description that you provide for your engine.

If the llm assumes that this query does not fit for the description it moves to other tool.

But since you only have one tool it should check first whether the engine is present there or not before actaully accessing it
ok but I dont understand, even if it thinks the tool isnt fit for the description, shouldnt it pick that tool anyway?
because its the only tool
its provided with a list of tools so it knows its options are { 0 }, why would it then go and try 1 or something else?
Attachment
image.png
ok thanks let me try
ok i was having difficulty with the debugger, but i seemed to be able to get it to work by using just a regular query engine
Add a reply
Sign up and join the conversation on Discord