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

Fix #935: DefaultAiService compatibility for TokenUsage result is null #942

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Kugaaa
Copy link
Contributor

@Kugaaa Kugaaa commented Apr 16, 2024

Context

See #935
LocalAiChatModel.generate the response of generate returned that tokenUsage is null

Change

  • LocalAiChatModel tried to return TokenUsage result
  • TokenUsage.add return if origin token usage is null, ensure AiService proxy successfully executed

Checklist

Before submitting this PR, please check the following points:

  • I have added unit and integration tests for my change
  • All unit and integration tests in the module I have added/changed are green
  • All unit and integration tests in the core and main modules are green
  • I have added/updated the documentation
  • I have added an example in the examples repo (only for "big" features)
  • I have added my new module in the BOM (only when a new module is added)

Checklist for adding new embedding store integration

  • I have added a {NameOfIntegration}EmbeddingStoreIT that extends from either EmbeddingStoreIT or EmbeddingStoreWithFilteringIT

@langchain4j langchain4j added the P3 Medium priority label Apr 23, 2024
@langchain4j
Copy link
Owner

@Kugaaa thank you, but this has been fixed already by another PR: #939

@ohadpinch
Copy link

@Kugaaa @langchain4j Need to consider that fix, it worked for me

@langchain4j
Copy link
Owner

@ohadpinch you mean fix in this (closed) PR?

@ohadpinch
Copy link

Yes

@langchain4j langchain4j reopened this May 13, 2024
@langchain4j langchain4j added P2 High priority and removed P3 Medium priority labels May 13, 2024
@Kugaaa
Copy link
Contributor Author

Kugaaa commented May 13, 2024

I merged the origin/main
And this commit handle the OpenAi SDK return a Usage is null, a NPE may be thrown after the toolSpecifications generate.

pertinent code

  • dev/langchain4j/service/DefaultAiServices.java:128
  • dev/langchain4j/service/DefaultAiServices.java:172

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

Successfully merging this pull request may close these issues.

None yet

3 participants