diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 536a2ee29..384110c51 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,7 +8,7 @@ assignees: '' --- Your issue may already be reported! -Please search on the [issue tracker](https://github.com/sashabaranov/go-openai/issues) before creating one. +Please search on the [issue tracker](https://github.com/openshieldai/go-openai/issues) before creating one. **Describe the bug** A clear and concise description of what the bug is. If it's an API-related bug, please provide relevant endpoint(s). diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 2359e5c00..40cbedc78 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -8,7 +8,7 @@ assignees: '' --- Your issue may already be reported! -Please search on the [issue tracker](https://github.com/sashabaranov/go-openai/issues) before creating one. +Please search on the [issue tracker](https://github.com/openshieldai/go-openai/issues) before creating one. **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 222c065ce..4e1b55c76 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,5 @@ A similar PR may already be submitted! -Please search among the [Pull request](https://github.com/sashabaranov/go-openai/pulls) before creating one. +Please search among the [Pull request](https://github.com/openshieldai/go-openai/pulls) before creating one. If your changes introduce breaking changes, please prefix the title of your pull request with "[BREAKING_CHANGES]". This allows for clear identification of such changes in the 'What's Changed' section on the release page, making it developer-friendly. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4dd184042..588c058c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,22 +1,22 @@ # Contributing Guidelines ## Overview -Thank you for your interest in contributing to the "Go OpenAI" project! By following this guideline, we hope to ensure that your contributions are made smoothly and efficiently. The Go OpenAI project is licensed under the [Apache 2.0 License](https://github.com/sashabaranov/go-openai/blob/master/LICENSE), and we welcome contributions through GitHub pull requests. +Thank you for your interest in contributing to the "Go OpenAI" project! By following this guideline, we hope to ensure that your contributions are made smoothly and efficiently. The Go OpenAI project is licensed under the [Apache 2.0 License](https://github.com/openshieldai/go-openai/blob/master/LICENSE), and we welcome contributions through GitHub pull requests. ## Reporting Bugs -If you discover a bug, first check the [GitHub Issues page](https://github.com/sashabaranov/go-openai/issues) to see if the issue has already been reported. If you're reporting a new issue, please use the "Bug report" template and provide detailed information about the problem, including steps to reproduce it. +If you discover a bug, first check the [GitHub Issues page](https://github.com/openshieldai/go-openai/issues) to see if the issue has already been reported. If you're reporting a new issue, please use the "Bug report" template and provide detailed information about the problem, including steps to reproduce it. ## Suggesting Features -If you want to suggest a new feature or improvement, first check the [GitHub Issues page](https://github.com/sashabaranov/go-openai/issues) to ensure a similar suggestion hasn't already been made. Use the "Feature request" template to provide a detailed description of your suggestion. +If you want to suggest a new feature or improvement, first check the [GitHub Issues page](https://github.com/openshieldai/go-openai/issues) to ensure a similar suggestion hasn't already been made. Use the "Feature request" template to provide a detailed description of your suggestion. ## Reporting Vulnerabilities -If you identify a security concern, please use the "Report a security vulnerability" template on the [GitHub Issues page](https://github.com/sashabaranov/go-openai/issues) to share the details. This report will only be viewable to repository maintainers. You will be credited if the advisory is published. +If you identify a security concern, please use the "Report a security vulnerability" template on the [GitHub Issues page](https://github.com/openshieldai/go-openai/issues) to share the details. This report will only be viewable to repository maintainers. You will be credited if the advisory is published. ## Questions for Users -If you have questions, please utilize [StackOverflow](https://stackoverflow.com/) or the [GitHub Discussions page](https://github.com/sashabaranov/go-openai/discussions). +If you have questions, please utilize [StackOverflow](https://stackoverflow.com/) or the [GitHub Discussions page](https://github.com/openshieldai/go-openai/discussions). ## Contributing Code -There might already be a similar pull requests submitted! Please search for [pull requests](https://github.com/sashabaranov/go-openai/pulls) before creating one. +There might already be a similar pull requests submitted! Please search for [pull requests](https://github.com/openshieldai/go-openai/pulls) before creating one. ### Requirements for Merging a Pull Request diff --git a/README.md b/README.md index b3ebc1471..6cbbc2269 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Go OpenAI -[![Go Reference](https://pkg.go.dev/badge/github.com/sashabaranov/go-openai.svg)](https://pkg.go.dev/github.com/sashabaranov/go-openai) -[![Go Report Card](https://goreportcard.com/badge/github.com/sashabaranov/go-openai)](https://goreportcard.com/report/github.com/sashabaranov/go-openai) +[![Go Reference](https://pkg.go.dev/badge/github.com/openshieldai/go-openai.svg)](https://pkg.go.dev/github.com/openshieldai/go-openai) +[![Go Report Card](https://goreportcard.com/badge/github.com/openshieldai/go-openai)](https://goreportcard.com/report/github.com/openshieldai/go-openai) [![codecov](https://codecov.io/gh/sashabaranov/go-openai/branch/master/graph/badge.svg?token=bCbIfHLIsW)](https://codecov.io/gh/sashabaranov/go-openai) This library provides unofficial Go clients for [OpenAI API](https://platform.openai.com/). We support: @@ -13,7 +13,7 @@ This library provides unofficial Go clients for [OpenAI API](https://platform.op ## Installation ``` -go get github.com/sashabaranov/go-openai +go get github.com/openshieldai/go-openai ``` Currently, go-openai requires Go version 1.18 or greater. @@ -28,7 +28,7 @@ package main import ( "context" "fmt" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) func main() { @@ -80,7 +80,7 @@ import ( "errors" "fmt" "io" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) func main() { @@ -133,7 +133,7 @@ package main import ( "context" "fmt" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) func main() { @@ -166,7 +166,7 @@ import ( "context" "fmt" "io" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) func main() { @@ -215,7 +215,7 @@ import ( "context" "fmt" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) func main() { @@ -247,7 +247,7 @@ import ( "fmt" "os" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) func main() { @@ -288,7 +288,7 @@ import ( "context" "encoding/base64" "fmt" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" "image/png" "os" ) @@ -376,7 +376,7 @@ config.HTTPClient = &http.Client{ c := openai.NewClientWithConfig(config) ``` -See also: https://pkg.go.dev/github.com/sashabaranov/go-openai#ClientConfig +See also: https://pkg.go.dev/github.com/openshieldai/go-openai#ClientConfig
@@ -392,7 +392,7 @@ import ( "os" "strings" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func main() { @@ -446,7 +446,7 @@ import ( "context" "fmt" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) func main() { @@ -492,7 +492,7 @@ package main import ( "context" "log" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) @@ -549,7 +549,7 @@ import ( "context" "fmt" - openai "github.com/sashabaranov/go-openai" + openai "github.com/openshieldai/go-openai" ) func main() { @@ -680,7 +680,7 @@ package main import ( "context" "fmt" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func main() { @@ -755,8 +755,8 @@ import ( "fmt" "log" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/jsonschema" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/jsonschema" ) func main() { @@ -828,7 +828,7 @@ Due to the factors mentioned above, different answers may be returned even for t By adopting these strategies, you can expect more consistent results. **Related Issues:** -[omitempty option of request struct will generate incorrect request when parameter is 0.](https://github.com/sashabaranov/go-openai/issues/9) +[omitempty option of request struct will generate incorrect request when parameter is 0.](https://github.com/openshieldai/go-openai/issues/9) ### Does Go OpenAI provide a method to count tokens? @@ -839,15 +839,15 @@ For counting tokens, you might find the following links helpful: - [How to count tokens with tiktoken](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) **Related Issues:** -[Is it possible to join the implementation of GPT3 Tokenizer](https://github.com/sashabaranov/go-openai/issues/62) +[Is it possible to join the implementation of GPT3 Tokenizer](https://github.com/openshieldai/go-openai/issues/62) ## Contributing -By following [Contributing Guidelines](https://github.com/sashabaranov/go-openai/blob/master/CONTRIBUTING.md), we hope to ensure that your contributions are made smoothly and efficiently. +By following [Contributing Guidelines](https://github.com/openshieldai/go-openai/blob/master/CONTRIBUTING.md), we hope to ensure that your contributions are made smoothly and efficiently. ## Thank you -We want to take a moment to express our deepest gratitude to the [contributors](https://github.com/sashabaranov/go-openai/graphs/contributors) and sponsors of this project: +We want to take a moment to express our deepest gratitude to the [contributors](https://github.com/openshieldai/go-openai/graphs/contributors) and sponsors of this project: - [Carson Kahn](https://carsonkahn.com) of [Spindle AI](https://spindleai.com) To all of you: thank you. You've helped us achieve more than we ever imagined possible. Can't wait to see where we go next, together! diff --git a/api_integration_test.go b/api_integration_test.go index 7828d9451..e3c456210 100644 --- a/api_integration_test.go +++ b/api_integration_test.go @@ -10,9 +10,9 @@ import ( "os" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" - "github.com/sashabaranov/go-openai/jsonschema" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai/jsonschema" ) func TestAPI(t *testing.T) { diff --git a/assistant_test.go b/assistant_test.go index 40de0e50f..09b519bd3 100644 --- a/assistant_test.go +++ b/assistant_test.go @@ -3,8 +3,8 @@ package openai_test import ( "context" - openai "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + openai "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" "encoding/json" "fmt" diff --git a/audio.go b/audio.go index f321f93d6..7da3a47c0 100644 --- a/audio.go +++ b/audio.go @@ -8,7 +8,7 @@ import ( "net/http" "os" - utils "github.com/sashabaranov/go-openai/internal" + utils "github.com/openshieldai/go-openai/internal" ) // Whisper Defines the models provided by OpenAI to use when processing audio with OpenAI. diff --git a/audio_api_test.go b/audio_api_test.go index c24598443..c202a309d 100644 --- a/audio_api_test.go +++ b/audio_api_test.go @@ -12,9 +12,9 @@ import ( "strings" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test" + "github.com/openshieldai/go-openai/internal/test/checks" ) // TestAudio Tests the transcription and translation endpoints of the API using the mocked server. diff --git a/audio_test.go b/audio_test.go index 235931f36..ab60433c9 100644 --- a/audio_test.go +++ b/audio_test.go @@ -8,8 +8,8 @@ import ( "path/filepath" "testing" - "github.com/sashabaranov/go-openai/internal/test" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai/internal/test" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestAudioWithFailingFormBuilder(t *testing.T) { diff --git a/batch_test.go b/batch_test.go index 4b2261e0e..65ee60d24 100644 --- a/batch_test.go +++ b/batch_test.go @@ -7,8 +7,8 @@ import ( "reflect" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestUploadBatchFile(t *testing.T) { diff --git a/chat_stream_test.go b/chat_stream_test.go index 63e45ee23..75c8f3bdb 100644 --- a/chat_stream_test.go +++ b/chat_stream_test.go @@ -10,8 +10,8 @@ import ( "strconv" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestChatCompletionsStreamWrongModel(t *testing.T) { diff --git a/chat_test.go b/chat_test.go index 37dc09d4d..1720bf156 100644 --- a/chat_test.go +++ b/chat_test.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" - "github.com/sashabaranov/go-openai/jsonschema" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai/jsonschema" ) const ( diff --git a/client.go b/client.go index 9f547e7cb..c2d7c2497 100644 --- a/client.go +++ b/client.go @@ -10,7 +10,7 @@ import ( "net/url" "strings" - utils "github.com/sashabaranov/go-openai/internal" + utils "github.com/openshieldai/go-openai/internal" ) // Client is OpenAI GPT-3 API client. diff --git a/client_test.go b/client_test.go index 7119d8a7e..80528c7f7 100644 --- a/client_test.go +++ b/client_test.go @@ -10,8 +10,8 @@ import ( "reflect" "testing" - "github.com/sashabaranov/go-openai/internal/test" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai/internal/test" + "github.com/openshieldai/go-openai/internal/test/checks" ) var errTestRequestBuilderFailed = errors.New("test request builder failed") diff --git a/completion_test.go b/completion_test.go index 89950bf94..db275cd69 100644 --- a/completion_test.go +++ b/completion_test.go @@ -12,8 +12,8 @@ import ( "testing" "time" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestCompletionsWrongModel(t *testing.T) { diff --git a/config_test.go b/config_test.go index 3e528c3e9..0108cab84 100644 --- a/config_test.go +++ b/config_test.go @@ -3,7 +3,7 @@ package openai_test import ( "testing" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func TestGetAzureDeploymentByModel(t *testing.T) { diff --git a/edits_test.go b/edits_test.go index d2a6db40d..fcf5b1fcd 100644 --- a/edits_test.go +++ b/edits_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) // TestEdits Tests the edits endpoint of the API using the mocked server. diff --git a/embeddings_test.go b/embeddings_test.go index 438978169..f48c99851 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -11,8 +11,8 @@ import ( "reflect" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestEmbedding(t *testing.T) { diff --git a/engines_test.go b/engines_test.go index d26aa5541..fbcca58da 100644 --- a/engines_test.go +++ b/engines_test.go @@ -7,8 +7,8 @@ import ( "net/http" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) // TestGetEngine Tests the retrieve engine endpoint of the API using the mocked server. diff --git a/error.go b/error.go index 37959a272..1f181b760 100644 --- a/error.go +++ b/error.go @@ -51,7 +51,7 @@ func (e *APIError) UnmarshalJSON(data []byte) (err error) { err = json.Unmarshal(rawMap["message"], &e.Message) if err != nil { // If the parameter field of a function call is invalid as a JSON schema - // refs: https://github.com/sashabaranov/go-openai/issues/381 + // refs: https://github.com/openshieldai/go-openai/issues/381 var messages []string err = json.Unmarshal(rawMap["message"], &messages) if err != nil { @@ -61,7 +61,7 @@ func (e *APIError) UnmarshalJSON(data []byte) (err error) { } // optional fields for azure openai - // refs: https://github.com/sashabaranov/go-openai/issues/343 + // refs: https://github.com/openshieldai/go-openai/issues/343 if _, ok := rawMap["type"]; ok { err = json.Unmarshal(rawMap["type"], &e.Type) if err != nil { diff --git a/error_test.go b/error_test.go index 48cbe4f29..05c09fd0a 100644 --- a/error_test.go +++ b/error_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func TestAPIErrorUnmarshalJSON(t *testing.T) { diff --git a/example_test.go b/example_test.go index 5910ffb84..2a98678d9 100644 --- a/example_test.go +++ b/example_test.go @@ -11,7 +11,7 @@ import ( "net/url" "os" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func Example() { diff --git a/examples/chatbot/main.go b/examples/chatbot/main.go index ad41e957d..7eead20f6 100644 --- a/examples/chatbot/main.go +++ b/examples/chatbot/main.go @@ -6,7 +6,7 @@ import ( "fmt" "os" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func main() { diff --git a/examples/completion-with-tool/main.go b/examples/completion-with-tool/main.go index 26126e41b..df4930693 100644 --- a/examples/completion-with-tool/main.go +++ b/examples/completion-with-tool/main.go @@ -5,8 +5,8 @@ import ( "fmt" "os" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/jsonschema" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/jsonschema" ) func main() { diff --git a/examples/completion/main.go b/examples/completion/main.go index 8c5cbd5ca..c83df14be 100644 --- a/examples/completion/main.go +++ b/examples/completion/main.go @@ -5,7 +5,7 @@ import ( "fmt" "os" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func main() { diff --git a/examples/images/main.go b/examples/images/main.go index 5ee649d22..09c578493 100644 --- a/examples/images/main.go +++ b/examples/images/main.go @@ -5,7 +5,7 @@ import ( "fmt" "os" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func main() { diff --git a/examples/voice-to-text/main.go b/examples/voice-to-text/main.go index 713e748e1..674af9480 100644 --- a/examples/voice-to-text/main.go +++ b/examples/voice-to-text/main.go @@ -6,7 +6,7 @@ import ( "fmt" "os" - "github.com/sashabaranov/go-openai" + "github.com/openshieldai/go-openai" ) func main() { diff --git a/files_api_test.go b/files_api_test.go index c92162a84..c560b3485 100644 --- a/files_api_test.go +++ b/files_api_test.go @@ -12,8 +12,8 @@ import ( "testing" "time" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestFileBytesUpload(t *testing.T) { diff --git a/files_test.go b/files_test.go index 3c1b99fb4..ebdb38c95 100644 --- a/files_test.go +++ b/files_test.go @@ -7,8 +7,8 @@ import ( "os" "testing" - utils "github.com/sashabaranov/go-openai/internal" - "github.com/sashabaranov/go-openai/internal/test/checks" + utils "github.com/openshieldai/go-openai/internal" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestFileBytesUploadWithFailingFormBuilder(t *testing.T) { diff --git a/fine_tunes_test.go b/fine_tunes_test.go index 2ab6817f7..5af083ee3 100644 --- a/fine_tunes_test.go +++ b/fine_tunes_test.go @@ -7,8 +7,8 @@ import ( "net/http" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) const testFineTuneID = "fine-tune-id" diff --git a/fine_tuning_job_test.go b/fine_tuning_job_test.go index 5f63ef24c..754bdde99 100644 --- a/fine_tuning_job_test.go +++ b/fine_tuning_job_test.go @@ -7,8 +7,8 @@ import ( "net/http" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) const testFineTuninigJobID = "fine-tuning-job-id" diff --git a/go.mod b/go.mod index 42cc7b391..67c7e94b4 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/sashabaranov/go-openai +module github.com/openshieldai/go-openai go 1.18 diff --git a/image_api_test.go b/image_api_test.go index 48416b1e2..aa4372069 100644 --- a/image_api_test.go +++ b/image_api_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestImages(t *testing.T) { diff --git a/image_test.go b/image_test.go index 9332dd5cd..ffbc61b80 100644 --- a/image_test.go +++ b/image_test.go @@ -1,8 +1,8 @@ package openai //nolint:testpackage // testing private field import ( - utils "github.com/sashabaranov/go-openai/internal" - "github.com/sashabaranov/go-openai/internal/test/checks" + utils "github.com/openshieldai/go-openai/internal" + "github.com/openshieldai/go-openai/internal/test/checks" "context" "fmt" diff --git a/internal/error_accumulator_test.go b/internal/error_accumulator_test.go index d48f28177..93efd4e98 100644 --- a/internal/error_accumulator_test.go +++ b/internal/error_accumulator_test.go @@ -5,8 +5,8 @@ import ( "errors" "testing" - utils "github.com/sashabaranov/go-openai/internal" - "github.com/sashabaranov/go-openai/internal/test" + utils "github.com/openshieldai/go-openai/internal" + "github.com/openshieldai/go-openai/internal/test" ) func TestErrorAccumulatorBytes(t *testing.T) { diff --git a/internal/form_builder_test.go b/internal/form_builder_test.go index d3faf9982..181b4bdfc 100644 --- a/internal/form_builder_test.go +++ b/internal/form_builder_test.go @@ -1,8 +1,8 @@ package openai //nolint:testpackage // testing private field import ( - "github.com/sashabaranov/go-openai/internal/test" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai/internal/test" + "github.com/openshieldai/go-openai/internal/test/checks" "bytes" "errors" diff --git a/internal/test/helpers.go b/internal/test/helpers.go index 0e63ae82f..0b1aa0214 100644 --- a/internal/test/helpers.go +++ b/internal/test/helpers.go @@ -1,7 +1,7 @@ package test import ( - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai/internal/test/checks" "net/http" "os" diff --git a/jsonschema/json_test.go b/jsonschema/json_test.go index 744706082..5101db218 100644 --- a/jsonschema/json_test.go +++ b/jsonschema/json_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/sashabaranov/go-openai/jsonschema" + "github.com/openshieldai/go-openai/jsonschema" ) func TestDefinition_MarshalJSON(t *testing.T) { diff --git a/jsonschema/validate_test.go b/jsonschema/validate_test.go index c2c47a2ce..87059f1a5 100644 --- a/jsonschema/validate_test.go +++ b/jsonschema/validate_test.go @@ -3,7 +3,7 @@ package jsonschema_test import ( "testing" - "github.com/sashabaranov/go-openai/jsonschema" + "github.com/openshieldai/go-openai/jsonschema" ) func Test_Validate(t *testing.T) { diff --git a/messages_test.go b/messages_test.go index 71ceb4d3a..b5c09da34 100644 --- a/messages_test.go +++ b/messages_test.go @@ -7,9 +7,9 @@ import ( "net/http" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test" + "github.com/openshieldai/go-openai/internal/test/checks" ) var emptyStr = "" diff --git a/models_test.go b/models_test.go index 24a28ed23..00066722e 100644 --- a/models_test.go +++ b/models_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) const testFineTuneModelID = "fine-tune-model-id" diff --git a/moderation_test.go b/moderation_test.go index 61171c384..8adf22325 100644 --- a/moderation_test.go +++ b/moderation_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) // TestModeration Tests the moderations endpoint of the API using the mocked server. diff --git a/openai_test.go b/openai_test.go index 729d8880c..608e9b61c 100644 --- a/openai_test.go +++ b/openai_test.go @@ -1,8 +1,8 @@ package openai_test import ( - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test" ) func setupOpenAITestServer() (client *openai.Client, server *test.ServerTest, teardown func()) { diff --git a/run.go b/run.go index 5598f1dfb..b2c4fc634 100644 --- a/run.go +++ b/run.go @@ -28,16 +28,6 @@ type Run struct { Metadata map[string]any `json:"metadata"` Usage Usage `json:"usage,omitempty"` - Temperature *float32 `json:"temperature,omitempty"` - // The maximum number of prompt tokens that may be used over the course of the run. - // If the run exceeds the number of prompt tokens specified, the run will end with status 'incomplete'. - MaxPromptTokens int `json:"max_prompt_tokens,omitempty"` - // The maximum number of completion tokens that may be used over the course of the run. - // If the run exceeds the number of completion tokens specified, the run will end with status 'incomplete'. - MaxCompletionTokens int `json:"max_completion_tokens,omitempty"` - // ThreadTruncationStrategy defines the truncation strategy to use for the thread. - TruncationStrategy *ThreadTruncationStrategy `json:"truncation_strategy,omitempty"` - httpHeader } @@ -50,7 +40,6 @@ const ( RunStatusCancelling RunStatus = "cancelling" RunStatusFailed RunStatus = "failed" RunStatusCompleted RunStatus = "completed" - RunStatusIncomplete RunStatus = "incomplete" RunStatusExpired RunStatus = "expired" RunStatusCancelled RunStatus = "cancelled" ) @@ -89,53 +78,7 @@ type RunRequest struct { AdditionalInstructions string `json:"additional_instructions,omitempty"` Tools []Tool `json:"tools,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` - - // Sampling temperature between 0 and 2. Higher values like 0.8 are more random. - // lower values are more focused and deterministic. - Temperature *float32 `json:"temperature,omitempty"` - TopP *float32 `json:"top_p,omitempty"` - - // The maximum number of prompt tokens that may be used over the course of the run. - // If the run exceeds the number of prompt tokens specified, the run will end with status 'incomplete'. - MaxPromptTokens int `json:"max_prompt_tokens,omitempty"` - - // The maximum number of completion tokens that may be used over the course of the run. - // If the run exceeds the number of completion tokens specified, the run will end with status 'incomplete'. - MaxCompletionTokens int `json:"max_completion_tokens,omitempty"` - - // ThreadTruncationStrategy defines the truncation strategy to use for the thread. - TruncationStrategy *ThreadTruncationStrategy `json:"truncation_strategy,omitempty"` - - // This can be either a string or a ToolChoice object. - ToolChoice any `json:"tool_choice,omitempty"` - // This can be either a string or a ResponseFormat object. - ResponseFormat any `json:"response_format,omitempty"` -} - -// ThreadTruncationStrategy defines the truncation strategy to use for the thread. -// https://platform.openai.com/docs/assistants/how-it-works/truncation-strategy. -type ThreadTruncationStrategy struct { - // default 'auto'. - Type TruncationStrategy `json:"type,omitempty"` - // this field should be set if the truncation strategy is set to LastMessages. - LastMessages *int `json:"last_messages,omitempty"` -} - -// TruncationStrategy defines the existing truncation strategies existing for thread management in an assistant. -type TruncationStrategy string - -const ( - // TruncationStrategyAuto messages in the middle of the thread will be dropped to fit the context length of the model. - TruncationStrategyAuto = TruncationStrategy("auto") - // TruncationStrategyLastMessages the thread will be truncated to the n most recent messages in the thread. - TruncationStrategyLastMessages = TruncationStrategy("last_messages") -) - -// ReponseFormat specifies the format the model must output. -// https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-response_format. -// Type can either be text or json_object. -type ReponseFormat struct { - Type string `json:"type"` + Stream bool `json:"stream,omitempty"` } type RunModifyRequest struct { @@ -240,7 +183,8 @@ func (c *Client) CreateRun( http.MethodPost, c.fullURL(urlSuffix), withBody(request), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } @@ -249,6 +193,51 @@ func (c *Client) CreateRun( return } +type RunStreamResponseDelta struct { + Role string `json:"role"` + Content []MessageContent `json:"content"` + FileIDs []string `json:"file_ids"` +} + +type RunStreamResponse struct { + ID string `json:"id"` + Object string `json:"object"` + Delta RunStreamResponseDelta `json:"delta"` +} + +type RunStream struct { + *streamReader[RunStreamResponse] +} + +// CreateRunStream creates a new run with streaming support. +func (c *Client) CreateRunStream( + ctx context.Context, + threadID string, + request RunRequest, +) (stream *RunStream, err error) { + urlSuffix := fmt.Sprintf("/threads/%s/runs", threadID) + request.Stream = true + req, err := c.newRequest( + ctx, + http.MethodPost, + c.fullURL(urlSuffix), + withBody(request), + withBetaAssistantVersion(c.config.AssistantVersion), + ) + if err != nil { + return + } + + resp, err := sendRequestStream[RunStreamResponse](c, req) + if err != nil { + return + } + stream = &RunStream{ + streamReader: resp, + } + return +} + // RetrieveRun retrieves a run. func (c *Client) RetrieveRun( ctx context.Context, @@ -260,7 +249,8 @@ func (c *Client) RetrieveRun( ctx, http.MethodGet, c.fullURL(urlSuffix), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } @@ -282,7 +272,8 @@ func (c *Client) ModifyRun( http.MethodPost, c.fullURL(urlSuffix), withBody(request), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } @@ -321,7 +312,8 @@ func (c *Client) ListRuns( ctx, http.MethodGet, c.fullURL(urlSuffix), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } @@ -342,7 +334,8 @@ func (c *Client) SubmitToolOutputs( http.MethodPost, c.fullURL(urlSuffix), withBody(request), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } @@ -361,7 +354,8 @@ func (c *Client) CancelRun( ctx, http.MethodPost, c.fullURL(urlSuffix), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } @@ -380,7 +374,8 @@ func (c *Client) CreateThreadAndRun( http.MethodPost, c.fullURL(urlSuffix), withBody(request), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } @@ -401,7 +396,8 @@ func (c *Client) RetrieveRunStep( ctx, http.MethodGet, c.fullURL(urlSuffix), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } @@ -441,7 +437,8 @@ func (c *Client) ListRunSteps( ctx, http.MethodGet, c.fullURL(urlSuffix), - withBetaAssistantVersion(c.config.AssistantVersion)) + withBetaAssistantVersion(c.config.AssistantVersion), + ) if err != nil { return } diff --git a/run_test.go b/run_test.go index cdf99db05..5e00df2af 100644 --- a/run_test.go +++ b/run_test.go @@ -3,8 +3,8 @@ package openai_test import ( "context" - openai "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + openai "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" "encoding/json" "fmt" diff --git a/speech_test.go b/speech_test.go index f1e405c39..40ea0948d 100644 --- a/speech_test.go +++ b/speech_test.go @@ -11,9 +11,9 @@ import ( "path/filepath" "testing" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestSpeechIntegration(t *testing.T) { diff --git a/stream_reader.go b/stream_reader.go index 4210a1948..833f4960b 100644 --- a/stream_reader.go +++ b/stream_reader.go @@ -7,7 +7,7 @@ import ( "io" "net/http" - utils "github.com/sashabaranov/go-openai/internal" + utils "github.com/openshieldai/go-openai/internal" ) var ( @@ -16,7 +16,7 @@ var ( ) type streamable interface { - ChatCompletionStreamResponse | CompletionResponse + ChatCompletionStreamResponse | CompletionResponse | RunStreamResponse } type streamReader[T streamable] struct { diff --git a/stream_reader_test.go b/stream_reader_test.go index cd6e46eff..bca0128b1 100644 --- a/stream_reader_test.go +++ b/stream_reader_test.go @@ -6,9 +6,9 @@ import ( "errors" "testing" - utils "github.com/sashabaranov/go-openai/internal" - "github.com/sashabaranov/go-openai/internal/test" - "github.com/sashabaranov/go-openai/internal/test/checks" + utils "github.com/openshieldai/go-openai/internal" + "github.com/openshieldai/go-openai/internal/test" + "github.com/openshieldai/go-openai/internal/test/checks" ) var errTestUnmarshalerFailed = errors.New("test unmarshaler failed") diff --git a/stream_test.go b/stream_test.go index 9dd95bb5f..9fc01846d 100644 --- a/stream_test.go +++ b/stream_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" - "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) func TestCompletionsStreamWrongModel(t *testing.T) { diff --git a/thread_test.go b/thread_test.go index 1ac0f3c0e..83e8676cf 100644 --- a/thread_test.go +++ b/thread_test.go @@ -7,8 +7,8 @@ import ( "net/http" "testing" - openai "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + openai "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" ) // TestThread Tests the thread endpoint of the API using the mocked server. diff --git a/vector_store_test.go b/vector_store_test.go index 58b9a857e..55d8beda2 100644 --- a/vector_store_test.go +++ b/vector_store_test.go @@ -3,8 +3,8 @@ package openai_test import ( "context" - openai "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" + openai "github.com/openshieldai/go-openai" + "github.com/openshieldai/go-openai/internal/test/checks" "encoding/json" "fmt"