Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use project ref to openai in test project and update sample #39689

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ AzureKeyCredential credential = new AzureKeyCredential(key);

OpenAIClient openAIClient = new OpenAIClient(endpoint, credential);
string description = "Very popular hotel in town.";
EmbeddingsOptions embeddingsOptions = new(description);
EmbeddingsOptions embeddingsOptions = new("EmbeddingsModelName", new string[] { description });

Embeddings embeddings = await openAIClient.GetEmbeddingsAsync("EmbeddingsModelName", embeddingsOptions);
IReadOnlyList<float> descriptionVector = embeddings.Data[0].Embedding;
Embeddings embeddings = await openAIClient.GetEmbeddingsAsync(embeddingsOptions);
ReadOnlyMemory<float> descriptionVector = embeddings.Data[0].Embedding;
```

In the sample code below, we are using hardcoded embeddings for the vector fields named `DescriptionVector` and `CategoryVector`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ AzureKeyCredential credential = new AzureKeyCredential(key);

OpenAIClient openAIClient = new OpenAIClient(endpoint, credential);
string description = "Very popular hotel in town.";
EmbeddingsOptions embeddingsOptions = new(description);
EmbeddingsOptions embeddingsOptions = new("EmbeddingsModelName", new string[] { description });

Embeddings embeddings = await openAIClient.GetEmbeddingsAsync("EmbeddingsModelName", embeddingsOptions);
IReadOnlyList<float> descriptionVector = embeddings.Data[0].Embedding;
Embeddings embeddings = await openAIClient.GetEmbeddingsAsync(embeddingsOptions);
ReadOnlyMemory<float> descriptionVector = embeddings.Data[0].Embedding;
```

In the sample code below, we are using hardcoded embeddings for the vector fields named `DescriptionVector` and `CategoryVector`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ AzureKeyCredential credential = new AzureKeyCredential(key);

OpenAIClient openAIClient = new OpenAIClient(endpoint, credential);
string description = "Very popular hotel in town.";
EmbeddingsOptions embeddingsOptions = new(description);
EmbeddingsOptions embeddingsOptions = new("EmbeddingsModelName", new string[] { description });

Embeddings embeddings = await openAIClient.GetEmbeddingsAsync("EmbeddingsModelName", embeddingsOptions);
IReadOnlyList<float> descriptionVector = embeddings.Data[0].Embedding;
Embeddings embeddings = await openAIClient.GetEmbeddingsAsync(embeddingsOptions);
ReadOnlyMemory<float> descriptionVector = embeddings.Data[0].Embedding;
```

In the sample code below, we are using hardcoded embeddings for the vector fields named `DescriptionVector` and `CategoryVector`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<!-- References required for sample snippet -->
<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" />
<ProjectReference Include="..\..\..\openai\Azure.AI.OpenAI\src\Azure.AI.OpenAI.csproj" />
</ItemGroup>

<!-- References required for test resource creation -->
Expand Down
6 changes: 3 additions & 3 deletions sdk/search/Azure.Search.Documents/tests/Samples/Readme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ public async Task GetEmbeddings()

OpenAIClient openAIClient = new OpenAIClient(endpoint, credential);
string description = "Very popular hotel in town.";
EmbeddingsOptions embeddingsOptions = new(description);
EmbeddingsOptions embeddingsOptions = new("EmbeddingsModelName", new string[] { description });

Embeddings embeddings = await openAIClient.GetEmbeddingsAsync("EmbeddingsModelName", embeddingsOptions);
IReadOnlyList<float> descriptionVector = embeddings.Data[0].Embedding;
Embeddings embeddings = await openAIClient.GetEmbeddingsAsync(embeddingsOptions);
ReadOnlyMemory<float> descriptionVector = embeddings.Data[0].Embedding;
#endregion
}

Expand Down