Find answers from the community

Updated last year

No text

@Logan M Trying to update to 0.7.0 but "NO_TEXT" as response mode seems broken.
ValueError: Unknown mode: ResponseMode.NO_TEXT

Raised here
llama_index\response_synthesizers\factory.py", line 96, in get_response_synthesizer
raise ValueError(f"Unknown mode: {response_mode}")

Looks like that factory.py file does not take NO_TEXT into account ... it's not in the if/elif list ...

The quick fix I have so far is to create a NoText class, based on BaseSynthesizer that returns nothing:
Plain Text
from typing import Any, Sequence
from llama_index.response_synthesizers.base import BaseSynthesizer
from llama_index.types import RESPONSE_TEXT_TYPE

class NoText(BaseSynthesizer):
    def get_response(
        self,
        query_str: str,
        text_chunks: Sequence[str],
        **response_kwargs: Any,
    ) -> RESPONSE_TEXT_TYPE:
        return ""
        

    
    async def aget_response(
        self,
        query_str: str,
        text_chunks: Sequence[str],
        **response_kwargs: Any,
    ) -> RESPONSE_TEXT_TYPE:
        return ""

and of course modify factory.py so it handles NO_TEXT:
Plain Text
...
    elif response_mode == ResponseMode.NO_TEXT:
        return NoText(
            service_context=service_context,
            streaming=streaming,
        )
    else:
...      


I can do a PR if this "fix" is ok for you
L
t
8 comments
I think the preferred way of achieving this functionality is to use

Plain Text
retriever = index.as_retriever()

nodes = retriever.retrieve("query")
ok. Thanks.

But in that case, you still have several code examples that use index.as_query_engine() with response_mode="no_text" to fix.
Here
https://gpt-index.readthedocs.io/en/latest/search.html?q=no_text&check_keywords=yes&area=default#
and here
https://github.com/search?q=repo%3Ajerryjliu%2Fllama_index%20no_text&type=code

On the other hand, if it's not meant to work anymore with as_query_engine then maybe NO_TEXT should be removed from the enum ? Is it used anywhere else ?

IMHO, it would be best to keep it though and simply make as_query_engine work with no_text ... having this option might be interesting for debugging purposes for instance : you don't need to modify your code and use retrievers instead of query_engine (or vice versa), just set response_mode="no_text" ... and it's backward compatible with v0.6.x
yea that's fair. I ripped it out very recently because it was causing extra complexity in the way it was implemented (forgot the docs, whoops). If you feel it's useful, then definitely make the PR πŸ‘ πŸ™
I don't have a hard opinion on it haha
What is easier ? a quick PR or rewriting the docs and testing the jupyter notebooks ? πŸ˜„ πŸ˜‰
will PR asap
docs are the worst 🀣 PR away πŸ›³οΈ
ok the PR is here:
https://github.com/jerryjliu/llama_index/pull/6755

There is some lint error but it does not say what exactly and I sincerely can't see anything wrong in there πŸ˜… πŸ₯΄
Add a reply
Sign up and join the conversation on Discord