langchain4j icon indicating copy to clipboard operation
langchain4j copied to clipboard

[FEATURE] Add withApiKey and withEndpoint shortcut methods to Azure models

Open agoncal opened this issue 2 years ago • 6 comments

Today all the models have Builders so you can build a valid model and then invoke it. Some models (MistralAiChatModel, NomicEmbeddingModel, OpenAiChatModel, etc.) also have shortcut methods allowing to set the minimum required attributes instead of using the builder:

// Using shortcut methods
ChatLanguageModel model = OpenAiChatModel.withApiKey(ApiKeys.OPENAI_API_KEY);

// Using the builder
ChatLanguageModel model = OpenAiChatModel.builder()
        .apiKey(ApiKeys.OPENAI_API_KEY))
        .modelName(GPT_4_VISION_PREVIEW)
        .maxTokens(50)
        .build();

It would be nice to have the same shortcuts (apiKey and endpoint) in the Azure models (AzureOpenAiChatModel, AzureOpenAiLanguageModel, AzureOpenAiStreamingLanguageModel, etc.)

AzureOpenAiChatModel model = AzureOpenAiChatModel.withApiKey(apiKey).withEndpoint(endpoint);

This way you can easily have an Azure model in one line.... and use the Builder if you need more control.

agoncal avatar Feb 08 '24 13:02 agoncal

As a developer who uses langchain4j, I would want the same shortcuts for all models.

SandraAhlgrimm avatar Feb 08 '24 13:02 SandraAhlgrimm

i wanna try this, pls assign me thanks.

yeshadoo avatar Feb 21 '24 07:02 yeshadoo

@yeshadoo go ahead, thanks!

langchain4j avatar Feb 21 '24 12:02 langchain4j

Hey @yeshadoo, any progress on that? Do you need any help?

agoncal avatar Mar 21 '24 03:03 agoncal

I apologize for being a bit busy recently, so I have to temporarily cancel the task assignment.

On Thu, Mar 21, 2024 at 11:55 AM Antonio Goncalves @.***> wrote:

Hey @yeshadoo https://github.com/yeshadoo, any progress on that? Do you need any help?

— Reply to this email directly, view it on GitHub https://github.com/langchain4j/langchain4j/issues/614#issuecomment-2011172737, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALKMGMBZGXDQBDEU2FMRLGTYZJKZRAVCNFSM6AAAAABC7W4TIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJRGE3TENZTG4 . You are receiving this because you were mentioned.Message ID: @.***>

yeshadoo avatar Mar 22 '24 01:03 yeshadoo

@yeshadoo No problem, that's fine. It happens to all of us. I'll take care of it.

@langchain4j can you assign this one to me please

agoncal avatar Mar 22 '24 05:03 agoncal