forked from sashabaranov/go-openai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change azure engine config to modelMapper (sashabaranov#306)
* change azure engine config to azure modelMapper config * Update go.mod * Revert "Update go.mod" This reverts commit 78d14c5. * lint fix * add test * lint fix * lint fix * lint fix * opt * opt * opt * opt
- Loading branch information
1 parent
5f4ff3e
commit be253c2
Showing
14 changed files
with
119 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package openai_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/sashabaranov/go-openai" | ||
) | ||
|
||
func TestGetAzureDeploymentByModel(t *testing.T) { | ||
cases := []struct { | ||
Model string | ||
AzureModelMapperFunc func(model string) string | ||
Expect string | ||
}{ | ||
{ | ||
Model: "gpt-3.5-turbo", | ||
Expect: "gpt-35-turbo", | ||
}, | ||
{ | ||
Model: "gpt-3.5-turbo-0301", | ||
Expect: "gpt-35-turbo-0301", | ||
}, | ||
{ | ||
Model: "text-embedding-ada-002", | ||
Expect: "text-embedding-ada-002", | ||
}, | ||
{ | ||
Model: "", | ||
Expect: "", | ||
}, | ||
{ | ||
Model: "models", | ||
Expect: "models", | ||
}, | ||
{ | ||
Model: "gpt-3.5-turbo", | ||
Expect: "my-gpt35", | ||
AzureModelMapperFunc: func(model string) string { | ||
modelmapper := map[string]string{ | ||
"gpt-3.5-turbo": "my-gpt35", | ||
} | ||
if val, ok := modelmapper[model]; ok { | ||
return val | ||
} | ||
return model | ||
}, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
t.Run(c.Model, func(t *testing.T) { | ||
conf := DefaultAzureConfig("", "https://test.openai.azure.com/") | ||
if c.AzureModelMapperFunc != nil { | ||
conf.AzureModelMapperFunc = c.AzureModelMapperFunc | ||
} | ||
actual := conf.GetAzureDeploymentByModel(c.Model) | ||
if actual != c.Expect { | ||
t.Errorf("Expected %s, got %s", c.Expect, actual) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters