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

langchain4j example JlamaAiFunctionCallingExamples doesn't work with version 0.7 #95

Closed
arxx-opus opened this issue Oct 24, 2024 · 6 comments · Fixed by #105 or #124
Closed

langchain4j example JlamaAiFunctionCallingExamples doesn't work with version 0.7 #95

arxx-opus opened this issue Oct 24, 2024 · 6 comments · Fixed by #105 or #124

Comments

@arxx-opus
Copy link

arxx-opus commented Oct 24, 2024

Exception running langchain4j example JlamaAiFunctionCallingExamples with JLama version 0.7

Exception in thread "main" java.lang.ClassCastException: class [Lcom.github.tjake.jlama.safetensors.prompt.ToolCall; cannot be cast to class java.util.List ([Lcom.github.tjake.jlama.safetensors.prompt.ToolCall; is in unnamed module of loader 'app'; java.util.List is in module java.base of loader 'bootstrap')
    at com.github.tjake.jlama.model.AbstractModel.postProcessResponse(AbstractModel.java:597)
    at com.github.tjake.jlama.model.AbstractModel.generate(AbstractModel.java:557)
    at dev.langchain4j.model.jlama.JlamaChatModel.generate(JlamaChatModel.java:117)
    at dev.langchain4j.service.DefaultAiServices$1.invoke(DefaultAiServices.java:229)
    at $Proxy17.chat(Unknown Source)
    at JlamaAiFunctionCallingExamples$Payment_Data_From_AiServices.main(JlamaAiFunctionCallingExamples.java:60)

JsonSupport.om readValue() returns a Tool instead of List of Tool

List toolCallList = JsonSupport.om.readValue(jsonCall, ToolCall.toolCallListTypeReference);

@tjake tjake linked a pull request Nov 5, 2024 that will close this issue
@tjake tjake closed this as completed in #105 Nov 5, 2024
@gschrader
Copy link

This still fails with the same exception for me in version 0.8.2

@tjake
Copy link
Owner

tjake commented Nov 20, 2024

Are you using latest langchain4j?

@gschrader
Copy link

I've tried 0.36.0, I see there is a 0.36.1 now, I can try that as well

@tjake
Copy link
Owner

tjake commented Nov 20, 2024

If I want to reproduce I just rub the examples or are you using something g else?

@gschrader
Copy link

yes I've just copy/pasted the example, pretty sure my dependencies are ok.

The readValue call is returning an array not a List:

image

@gschrader
Copy link

gschrader commented Nov 20, 2024

This code would work:

            List<ToolCall> toolCallList = JsonSupport.om.readValue(jsonCall, new TypeReference<>() {});

@tjake tjake reopened this Nov 23, 2024
@tjake tjake linked a pull request Nov 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants