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
Configure the OpenAI user-agent for LangChain4J #733
Configure the OpenAI user-agent for LangChain4J #733
Conversation
WalkthroughThe update introduces a new constant, Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to path filters (1)
langchain4j-parent/pom.xml
is excluded by:!**/*.xml
Files selected for processing (8)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/InternalOpenAiHelper.java (1 hunks)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiChatModel.java (1 hunks)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiEmbeddingModel.java (1 hunks)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiImageModel.java (2 hunks)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiLanguageModel.java (1 hunks)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiModerationModel.java (1 hunks)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiStreamingChatModel.java (1 hunks)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiStreamingLanguageModel.java (2 hunks)
Additional comments: 8
langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiLanguageModel.java (1)
- 63-63: Setting the
DEFAULT_USER_AGENT
in theOpenAiClient
builder is a good practice for identifying the source of API requests. This change aligns with the PR's objective to enhance visibility to Azure OpenAI and OpenAI. Ensure that theDEFAULT_USER_AGENT
value accurately represents the LangChain4J project and adheres to any user-agent formatting guidelines provided by OpenAI.langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiModerationModel.java (1)
- 65-65: Setting the
DEFAULT_USER_AGENT
in theOpenAiClient
builder within theOpenAiModerationModel
constructor is consistent with the PR's goal. This ensures that moderation requests from LangChain4J are properly identified by OpenAI. Good implementation.langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiEmbeddingModel.java (1)
- 71-71: The addition of the
DEFAULT_USER_AGENT
in theOpenAiEmbeddingModel
constructor is in line with the PR's objectives. This ensures that embedding model requests are identifiable as coming from LangChain4J. This is a positive change for visibility and tracking purposes.langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiStreamingLanguageModel.java (1)
- 62-62: The inclusion of
DEFAULT_USER_AGENT
in theOpenAiStreamingLanguageModel
constructor ensures that streaming language model requests can be traced back to LangChain4J. This aligns with the PR's aim to enhance project visibility to OpenAI services.langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiImageModel.java (1)
- 89-89: Incorporating the
DEFAULT_USER_AGENT
in theOpenAiImageModel
constructor is a strategic move to ensure that image model requests from LangChain4J are identifiable by OpenAI. This change supports the PR's goal of improving visibility and is implemented correctly.langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiChatModel.java (1)
- 90-90: The addition of
DEFAULT_USER_AGENT
to theOpenAiChatModel
constructor is a crucial step towards achieving the PR's objectives of enhancing LangChain4J's visibility to OpenAI. This ensures that chat model requests are properly identified, which is beneficial for tracking and optimization.langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/OpenAiStreamingChatModel.java (1)
- 87-87: The implementation of
DEFAULT_USER_AGENT
in theOpenAiStreamingChatModel
constructor aligns with the PR's goal of enhancing the visibility of LangChain4J to OpenAI. This ensures that streaming chat model requests are identifiable, which is a positive change for tracking and visibility.langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/InternalOpenAiHelper.java (1)
- 37-37: The introduction of the
DEFAULT_USER_AGENT
constant in theInternalOpenAiHelper
class is a key part of this PR, providing a centralized way to set the user-agent for all OpenAI API requests made by LangChain4J. This is a well-thought-out addition that supports the PR's objectives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/InternalOpenAiHelper.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- langchain4j-open-ai/src/main/java/dev/langchain4j/model/openai/InternalOpenAiHelper.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdubois thanks!
This will give visibility to the LangChain4J project to Azure OpenAI and OpenAI.
WARNING I had to update OpenAI4j version to 0.15 and I don't know about the other impacts of this upgrade.
Summary by CodeRabbit