Skip to content

Commit de53b98

Browse files
updates for demo (Azure#46997)
* updates for demo * PR feedback * updated api file * changed from global to local memory.data 8.0 * fixed bugs * more bug fixes
1 parent d96e4ea commit de53b98

File tree

11 files changed

+193
-89
lines changed

11 files changed

+193
-89
lines changed

sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public readonly partial struct MessagingServices
2626
{
2727
private readonly object _dummy;
2828
private readonly int _dummyPrimitive;
29-
public void SendMessage(object serializable) { }
29+
public void SendJson(object serializable) { }
30+
public System.Threading.Tasks.Task SendJsonAsync(object serializable) { throw null; }
3031
public void WhenMessageReceived(System.Action<string> received) { }
3132
}
3233
public partial class StorageFile
@@ -36,6 +37,7 @@ internal StorageFile() { }
3637
public string Path { get { throw null; } }
3738
public string RequestId { get { throw null; } }
3839
public void Delete() { }
40+
public System.Threading.Tasks.Task DeleteAsync() { throw null; }
3941
public System.BinaryData Download() { throw null; }
4042
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
4143
public override bool Equals(object obj) { throw null; }
@@ -50,14 +52,18 @@ public readonly partial struct StorageServices
5052
{
5153
private readonly object _dummy;
5254
private readonly int _dummyPrimitive;
53-
public void DeleteBlob(string path) { }
54-
public System.BinaryData DownloadBlob(string path) { throw null; }
55-
public string UploadBinaryData(System.BinaryData data, string name = null, bool overwrite = false) { throw null; }
56-
public string UploadBytes(byte[] bytes, string name = null, bool overwrite = false) { throw null; }
57-
public string UploadBytes(System.ReadOnlyMemory<byte> bytes, string name = null, bool overwrite = false) { throw null; }
55+
public void Delete(string path) { }
56+
public System.Threading.Tasks.Task DeleteAsync(string path) { throw null; }
57+
public System.BinaryData Download(string path) { throw null; }
58+
public System.Threading.Tasks.Task<System.BinaryData> DownloadAsync(string path) { throw null; }
59+
public string Upload(System.BinaryData data, string name = null, bool overwrite = false) { throw null; }
60+
public string Upload(System.IO.Stream fileStream, string name = null, string contentType = null, bool overwrite = false) { throw null; }
61+
public System.Threading.Tasks.Task<string> UploadAsync(System.BinaryData data, string name = null, bool overwrite = false) { throw null; }
62+
public System.Threading.Tasks.Task<string> UploadAsync(System.IO.Stream fileStream, string name = null, string contentType = null, bool overwrite = false) { throw null; }
5863
public string UploadJson(object json, string name = null, bool overwrite = false) { throw null; }
59-
public string UploadStream(System.IO.Stream fileStream, string name = null, bool overwrite = false) { throw null; }
60-
public void WhenBlobUploaded(System.Action<Azure.CloudMachine.StorageFile> function) { }
64+
public System.Threading.Tasks.Task<string> UploadJsonAsync(object json, string name = null, bool overwrite = false) { throw null; }
65+
public void WhenUploaded(System.Action<Azure.CloudMachine.StorageFile> function) { }
66+
public void WhenUploaded(System.Action<System.BinaryData> function) { }
6167
}
6268
}
6369
namespace Azure.CloudMachine.KeyVault
@@ -71,12 +77,11 @@ namespace Azure.CloudMachine.OpenAI
7177
{
7278
public static partial class AzureOpenAIExtensions
7379
{
80+
public static void Add(this System.Collections.Generic.List<OpenAI.Chat.ChatMessage> messages, System.Collections.Generic.IEnumerable<Azure.CloudMachine.OpenAI.VectorbaseEntry> entries) { }
7481
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
7582
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
83+
public static void Trim(this System.Collections.Generic.List<OpenAI.Chat.ChatMessage> messages) { }
7684
}
77-
}
78-
namespace Azure.CloudMachine.OpenAI.Chat
79-
{
8085
public partial class ChatTools
8186
{
8287
public ChatTools(params System.Type[] tools) { }
@@ -92,14 +97,12 @@ public void Add(System.Type functions) { }
9297
protected virtual string GetMethodInfoToName(System.Reflection.MethodInfo function) { throw null; }
9398
protected virtual string GetParameterInfoToDescription(System.Reflection.ParameterInfo parameter) { throw null; }
9499
}
95-
}
96-
namespace Azure.CloudMachine.OpenAI.Embeddings
97-
{
98100
public partial class EmbeddingsVectorbase
99101
{
100-
public EmbeddingsVectorbase(OpenAI.Embeddings.EmbeddingClient client, Azure.CloudMachine.OpenAI.Embeddings.VectorbaseStore store = null, int factChunkSize = 0) { }
102+
public EmbeddingsVectorbase(OpenAI.Embeddings.EmbeddingClient client, Azure.CloudMachine.OpenAI.VectorbaseStore store = null, int factChunkSize = 0) { }
103+
public void Add(System.BinaryData data) { }
101104
public void Add(string text) { }
102-
public System.Collections.Generic.IEnumerable<Azure.CloudMachine.OpenAI.Embeddings.VectorbaseEntry> Find(string text, Azure.CloudMachine.OpenAI.Embeddings.FindOptions options = null) { throw null; }
105+
public System.Collections.Generic.IEnumerable<Azure.CloudMachine.OpenAI.VectorbaseEntry> Find(string text, Azure.CloudMachine.OpenAI.FindOptions options = null) { throw null; }
103106
}
104107
public partial class FindOptions
105108
{
@@ -120,10 +123,10 @@ public readonly partial struct VectorbaseEntry
120123
public abstract partial class VectorbaseStore
121124
{
122125
protected VectorbaseStore() { }
123-
public abstract int Add(Azure.CloudMachine.OpenAI.Embeddings.VectorbaseEntry entry);
124-
public abstract void Add(System.Collections.Generic.IReadOnlyList<Azure.CloudMachine.OpenAI.Embeddings.VectorbaseEntry> entry);
126+
public abstract int Add(Azure.CloudMachine.OpenAI.VectorbaseEntry entry);
127+
public abstract void Add(System.Collections.Generic.IReadOnlyList<Azure.CloudMachine.OpenAI.VectorbaseEntry> entry);
125128
public static float CosineSimilarity(System.ReadOnlySpan<float> x, System.ReadOnlySpan<float> y) { throw null; }
126-
public abstract System.Collections.Generic.IEnumerable<Azure.CloudMachine.OpenAI.Embeddings.VectorbaseEntry> Find(System.ReadOnlyMemory<float> vector, Azure.CloudMachine.OpenAI.Embeddings.FindOptions options);
129+
public abstract System.Collections.Generic.IEnumerable<Azure.CloudMachine.OpenAI.VectorbaseEntry> Find(System.ReadOnlyMemory<float> vector, Azure.CloudMachine.OpenAI.FindOptions options);
127130
}
128131
}
129132
namespace Azure.Core

sdk/cloudmachine/Azure.CloudMachine/src/Azure.CloudMachine.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<PackageReference Include="Azure.Security.KeyVault.Secrets" />
2222
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" VersionOverride="8.0.0" />
2323
<PackageReference Include="Microsoft.Bcl.Numerics" />
24+
<PackageReference Include="System.Memory.Data" VersionOverride="8.0.0"/>
2425
</ItemGroup>
2526

2627
</Project>

sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/MessagingServices.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,24 @@ public readonly struct MessagingServices
2020
/// Sends a message to the service bus.
2121
/// </summary>
2222
/// <param name="serializable"></param>
23-
public void SendMessage(object serializable)
23+
public void SendJson(object serializable)
24+
{
25+
#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult().
26+
SendJsonAsync(serializable).GetAwaiter().GetResult();
27+
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult().
28+
}
29+
30+
/// <summary>
31+
/// Sends a message to the service bus.
32+
/// </summary>
33+
/// <param name="serializable"></param>
34+
public async Task SendJsonAsync(object serializable)
2435
{
2536
ServiceBusSender sender = GetServiceBusSender();
2637

2738
BinaryData serialized = BinaryData.FromObjectAsJson(serializable);
2839
ServiceBusMessage message = new(serialized);
29-
#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult().
30-
sender.SendMessageAsync(message).GetAwaiter().GetResult();
31-
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult().
40+
await sender.SendMessageAsync(message).ConfigureAwait(false);
3241
}
3342

3443
/// <summary>

sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/StorageFile.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.ComponentModel;
66
using System.Threading;
7+
using System.Threading.Tasks;
78

89
namespace Azure.CloudMachine;
910

@@ -43,7 +44,7 @@ public class StorageFile
4344
/// </summary>
4445
/// <returns></returns>
4546
public BinaryData Download()
46-
=> _storage.DownloadBlob(Path);
47+
=> _storage.Download(Path);
4748

4849
// public async Task<BinaryData> DownloadAsync()
4950
// => await _storage.DownloadBlobAsync(Path).ConfigureAwait(false);
@@ -52,10 +53,14 @@ public BinaryData Download()
5253
/// Deletes the file from the storage account.
5354
/// </summary>
5455
public void Delete()
55-
=> _storage.DeleteBlob(Path);
56+
=> _storage.Delete(Path);
5657

57-
// public async Task DeleteAsync()
58-
// => await _storage.DeleteBlobAsync(Path).ConfigureAwait(false);
58+
/// <summary>
59+
/// Deletes the file from the storage account.
60+
/// </summary>
61+
/// <returns></returns>
62+
public async Task DeleteAsync()
63+
=> await _storage.DeleteAsync(Path).ConfigureAwait(false);
5964

6065
// public Uri ShareFolder(AccessPermissions permissions, TimeSpan expiresAfter)
6166
// => _storage.ShareFolder(Path, permissions, expiresAfter);

0 commit comments

Comments
 (0)