Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -11,6 +11,11 @@ namespace Microsoft.Extensions.AI;
/// <summary>Represents a chat client.</summary>
/// <remarks>
/// <para>
/// Applications must consider the risks of prompt injection attacks, data sizes, and the number of messages
/// sent to the underlying provider or returned from it. Unless a specific <see cref="IChatClient"/> implementation
/// explicitly documents safeguards for these concerns, the application is expected to implement appropriate protections.
/// </para>
/// <para>
/// Unless otherwise specified, all members of <see cref="IChatClient"/> are thread-safe for concurrent use.
/// It is expected that all implementations of <see cref="IChatClient"/> support being used by multiple requests concurrently.
/// Instances must not be disposed of while the instance is still in use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ namespace Microsoft.Extensions.AI;
public static class AzureAIInferenceExtensions
{
/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="ChatCompletionsClient"/>.</summary>
/// <remarks>
/// <para>
/// No prompt injection defense is performed by default. Applications are expected to implement
/// guards against prompt injection attacks as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on data sizes sent to the underlying provider or returned from it
/// by default. Applications are expected to apply data size limits as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on the number of messages sent to the underlying provider or returned from
/// it by default. Applications are expected to apply rate limits on a per-user or per-session basis as needed.
/// </para>
/// </remarks>
/// <param name="chatCompletionsClient">The client.</param>
/// <param name="modelId">The ID of the model to use. If <see langword="null"/>, it can be provided per request via <see cref="ChatOptions.ModelId"/>.</param>
/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="ChatCompletionsClient"/>.</returns>
Expand Down
14 changes: 14 additions & 0 deletions src/Libraries/Microsoft.Extensions.AI.Ollama/OllamaChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
namespace Microsoft.Extensions.AI;

/// <summary>Represents an <see cref="IChatClient"/> for Ollama.</summary>
/// <remarks>
/// <para>
/// No prompt injection defense is performed by default. Applications are expected to implement
/// guards against prompt injection attacks as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on data sizes sent to the underlying provider or returned from it
/// by default. Applications are expected to apply data size limits as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on the number of messages sent to the underlying provider or returned from
/// it by default. Applications are expected to apply rate limits on a per-user or per-session basis as needed.
/// </para>
/// </remarks>
public sealed class OllamaChatClient : IChatClient
{
private static readonly JsonElement _schemalessJsonResponseFormatValue = JsonDocument.Parse("\"json\"").RootElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,60 @@ namespace Microsoft.Extensions.AI;
public static class OpenAIClientExtensions
{
/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="ChatClient"/>.</summary>
/// <remarks>
/// <para>
/// No prompt injection defense is performed by default. Applications are expected to implement
/// guards against prompt injection attacks as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on data sizes sent to the underlying provider or returned from it
/// by default. Applications are expected to apply data size limits as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on the number of messages sent to the underlying provider or returned from
/// it by default. Applications are expected to apply rate limits on a per-user or per-session basis as needed.
/// </para>
/// </remarks>
/// <param name="chatClient">The client.</param>
/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="ChatClient"/>.</returns>
public static IChatClient AsIChatClient(this ChatClient chatClient) =>
new OpenAIChatClient(chatClient);

/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="OpenAIResponseClient"/>.</summary>
/// <remarks>
/// <para>
/// No prompt injection defense is performed by default. Applications are expected to implement
/// guards against prompt injection attacks as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on data sizes sent to the underlying provider or returned from it
/// by default. Applications are expected to apply data size limits as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on the number of messages sent to the underlying provider or returned from
/// it by default. Applications are expected to apply rate limits on a per-user or per-session basis as needed.
/// </para>
/// </remarks>
/// <param name="responseClient">The client.</param>
/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="OpenAIResponseClient"/>.</returns>
public static IChatClient AsIChatClient(this OpenAIResponseClient responseClient) =>
new OpenAIResponseChatClient(responseClient);

/// <summary>Gets an <see cref="ISpeechToTextClient"/> for use with this <see cref="AudioClient"/>.</summary>
/// <remarks>
/// <para>
/// No prompt injection defense is performed by default. Applications are expected to implement
/// guards against prompt injection attacks as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on data sizes sent to the underlying provider or returned from it
/// by default. Applications are expected to apply data size limits as needed.
/// </para>
/// <para>
/// There are no limits or restrictions imposed on the number of messages sent to the underlying provider or returned from
/// it by default. Applications are expected to apply rate limits on a per-user or per-session basis as needed.
/// </para>
/// </remarks>
/// <param name="audioClient">The client.</param>
/// <returns>An <see cref="ISpeechToTextClient"/> that can be used to transcribe audio via the <see cref="AudioClient"/>.</returns>
[Experimental("MEAI001")]
Expand Down
Loading