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

967 set useragent to lang chain4j #1046

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

roytruelove
Copy link

@roytruelove roytruelove commented Apr 30, 2024

Issue

Set User Agent to 'LangChain4J'

Change

Added the User Agent wherever it was accessible

General checklist

  • There are no breaking changes
  • I have added unit and integration tests for my change
  • I have manually run all the unit and integration tests in the module I have added/changed, and they are all green
  • I have manually run all the unit and integration tests in the core and main modules, and they are all green

Checklist for adding new model integration

  • [N/A] I have added my new module in the BOM

Checklist for adding new embedding store integration

  • [N/A] I have added a {NameOfIntegration}EmbeddingStoreIT that extends from either EmbeddingStoreIT or EmbeddingStoreWithFilteringIT
  • [N/A] I have added my new module in the BOM

Checklist for changing existing embedding store integration

  • [N/A] I have manually verified that the {NameOfIntegration}EmbeddingStore works correctly with the data persisted using the latest released version of LangChain4j

@roytruelove
Copy link
Author

A few questions for y'all

  1. I've cut and pasted the same code to (so far) 3 of the OkHttpClient. Continuing this way doesn't feel right but there's not a natural place (that I've found) where I could create a singleton Interceptor and/or a make a constant for the User Agent value. Maybe a util class in dev.langchain4j.core but that doesn't have OkHttp as a dependency.

It seems like there are several other tickets discussing HTTP client including getting rid of OkHttp3 as the default, so perhaps the cut and paste is fine for the time being before larger changes take place?

  1. There are no current tests for the classes I'm changing, so I'm wondering if as part of this change I'd need to create full coverage for all of the client classes?

@langchain4j
Copy link
Owner

Hi @roytruelove,

I've cut and pasted the same code to (so far) 3 of the OkHttpClient. Continuing this way doesn't feel right but there's not a natural place (that I've found) where I could create a singleton Interceptor and/or a make a constant for the User Agent value. Maybe a util class in dev.langchain4j.core but that doesn't have OkHttp as a dependency.
It seems like there are several other tickets discussing HTTP client including getting rid of OkHttp3 as the default, so perhaps the cut and paste is fine for the time being before larger changes take place?

Yes, I guess copy/paste is OK for now.

There are no current tests for the classes I'm changing, so I'm wondering if as part of this change I'd need to create full coverage for all of the client classes?

Ideally it would be nice to have a test. But if it takes too long, let's just test manually and see that existing tests are green.
If it is quick to do though, I would do it and copy/paste it everywhere.

@roytruelove
Copy link
Author

roytruelove commented May 2, 2024 via email

@roytruelove
Copy link
Author

Core code is complete, looking to see where I can add some tests

@langchain4j langchain4j added the P3 Medium priority label May 7, 2024
Copy link
Author

@roytruelove roytruelove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests for new methods. Unfortunately it is a bigger lift to test that the HTTP calls contain the correct user agent, without adding mocks / inject-able HTTP clients. Please let me know your thoughts on this.

Other than that the PR is ready for review.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modeled after InternalOpenAiHelper.

@@ -95,8 +96,11 @@ public VertexAiEmbeddingModel(String endpoint,
);

try {
// TODO switch to use InternalVertexAiHelper.defaultPredictionServiceSettingsBuilder() once the library
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly this uses a beta verson of PredictionServiceSettings so it could not use the new InternalVertexAiHelper class.

@roytruelove roytruelove marked this pull request as ready for review May 7, 2024 15:12
@roytruelove
Copy link
Author

Apologies - I marked this as "ready" when it should still be in draft..

@roytruelove roytruelove marked this pull request as draft May 28, 2024 08:12
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