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

CompressingQueryTransformer NullPointException #1120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zxyyang
Copy link

@zxyyang zxyyang commented May 17, 2024

Visit CompressingQueryTransformer transform method to query. The metadata () when no memory context model of null pointer error
image

…data () when no memory context model of null pointer error
@zxyyang
Copy link
Author

zxyyang commented May 17, 2024

If you create the Assistant without specifying ChatMemoryProvider in the Build method but specifying retrievalAugmentor and then access it after the Assistant is built, you'll get a null pointer problem
(如果创建Assistant时候Build方法没有指定 ChatMemoryProvider 但是指定了retrievalAugmentor则在传入构建好后访问,会产出空指针问题)

@zxyyang
Copy link
Author

zxyyang commented May 20, 2024

@langchain4j

@langchain4j
Copy link
Owner

Hi @zxyyang, thank you, but what is the point of using CompressingQueryTransformer without ChatMemory?

@zxyyang
Copy link
Author

zxyyang commented May 21, 2024

Hi @zxyyang, thank you, but what is the point of using CompressingQueryTransformer without ChatMemory?

build AiServices use .retrievalAugmentor(retrievalAugmentor) but null .chatMemoryProvider(chatMemoryProvider) ,Use a embedding database but no memory context

@langchain4j
Copy link
Owner

@zxyyang I mean using CompressingQueryTransformer makes sense only when ChatMemory/chatMemoryProvider is present. Without the memory, there is nothing to compress...

@zxyyang
Copy link
Author

zxyyang commented May 21, 2024

CompressingQueryTransformer

My scenario is to use retrievalAugmentor but not set chatMemoryProvider automatically to call CompressingQueryTransformer and error ,

@langchain4j
Copy link
Owner

@zxyyang using CompressingQueryTransformer makes no sense without ChatMemory/chatMemoryProvider. What are you trying to achieve? Do you understand how CompressingQueryTransformer works? It takes all messages from chat memory (for this you need ChatMemory/chatMemoryProvider) and compresses them into a standalone query. If there is no memory, CompressingQueryTransformer will just waste time and tokens. It makes no sense.

@zxyyang
Copy link
Author

zxyyang commented May 21, 2024

@zxyyang using CompressingQueryTransformer makes no sense without ChatMemory/chatMemoryProvider. What are you trying to achieve? Do you understand how CompressingQueryTransformer works? It takes all messages from chat memory (for this you need ChatMemory/chatMemoryProvider) and compresses them into a standalone query. If there is no memory, CompressingQueryTransformer will just waste time and tokens. It makes no sense.

You mean that if I use embedding database I must have to configure the memory context store

@langchain4j
Copy link
Owner

You mean that if I use embedding database I must have to configure the memory context store

No, embedding store can be used without memory.
CompressingQueryTransformer is not needed to use embeding store/retreiver.
Hovewer, ChatMemory/chatMemoryProvider are needed to use CompressingQueryTransformer.

@zxyyang
Copy link
Author

zxyyang commented May 21, 2024

You mean that if I use embedding database I must have to configure the memory context store

No, embedding store can be used without memory. CompressingQueryTransformer is not needed to use embeding store/retreiver. Hovewer, ChatMemory/chatMemoryProvider are needed to use CompressingQueryTransformer.

    Assistant userMessageAssistant = AiServices.builder(Assistant.class)
      //       .chatMemoryProvider(chatMemoryProvider)
            .chatLanguageModel(OpenAiChatModel
                    .builder()
                    .logRequests(true)
                    .logResponses(true)
                    .modelName(apiConfig.getModel()) // 指定使用的模型名称
                    .apiKey(apiConfig.getKey()) // 设置API密钥
                    .maxTokens(apiConfig.getMaxToken()) // 最大令牌数
                    .maxRetries(apiConfig.getRetryTimes())
                    .baseUrl(StringUtils.isBlank(apiConfig.getBaseUrl()) ? null : apiConfig.getBaseUrl()) // 设置基础URL
                    .build())
            .tools(indicatorQueryTool)
            .retrievalAugmentor(retrievalAugmentor)
            .build();     This is my code If I use retrievalAugmentor will use CompressingQueryTransformer error he would himself, and because there is no context and error null pointer, If you had.chatMemoryProvider(chatMemoryProvider), it would work

@zxyyang
Copy link
Author

zxyyang commented May 29, 2024

You see is I use a problem or this code is not rigorous@ @langchain4j

@langchain4j langchain4j added the P3 Medium priority label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Medium priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants