Skip to content
Open
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
9 changes: 9 additions & 0 deletions sdk_v2/cs/src/Detail/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ await Utils.CallWithExceptionHandlingAsync(
$"Error removing model {Id} from cache", _logger, ct).ConfigureAwait(false);
}

[System.Obsolete("Use new ChatSession(model) instead.", error: false)]
public async Task<OpenAIChatClient> GetChatClientAsync(CancellationToken? ct = null)
{
return await Utils.CallWithExceptionHandlingAsync(
Expand All @@ -125,11 +126,14 @@ public async Task<OpenAIChatClient> GetChatClientAsync(CancellationToken? ct = n
throw new FoundryLocalException($"Model {Id} is not loaded. Call LoadAsync first.");
}

#pragma warning disable CS0618 // OpenAIChatClient is obsolete
return new OpenAIChatClient(Id, NativeModel);
#pragma warning restore CS0618
},
"Error getting chat client for model", _logger).ConfigureAwait(false);
}

[System.Obsolete("Use new AudioSession(model) instead.", error: false)]
public async Task<OpenAIAudioClient> GetAudioClientAsync(CancellationToken? ct = null)
{
return await Utils.CallWithExceptionHandlingAsync(
Expand All @@ -140,11 +144,14 @@ public async Task<OpenAIAudioClient> GetAudioClientAsync(CancellationToken? ct =
throw new FoundryLocalException($"Model {Id} is not loaded. Call LoadAsync first.");
}

#pragma warning disable CS0618 // OpenAIAudioClient is obsolete
return new OpenAIAudioClient(Id, NativeModel);
#pragma warning restore CS0618
},
"Error getting audio client for model", _logger).ConfigureAwait(false);
}

[System.Obsolete("Use new EmbeddingsSession(model) instead.", error: false)]
public async Task<OpenAIEmbeddingClient> GetEmbeddingClientAsync(CancellationToken? ct = null)
{
return await Utils.CallWithExceptionHandlingAsync(
Expand All @@ -155,7 +162,9 @@ public async Task<OpenAIEmbeddingClient> GetEmbeddingClientAsync(CancellationTok
throw new FoundryLocalException($"Model {Id} is not loaded. Call LoadAsync first.");
}

#pragma warning disable CS0618 // OpenAIEmbeddingClient is obsolete
return new OpenAIEmbeddingClient(Id, NativeModel);
#pragma warning restore CS0618
},
"Error getting embedding client for model", _logger).ConfigureAwait(false);
}
Expand Down
3 changes: 3 additions & 0 deletions sdk_v2/cs/src/IModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,23 @@ Task DownloadAsync(Action<float>? downloadProgress = null,
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
/// <returns>OpenAI.ChatClient</returns>
[System.Obsolete("Use new ChatSession(model) instead.", error: false)]
Task<OpenAIChatClient> GetChatClientAsync(CancellationToken? ct = null);

/// <summary>
/// Get an OpenAI API based AudioClient
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
/// <returns>OpenAI.AudioClient</returns>
[System.Obsolete("Use new AudioSession(model) instead.", error: false)]
Task<OpenAIAudioClient> GetAudioClientAsync(CancellationToken? ct = null);

/// <summary>
/// Get an OpenAI API based EmbeddingClient.
/// </summary>
/// <param name="ct">Optional cancellation token.</param>
/// <returns>OpenAI.EmbeddingClient</returns>
[System.Obsolete("Use new EmbeddingsSession(model) instead.", error: false)]
Task<OpenAIEmbeddingClient> GetEmbeddingClientAsync(CancellationToken? ct = null);

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions sdk_v2/cs/src/OpenAI/AudioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Microsoft.AI.Foundry.Local;
/// Audio Client that uses the OpenAI API.
/// Implemented using Betalgo.Ranul.OpenAI SDK types.
/// </summary>
[System.Obsolete("OpenAIAudioClient is deprecated. Use AudioSession instead. OpenAI types remain supported for the web-server path.", error: false)]
public class OpenAIAudioClient
{
private readonly string _modelId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ internal record AudioTranscriptionCreateRequestExtended : AudioCreateTranscripti
{
internal static AudioTranscriptionCreateRequestExtended FromUserInput(string modelId,
string audioFilePath,
#pragma warning disable CS0618 // OpenAIAudioClient is obsolete
OpenAIAudioClient.AudioSettings settings)
#pragma warning restore CS0618
{
return new AudioTranscriptionCreateRequestExtended
{
Expand Down
1 change: 1 addition & 0 deletions sdk_v2/cs/src/OpenAI/ChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Microsoft.AI.Foundry.Local;
/// Chat Client that uses the OpenAI API.
/// Implemented using Betalgo.Ranul.OpenAI SDK types.
/// </summary>
[System.Obsolete("OpenAIChatClient is deprecated. Use ChatSession instead. OpenAI types remain supported for the web-server path.", error: false)]
public class OpenAIChatClient
{
private readonly string _modelId;
Expand Down
2 changes: 2 additions & 0 deletions sdk_v2/cs/src/OpenAI/ChatCompletionRequestResponseTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ internal class ChatCompletionCreateRequestExtended : ChatCompletionCreateRequest
internal static ChatCompletionCreateRequestExtended FromUserInput(string modelId,
IEnumerable<OpenAIChatMessage> messages,
IEnumerable<ToolDefinition>? tools,
#pragma warning disable CS0618 // OpenAIChatClient is obsolete
OpenAIChatClient.ChatSettings settings,
#pragma warning restore CS0618
bool stream)
{
var request = new ChatCompletionCreateRequestExtended
Expand Down
1 change: 1 addition & 0 deletions sdk_v2/cs/src/OpenAI/EmbeddingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Microsoft.AI.Foundry.Local;
/// Embedding Client that uses the OpenAI API.
/// Implemented using Betalgo.Ranul.OpenAI SDK types.
/// </summary>
[System.Obsolete("OpenAIEmbeddingClient is deprecated. Use EmbeddingsSession instead. OpenAI types remain supported for the web-server path.", error: false)]
public class OpenAIEmbeddingClient
{
private readonly string _modelId;
Expand Down
1 change: 1 addition & 0 deletions sdk_v2/cs/src/OpenAI/LiveAudioTranscriptionClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Microsoft.AI.Foundry.Local.OpenAI;
/// Push PCM audio chunks via <see cref="AppendAsync"/> and consume transcription results
/// via <see cref="GetStream"/>.
/// </summary>
[System.Obsolete("LiveAudioTranscriptionSession is deprecated. Use AudioSession streaming instead. OpenAI types remain supported for the web-server path.", error: false)]
public sealed class LiveAudioTranscriptionSession : IAsyncDisposable
{
private enum SessionState { Created, Started, Stopped, Disposed }
Expand Down
4 changes: 4 additions & 0 deletions sdk_v2/js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ export type {
ToolChoice,
} from "./types.js";

/** @deprecated Use ChatSession instead. OpenAI types remain supported for the web-server path. */
export { ChatClient, ChatClientSettings } from "./openai/chatClient.js";
/** @deprecated Use AudioSession instead. OpenAI types remain supported for the web-server path. */
export { AudioClient, AudioClientSettings } from "./openai/audioClient.js";
/** @deprecated Use EmbeddingsSession instead. OpenAI types remain supported for the web-server path. */
export { EmbeddingClient } from "./openai/embeddingClient.js";
/** @deprecated Use AudioSession streaming instead. OpenAI types remain supported for the web-server path. */
export {
LiveAudioTranscriptionOptions,
LiveAudioTranscriptionSession,
Expand Down
3 changes: 3 additions & 0 deletions sdk_v2/js/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,17 @@ export class Model implements IModel {
this.#native.selectVariant(nativeVariant);
}

/** @deprecated Use a `ChatSession` instead. The OpenAI direct client is deprecated. */
createChatClient(): ChatClient {
return new ChatClient(this);
}

/** @deprecated Use an `AudioSession` instead. The OpenAI direct client is deprecated. */
createAudioClient(): AudioClient {
return new AudioClient(this);
}

/** @deprecated Use an `EmbeddingsSession` instead. The OpenAI direct client is deprecated. */
createEmbeddingClient(): EmbeddingClient {
return new EmbeddingClient(this);
}
Expand Down
4 changes: 4 additions & 0 deletions sdk_v2/js/src/openai/audioClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export class AudioClientSettings {
}
}

/**
* @deprecated The OpenAI direct client is deprecated. Use AudioSession instead.
* OpenAI types remain supported for the web-server path.
*/
export class AudioClient {
readonly #model: Model;
#disposed = false;
Expand Down
3 changes: 3 additions & 0 deletions sdk_v2/js/src/openai/chatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class ChatClientSettings {
* {@link Model.createChatClient}. The underlying model must already be loaded — call `await model.load()` first.
* Each `completeChat` / `completeStreamingChat` call constructs and disposes its own `ChatSession`,
* matching the v1 SDK's stateless behaviour — no conversation state is retained on the client.
*
* @deprecated The OpenAI direct client is deprecated. Use ChatSession instead.
* OpenAI types remain supported for the web-server path.
*/
export class ChatClient {
readonly #model: Model;
Expand Down
4 changes: 4 additions & 0 deletions sdk_v2/js/src/openai/embeddingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { EmbeddingsSession } from "../session.js";
// biome-ignore lint/suspicious/noExplicitAny: OpenAI request/response objects are user-shaped JSON.
type Json = any;

/**
* @deprecated The OpenAI direct client is deprecated. Use EmbeddingsSession instead.
* OpenAI types remain supported for the web-server path.
*/
export class EmbeddingClient {
readonly #model: Model;
#disposed = false;
Expand Down
4 changes: 4 additions & 0 deletions sdk_v2/js/src/openai/liveAudioSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export class LiveAudioTranscriptionOptions {
pushQueueCapacity = 100;
}

/**
* @deprecated The OpenAI direct client is deprecated. Use AudioSession streaming instead.
* OpenAI types remain supported for the web-server path.
*/
export class LiveAudioTranscriptionSession implements AsyncDisposable, Disposable {
readonly #model: Model;
public settings = new LiveAudioTranscriptionOptions();
Expand Down
26 changes: 23 additions & 3 deletions sdk_v2/python/src/foundry_local_sdk/imodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Callable

from typing_extensions import deprecated

from foundry_local_sdk.exception import FoundryLocalException
from foundry_local_sdk.model_info import DeviceType, ModelInfo, Runtime

Expand Down Expand Up @@ -106,15 +108,27 @@ def unload(self) -> None:

@abstractmethod
def get_chat_client(self) -> "ChatClient":
"""Get an OpenAI API-compatible ChatClient."""
"""Get an OpenAI API-compatible ChatClient.

.. deprecated::
Use ``ChatSession`` instead. OpenAI types remain supported for the web-server path.
"""

@abstractmethod
def get_audio_client(self) -> "AudioClient":
"""Get an OpenAI API-compatible AudioClient."""
"""Get an OpenAI API-compatible AudioClient.

.. deprecated::
Use ``AudioSession`` instead. OpenAI types remain supported for the web-server path.
"""

@abstractmethod
def get_embedding_client(self) -> "EmbeddingClient":
"""Get an OpenAI API-compatible EmbeddingClient."""
"""Get an OpenAI API-compatible EmbeddingClient.

.. deprecated::
Use ``EmbeddingsSession`` instead. OpenAI types remain supported for the web-server path.
"""

@property
@abstractmethod
Expand Down Expand Up @@ -400,14 +414,20 @@ def select_variant(self, variant: IModel) -> None:
# OpenAI client factories
# ------------------------------------------------------------------

@deprecated("The OpenAI direct client is deprecated; use ChatSession. OpenAI types remain supported "
"for the web-server path.")
def get_chat_client(self) -> "ChatClient":
from foundry_local_sdk.openai.chat_client import ChatClient
return ChatClient(self.info.id, self)

@deprecated("The OpenAI direct client is deprecated; use ChatSession. OpenAI types remain supported "
"for the web-server path.")
def get_audio_client(self) -> "AudioClient":
from foundry_local_sdk.openai.audio_client import AudioClient
return AudioClient(self.info.id, self)

@deprecated("The OpenAI direct client is deprecated; use EmbeddingsSession. OpenAI types remain "
"supported for the web-server path.")
def get_embedding_client(self) -> "EmbeddingClient":
from foundry_local_sdk.openai.embedding_client import EmbeddingClient
return EmbeddingClient(self.info.id, self)
18 changes: 18 additions & 0 deletions sdk_v2/python/src/foundry_local_sdk/openai/audio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
from __future__ import annotations

import json
import warnings
from dataclasses import dataclass
from typing import TYPE_CHECKING, Generator

from typing_extensions import deprecated

if TYPE_CHECKING:
from foundry_local_sdk.imodel import IModel
from foundry_local_sdk.openai.live_audio_session import LiveAudioTranscriptionSession
Expand Down Expand Up @@ -42,9 +45,18 @@ class AudioTranscriptionResponse:
text: str


@deprecated(
"The OpenAI direct client is deprecated; use AudioSession. OpenAI types remain supported "
"for the web-server path."
)
class AudioClient:
"""OpenAI-compatible audio transcription client backed by Foundry Local Core.

.. deprecated::
The OpenAI direct client is deprecated; use
:class:`foundry_local_sdk.session.AudioSession`. OpenAI types remain
supported for the web-server path.

Each call creates a fresh native session (stateless — no session history).
Supports non-streaming and streaming transcription of audio files.

Expand All @@ -54,6 +66,12 @@ class AudioClient:
"""

def __init__(self, model_id: str, model: IModel) -> None:
warnings.warn(
"The OpenAI direct client is deprecated; use AudioSession. OpenAI types remain "
"supported for the web-server path.",
DeprecationWarning,
stacklevel=2,
)
self.model_id = model_id
# Hold the IModel reference so the underlying native model pointer
# cannot be released out from under us.
Expand Down
17 changes: 17 additions & 0 deletions sdk_v2/python/src/foundry_local_sdk/openai/chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
from __future__ import annotations

import json
import warnings
from typing import TYPE_CHECKING, Any, Generator

from openai.types.chat.chat_completion_message_param import ChatCompletionMessageParam
from openai.types.chat import ChatCompletion
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk
from typing_extensions import deprecated

if TYPE_CHECKING:
from foundry_local_sdk.imodel import IModel
Expand Down Expand Up @@ -115,9 +117,18 @@ def _validate_tool_choice(self, tool_choice: dict[str, Any] | None) -> None:
raise ValueError(f'ToolChoice with type "{choice_type}" should not have a name property.')


@deprecated(
"The OpenAI direct client is deprecated; use ChatSession. OpenAI types remain supported "
"for the web-server path."
)
class ChatClient:
"""OpenAI-compatible chat completions client backed by Foundry Local Core.

.. deprecated::
The OpenAI direct client is deprecated; use
:class:`foundry_local_sdk.session.ChatSession`. OpenAI types remain
supported for the web-server path.

Each call creates a fresh native session (stateless — no turn history).
Supports non-streaming and streaming completions with optional tool calling.

Expand All @@ -127,6 +138,12 @@ class ChatClient:
"""

def __init__(self, model_id: str, model: IModel) -> None:
warnings.warn(
"The OpenAI direct client is deprecated; use ChatSession. OpenAI types remain "
"supported for the web-server path.",
DeprecationWarning,
stacklevel=2,
)
self.model_id = model_id
# Hold the IModel reference so the underlying native model pointer
# cannot be released out from under us.
Expand Down
17 changes: 17 additions & 0 deletions sdk_v2/python/src/foundry_local_sdk/openai/embedding_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,41 @@
from __future__ import annotations

import json
import warnings
from typing import TYPE_CHECKING

from openai.types import CreateEmbeddingResponse
from typing_extensions import deprecated

if TYPE_CHECKING:
from foundry_local_sdk.imodel import IModel


@deprecated(
"The OpenAI direct client is deprecated; use EmbeddingsSession. OpenAI types remain supported "
"for the web-server path."
)
class EmbeddingClient:
"""OpenAI-compatible embedding client backed by Foundry Local Core.

.. deprecated::
The OpenAI direct client is deprecated; use
:class:`foundry_local_sdk.session.EmbeddingsSession`. OpenAI types
remain supported for the web-server path.

Each call creates a fresh native session (stateless — no session history).

Attributes:
model_id: The ID of the loaded embedding model variant.
"""

def __init__(self, model_id: str, model: IModel) -> None:
warnings.warn(
"The OpenAI direct client is deprecated; use EmbeddingsSession. OpenAI types remain "
"supported for the web-server path.",
DeprecationWarning,
stacklevel=2,
)
self.model_id = model_id
# Hold the IModel reference so the underlying native model pointer
# cannot be released out from under us.
Expand Down
Loading