Repository: sashabaranov/go-openai
Pull request #317 (2023-05-19 14:28:58)

docs(readme): update format
as title.


Patch:
diff --git a/README.md b/README.md
index 994f26d..7562694 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
 [![Go Report Card](https://goreportcard.com/badge/github.com/sashabaranov/go-openai)](https://goreportcard.com/report/github.com/sashabaranov/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 Go clients for [OpenAI API](https://platform.openai.com/). We support:
+This library provides unofficial Go clients for [OpenAI API](https://platform.openai.com/). We support: 
 
 * ChatGPT
 * GPT-3, GPT-4
@@ -435,16 +435,15 @@ import (
 )
 
 func main() {
-
 	config := openai.DefaultAzureConfig("your Azure OpenAI Key", "https://your Azure OpenAI Endpoint")
-	//If you use a deployment name different from the model name, you can customize the AzureModelMapperFunc function
-	//config.AzureModelMapperFunc = func(model string) string {
-        //    azureModelMapping = map[string]string{
-        //        "gpt-3.5-turbo":"your gpt-3.5-turbo deployment name",
-        //    }
-        //    return azureModelMapping[model]
-        //}
-	
+	// If you use a deployment name different from the model name, you can customize the AzureModelMapperFunc function
+	// config.AzureModelMapperFunc = func(model string) string {
+	// 	azureModelMapping = map[string]string{
+	// 		"gpt-3.5-turbo": "your gpt-3.5-turbo deployment name",
+	// 	}
+	// 	return azureModelMapping[model]
+	// }
+
 	client := openai.NewClientWithConfig(config)
 	resp, err := client.CreateChatCompletion(
 		context.Background(),
@@ -458,7 +457,6 @@ func main() {
 			},
 		},
 	)
-
 	if err != nil {
 		fmt.Printf("ChatCompletion error: %v\n", err)
 		return
@@ -466,6 +464,55 @@ func main() {
 
 	fmt.Println(resp.Choices[0].Message.Content)
 }
+
+```
+</details>
+
+<details>
+<summary>Azure OpenAI Embeddings</summary>
+
+```go
+package main
+
+import (
+	"context"
+	"fmt"
+
+	openai "github.com/sashabaranov/go-openai"
+)
+
+func main() {
+
+	config := openai.DefaultAzureConfig("your Azure OpenAI Key", "https://your Azure OpenAI Endpoint")
+	config.APIVersion = "2023-05-15" // optional update to latest API version
+
+	//If you use a deployment name different from the model name, you can customize the AzureModelMapperFunc function
+	//config.AzureModelMapperFunc = func(model string) string {
+	//    azureModelMapping = map[string]string{
+	//        "gpt-3.5-turbo":"your gpt-3.5-turbo deployment name",
+	//    }
+	//    return azureModelMapping[model]
+	//}
+
+	input := "Text to vectorize"
+
+	client := openai.NewClientWithConfig(config)
+	resp, err := client.CreateEmbeddings(
+		context.Background(),
+		openai.EmbeddingRequest{
+			Input: []string{input},
+			Model: openai.AdaEmbeddingV2,
+		})
+
+	if err != nil {
+		fmt.Printf("CreateEmbeddings error: %v\n", err)
+		return
+	}
+
+	vectors := resp.Data[0].Embedding // []float32 with 1536 dimensions
+
+	fmt.Println(vectors[:10], "...", vectors[len(vectors)-10:])
+}
 ```
 </details>
 
diff --git a/config.go b/config.go
index fbcf377..c58b71e 100644
--- a/config.go
+++ b/config.go
@@ -56,7 +56,7 @@ func DefaultAzureConfig(apiKey, baseURL string) ClientConfig {
 		BaseURL:    baseURL,
 		OrgID:      "",
 		APIType:    APITypeAzure,
-		APIVersion: "2023-03-15-preview",
+		APIVersion: "2023-05-15",
 		AzureModelMapperFunc: func(model string) string {
 			return regexp.MustCompile(`[.:]`).ReplaceAllString(model, "")
 		},


Test patch:
diff --git a/api_internal_test.go b/api_internal_test.go
index 529e7c7..214b627 100644
--- a/api_internal_test.go
+++ b/api_internal_test.go
@@ -122,7 +122,7 @@ func TestAzureFullURL(t *testing.T) {
 			"chatgpt-demo",
 			"https://httpbin.org/" +
 				"openai/deployments/chatgpt-demo" +
-				"/chat/completions?api-version=2023-03-15-preview",
+				"/chat/completions?api-version=2023-05-15",
 		},
 		{
 			"AzureBaseURLWithoutSlashOK",
@@ -131,7 +131,7 @@ func TestAzureFullURL(t *testing.T) {
 			"chatgpt-demo",
 			"https://httpbin.org/" +
 				"openai/deployments/chatgpt-demo" +
-				"/chat/completions?api-version=2023-03-15-preview",
+				"/chat/completions?api-version=2023-05-15",
 		},
 	}