Skip to content

Commit 103d454

Browse files
chore(internal): updates (#2)
1 parent fb2df0f commit 103d454

File tree

9 files changed

+135
-659
lines changed

9 files changed

+135
-659
lines changed

README.md

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ func main() {
5151
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("OPENAI_API_KEY")
5252
)
5353
chatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{
54-
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
55-
openai.UserMessage("Say this is a test"),
56-
}),
54+
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{openai.ChatCompletionUserMessageParam{
55+
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
56+
Content: openai.F[openai.ChatCompletionUserMessageParamContentUnion](shared.UnionString("Say this is a test")),
57+
}}),
5758
Model: openai.F(openai.ChatModelGPT4o),
5859
})
5960
if err != nil {
@@ -236,9 +237,10 @@ defer cancel()
236237
client.Chat.Completions.New(
237238
ctx,
238239
openai.ChatCompletionNewParams{
239-
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
240-
openai.UserMessage("Say this is a test"),
241-
}),
240+
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{openai.ChatCompletionUserMessageParam{
241+
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
242+
Content: openai.F[openai.ChatCompletionUserMessageParamContentUnion](shared.UnionString("How can I list all files in a directory using Python?")),
243+
}}),
242244
Model: openai.F(openai.ChatModelGPT4o),
243245
},
244246
// This sets the per-retry timeout
@@ -298,9 +300,10 @@ client := openai.NewClient(
298300
client.Chat.Completions.New(
299301
context.TODO(),
300302
openai.ChatCompletionNewParams{
301-
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
302-
openai.UserMessage("Say this is a test"),
303-
}),
303+
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{openai.ChatCompletionUserMessageParam{
304+
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
305+
Content: openai.F[openai.ChatCompletionUserMessageParamContentUnion](shared.UnionString("How can I get the name of the current day in Node.js?")),
306+
}}),
304307
Model: openai.F(openai.ChatModelGPT4o),
305308
},
306309
option.WithMaxRetries(5),
@@ -393,44 +396,6 @@ You may also replace the default `http.Client` with
393396
accepted (this overwrites any previous client) and receives requests after any
394397
middleware has been applied.
395398

396-
## Microsoft Azure OpenAI
397-
398-
To use this library with [Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/overview), use the option.RequestOption functions in the `azure` package.
399-
400-
```go
401-
package main
402-
403-
import (
404-
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
405-
"github.com/openai/openai-go"
406-
"github.com/openai/openai-go/azure"
407-
"github.com/openai/openai-go/option"
408-
)
409-
410-
func main() {
411-
const azureOpenAIEndpoint = "https://<azure-openai-resource>.openai.azure.com"
412-
413-
// The latest API versions, including previews, can be found here:
414-
// https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versioning
415-
const azureOpenAIAPIVersion = "2024-06-01"
416-
417-
tokenCredential, err := azidentity.NewDefaultAzureCredential(nil)
418-
419-
if err != nil {
420-
fmt.Printf("Failed to create the DefaultAzureCredential: %s", err)
421-
os.Exit(1)
422-
}
423-
424-
client := openai.NewClient(
425-
azure.WithEndpoint(azureOpenAIEndpoint, azureOpenAIAPIVersion),
426-
427-
// Choose between authenticating using a TokenCredential or an API Key
428-
azure.WithTokenCredential(tokenCredential),
429-
// or azure.WithAPIKey(azureOpenAIAPIKey),
430-
)
431-
}
432-
```
433-
434399
## Semantic versioning
435400

436401
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

azure/azure.go

Lines changed: 0 additions & 237 deletions
This file was deleted.

0 commit comments

Comments
 (0)