From 1f79d2b328aab6724ac0ce4effaaec72d6242970 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 10 Dec 2024 10:56:36 +0100 Subject: [PATCH] Pass through correct model name for Azure AI Also, fix error reporting to not complain about deleteErr when there is no deleteErr. --- llm/openai.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llm/openai.go b/llm/openai.go index 2ae31d5..a82382d 100644 --- a/llm/openai.go +++ b/llm/openai.go @@ -21,11 +21,10 @@ import ( func NewOpenAIProvider(apiKey string, azureBaseURL string, model, azureModelName string, name string, jsonMode bool) *openAIProvider { var cfg openai.ClientConfig if azureBaseURL != "" { + // override model choice with what we get from the configuration + model = azureModelName cfg = openai.DefaultAzureConfig(apiKey, azureBaseURL) cfg.APIVersion = "2024-05-01-preview" - cfg.AzureModelMapperFunc = func(m string) string { - return azureModelName - } } else { cfg = openai.DefaultConfig(apiKey) } @@ -150,8 +149,10 @@ func (c *openAIConversation) SendMessage(ctx context.Context, userMessage string err := fmt.Errorf("failed to append message: %w", err) // Delete the last message so we don't end up with duplicates _, deleteErr := c.client.DeleteMessage(ctx, c.thread.ID, message.ID) - deleteErr = fmt.Errorf("failed to delete message: %w", deleteErr) - err = errors.Join(err, deleteErr) + if deleteErr != nil { + deleteErr = fmt.Errorf("failed to delete message: %w", deleteErr) + err = errors.Join(err, deleteErr) + } return err })