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

[Bug]: CitationQueryEngine init function #17896

Open
nbrosse opened this issue Feb 24, 2025 · 3 comments · May be fixed by #17897
Open

[Bug]: CitationQueryEngine init function #17896

nbrosse opened this issue Feb 24, 2025 · 3 comments · May be fixed by #17897
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized

Comments

@nbrosse
Copy link

nbrosse commented Feb 24, 2025

Bug Description

CitationQueryEngine init function is wrong and not coherent with from_args function.

Example:

query_engine = CitationQueryEngine(
    retriever=retriever,
)

query_engine = CitationQueryEngine.from_args(
    index=index,
    retriever=retriever,
)

The second one is working correctly, the first one does not work. This is due to

 self._response_synthesizer = response_synthesizer or get_response_synthesizer(
      llm=llm,
      callback_manager=callback_manager,
  )

inside init

Version

'0.12.19'

Steps to Reproduce

query_engine = CitationQueryEngine(
    retriever=retriever,
)

query_engine = CitationQueryEngine.from_args(
    index=index,
    retriever=retriever,
)

Relevant Logs/Tracbacks

@nbrosse nbrosse added bug Something isn't working triage Issue needs to be triaged/prioritized labels Feb 24, 2025
Copy link

dosubot bot commented Feb 24, 2025

Hey @nbrosse!

I'm here to help you with any bugs, questions, or contributions you have. Let's work together to resolve your issue.

The issue you're encountering seems to be related to the initialization of the CitationQueryEngine when using the __init__ method directly. The problem arises because the __init__ method requires a response_synthesizer or defaults to using get_response_synthesizer with the llm and callback_manager parameters. If these are not properly set or defaulted, it could lead to issues.

In contrast, the from_args method handles more parameters and defaults, including setting up the retriever from the index if not explicitly provided, which might be why it works correctly in your case.

To resolve the issue with the __init__ method, ensure that all necessary parameters, especially llm and callback_manager, are correctly provided or defaulted. Alternatively, using from_args is a more robust approach as it handles more configurations and defaults internally [1].

To continue talking to Dosu, mention @dosu.


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

@anoopshrma
Copy link
Collaborator

Can you share the traceback for first way

@nbrosse
Copy link
Author

nbrosse commented Feb 24, 2025

There is no apparent bug but the templates are wrong. They are not the CitationQueryEngine default templates but the RetrieverQueryEngine default ones.

query_engine = CitationQueryEngine(
    retriever=retriever,
)

prompts = query_engine.get_prompts()
for k, prompt in prompts.items():
    print(k)
    print(prompt.default_template.template)
    
response_synthesizer:text_qa_template
Context information is below.
---------------------
{context_str}
---------------------
Given the context information and not prior knowledge, answer the query.
Query: {query_str}
Answer: 
response_synthesizer:refine_template
The original query is as follows: {query_str}
We have provided an existing answer: {existing_answer}
We have the opportunity to refine the existing answer (only if needed) with some more context below.
------------
{context_msg}
------------
Given the new context, refine the original answer to better answer the query. If the context isn't useful, return the original answer.
Refined Answer: 

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

Successfully merging a pull request may close this issue.

2 participants