Better configuration (#79)

* Configurable Transport (#75)

* new functions to allow HTTPClient configuration

* updated go.mod for testing from remote

* updated go.mod for remote testing

* revert go.mod replace directives

* Fixed NewOrgClientWithTransport comment

* Make client fully configurable

* make empty messages limit configurable #70 #71

* make auth token private in config

* add docs

* lint

---------

Co-authored-by: Michael Fox <m.will.fox@gmail.com>
This commit is contained in:
sashabaranov
2023-02-21 00:16:44 +04:00
committed by GitHub
parent 133d2c9184
commit 1eb5d625f8
10 changed files with 89 additions and 53 deletions

View File

@@ -37,9 +37,15 @@ func TestCreateCompletionStream(t *testing.T) {
defer server.Close()
// Client portion of the test
client := NewClient(test.GetTestToken())
config := DefaultConfig(test.GetTestToken())
config.BaseURL = server.URL + "/v1"
config.HTTPClient.Transport = &tokenRoundTripper{
test.GetTestToken(),
http.DefaultTransport,
}
client := NewClientWithConfig(config)
ctx := context.Background()
client.BaseURL = server.URL + "/v1"
request := CompletionRequest{
Prompt: "Ex falso quodlibet",
@@ -48,11 +54,6 @@ func TestCreateCompletionStream(t *testing.T) {
Stream: true,
}
client.HTTPClient.Transport = &tokenRoundTripper{
test.GetTestToken(),
http.DefaultTransport,
}
stream, err := client.CreateCompletionStream(ctx, request)
if err != nil {
t.Errorf("CreateCompletionStream returned error: %v", err)