-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Alternative OpenAI Endpoint URL (#126)
* feat: Use a custom URL for OpenAI API endpoints * refactor OpenAI config * minimal tests --------- Co-authored-by: Drew Baumann <[email protected]>
- Loading branch information
1 parent
acc0312
commit 2f55d2c
Showing
6 changed files
with
92 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dev": { | ||
"host": "http://localhost:8000" | ||
} | ||
} |
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,57 @@ | ||
package llms | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/getzep/zep/config" | ||
"github.com/getzep/zep/pkg/llms/openairetryclient" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// Minimal set of test cases. We'd need to refactor the error states to not immediately | ||
// exit the program to test more thoroughly. | ||
|
||
// Test with a valid Azure configuration. | ||
func TestNewOpenAIRetryClient_ValidAzureConfig(t *testing.T) { | ||
cfg := &config.Config{ | ||
LLM: config.LLM{ | ||
OpenAIAPIKey: "testKey", | ||
AzureOpenAIEndpoint: "azureEndpoint", | ||
}, | ||
} | ||
|
||
client := NewOpenAIRetryClient(cfg) | ||
assert.IsType(t, &openairetryclient.OpenAIRetryClient{}, client) | ||
assert.IsType(t, time.Duration(0), client.Config.Timeout) | ||
assert.Equal(t, uint(5), client.Config.MaxAttempts) | ||
} | ||
|
||
// Test with a valid configuration. | ||
func TestNewOpenAIRetryClient_ValidConfig(t *testing.T) { | ||
cfg := &config.Config{ | ||
LLM: config.LLM{ | ||
OpenAIAPIKey: "testKey", | ||
}, | ||
} | ||
|
||
client := NewOpenAIRetryClient(cfg) | ||
assert.IsType(t, &openairetryclient.OpenAIRetryClient{}, client) | ||
assert.IsType(t, time.Duration(0), client.Config.Timeout) | ||
assert.Equal(t, uint(5), client.Config.MaxAttempts) | ||
} | ||
|
||
// Test with a valid configuration. | ||
func TestNewOpenAIRetryClient_ValidConfigCustomEndpoint(t *testing.T) { | ||
cfg := &config.Config{ | ||
LLM: config.LLM{ | ||
OpenAIAPIKey: "testKey", | ||
OpenAIEndpoint: "https://api.openai.com/v1", | ||
}, | ||
} | ||
|
||
client := NewOpenAIRetryClient(cfg) | ||
assert.IsType(t, &openairetryclient.OpenAIRetryClient{}, client) | ||
assert.IsType(t, time.Duration(0), client.Config.Timeout) | ||
assert.Equal(t, uint(5), client.Config.MaxAttempts) | ||
} |