change azure engine config to modelMapper (#306)
* change azure engine config to azure modelMapper config * Update go.mod * Revert "Update go.mod" This reverts commit 78d14c58f2a9ce668da43f6adbe20b60afcfe0d7. * lint fix * add test * lint fix * lint fix * lint fix * opt * opt * opt * opt
This commit is contained in:
@@ -94,7 +94,7 @@ func TestRequestAuthHeader(t *testing.T) {
|
||||
az.OrgID = c.OrgID
|
||||
|
||||
cli := NewClientWithConfig(az)
|
||||
req, err := cli.newStreamRequest(context.Background(), "POST", "/chat/completions", nil)
|
||||
req, err := cli.newStreamRequest(context.Background(), "POST", "/chat/completions", nil, "")
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create request: %v", err)
|
||||
}
|
||||
@@ -109,14 +109,16 @@ func TestRequestAuthHeader(t *testing.T) {
|
||||
|
||||
func TestAzureFullURL(t *testing.T) {
|
||||
cases := []struct {
|
||||
Name string
|
||||
BaseURL string
|
||||
Engine string
|
||||
Expect string
|
||||
Name string
|
||||
BaseURL string
|
||||
AzureModelMapper map[string]string
|
||||
Model string
|
||||
Expect string
|
||||
}{
|
||||
{
|
||||
"AzureBaseURLWithSlashAutoStrip",
|
||||
"https://httpbin.org/",
|
||||
nil,
|
||||
"chatgpt-demo",
|
||||
"https://httpbin.org/" +
|
||||
"openai/deployments/chatgpt-demo" +
|
||||
@@ -125,6 +127,7 @@ func TestAzureFullURL(t *testing.T) {
|
||||
{
|
||||
"AzureBaseURLWithoutSlashOK",
|
||||
"https://httpbin.org",
|
||||
nil,
|
||||
"chatgpt-demo",
|
||||
"https://httpbin.org/" +
|
||||
"openai/deployments/chatgpt-demo" +
|
||||
@@ -134,10 +137,10 @@ func TestAzureFullURL(t *testing.T) {
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
az := DefaultAzureConfig("dummy", c.BaseURL, c.Engine)
|
||||
az := DefaultAzureConfig("dummy", c.BaseURL)
|
||||
cli := NewClientWithConfig(az)
|
||||
// /openai/deployments/{engine}/chat/completions?api-version={api_version}
|
||||
actual := cli.fullURL("/chat/completions")
|
||||
actual := cli.fullURL("/chat/completions", c.Model)
|
||||
if actual != c.Expect {
|
||||
t.Errorf("Expected %s, got %s", c.Expect, actual)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user