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] IllegalException"text cannot be null" when using Qianfan Model #1110

Open
yao-wenbin opened this issue May 15, 2024 · 4 comments
Open
Assignees
Labels
bug Something isn't working P2 High priority

Comments

@yao-wenbin
Copy link

Describe the bug

when I using qianfan model, If api reach the limited, Model's generate() method will throw Illegal Exception instead of clear err response.

Log and Stack trace

Exception in thread "main" java.lang.IllegalArgumentException: text cannot be null
	at dev.langchain4j.internal.Exceptions.illegalArgument(Exceptions.java:19)
	at dev.langchain4j.internal.ValidationUtils.ensureNotNull(ValidationUtils.java:50)
	at dev.langchain4j.internal.ValidationUtils.ensureNotNull(ValidationUtils.java:37)
	at dev.langchain4j.data.message.AiMessage.<init>(AiMessage.java:30)
	at dev.langchain4j.data.message.AiMessage.from(AiMessage.java:116)
	at dev.langchain4j.data.message.AiMessage.aiMessage(AiMessage.java:146)
	at dev.langchain4j.model.qianfan.InternalQianfanHelper.aiMessageFrom(InternalQianfanHelper.java:162)
	at dev.langchain4j.model.qianfan.QianfanChatModel.generate(QianfanChatModel.java:131)
	at dev.langchain4j.model.qianfan.QianfanChatModel.generate(QianfanChatModel.java:95)
	at com.github.yaowenbin.functioncalling.GetWeatherExample.main(GetWeatherExample.java:32)

To Reproduce

Using qianfan model and provide a reached limit api key and then call model's generate().

    var model = QianfanChatModel.builder()
            .modelName("ERNIE-Bot")
            .apiKey(System.getenv("QIANFAN_API_KEY"))
            .secretKey(System.getenv("QIANFAN_SECRET_KEY"))
            .build();
        UserMessage userMessage = UserMessage.from("What is the square root of 475695037565?");
        Response<AiMessage> response = model.generate(Collections.singletonList(userMessage));

Expected behavior

If API reached limit, generate() method should throw a more clear exception instead of IllegalException: text cannot be null.

Please complete the following information:

  • LangChain4j version: 3.0.0
  • LLM(s) used: Qianfan
  • Java version: 17
  • Spring Boot version (if applicable):

Additional context

@yao-wenbin yao-wenbin added the bug Something isn't working label May 15, 2024
Copy link

dosubot bot commented May 15, 2024

Hey there, @yao-wenbin! 🎉 I'm Dosu, a bot here to help you solve bugs, answer questions, and even guide you on becoming a contributor. While we're waiting for a human maintainer to chime in, I'm here to assist you. Just wanted to let you know that I'm taking a look at your issue with the Qianfan Model and will provide you with a full answer shortly. Stay tuned!

@yao-wenbin
Copy link
Author

It's a debug in QianfanModel's generate() method image

@langchain4j langchain4j added the P2 High priority label May 15, 2024
@yao-wenbin
Copy link
Author

@langchain4j hi, could you assign me to this issue? I'll work on it today

@yao-wenbin
Copy link
Author

@langchain4j hello, I already create a pr for this issue, It my first time to contribute code to this repository.
Could you give me a code review or something other advices?I will appreciate that.
Thank you! has a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 High priority
Projects
None yet
Development

No branches or pull requests

2 participants