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
4 changes: 2 additions & 2 deletions .github/workflows/samples-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
# Note: /p:TreatWarningsAsErrors=false avoids failing on SDK doc warnings
dotnet pack sdk/cs/src/Microsoft.AI.Foundry.Local.csproj `
-o local-packages `
/p:Version=1.0.0-rc1 `
/p:Version=1.0.0-rc2 `
/p:IsPacking=true `
/p:TreatWarningsAsErrors=false `
--configuration Release
Expand All @@ -180,7 +180,7 @@ jobs:
if ($IsWindows) {
dotnet pack sdk/cs/src/Microsoft.AI.Foundry.Local.csproj `
-o local-packages `
/p:Version=1.0.0-rc1 `
/p:Version=1.0.0-rc2 `
/p:UseWinML=true `
/p:IsPacking=true `
/p:TreatWarningsAsErrors=false `
Expand Down
1 change: 0 additions & 1 deletion .pipelines/templates/build-core-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ steps:
</packageSources>
<packageSourceMapping>
<packageSource key="feed-ORT-Nightly">
<package pattern="Microsoft.ML.OnnxRuntimeGenAI*" />
<package pattern="Microsoft.Telemetry*" />
</packageSource>
<packageSource key="nuget.org">
Expand Down
8 changes: 6 additions & 2 deletions .pipelines/templates/build-python-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ steps:
Write-Warning "No FLC wheel found matching $filter in ${{ parameters.flcWheelsDir }}"
}

- script: pip install onnxruntime-core==1.24.3 onnxruntime-genai-core==0.12.1
displayName: 'Install ORT native packages'
- ${{ if eq(parameters.isWinML, true) }}:
- script: pip install onnxruntime-core==1.23.2.3 onnxruntime-genai-core==0.12.1
displayName: 'Install ORT native packages (WinML)'
- ${{ else }}:
- script: pip install onnxruntime-core==1.24.3 onnxruntime-genai-core==0.12.1
displayName: 'Install ORT native packages'

- script: pip install "pydantic>=2.0.0" "requests>=2.32.4" "openai>=2.24.0"
displayName: 'Install pure python dependencies'
Expand Down
4 changes: 2 additions & 2 deletions .pipelines/templates/package-core-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ steps:
$nuspec = "$nsRoot/src/FoundryLocalCore/Core/WinMLNuget.nuspec"
$id = "Microsoft.AI.Foundry.Local.Core.WinML"
$ortVer = $pg.OnnxRuntimeFoundryVersionForWinML
$genaiVer = $pg.OnnxRuntimeGenAIWinML
$genaiVer = $pg.OnnxRuntimeGenAIFoundryVersion
$winAppSdkVer = $pg.WinAppSdkVersion
$props = "id=$id;version=$(flcVersion);commitId=$(Build.SourceVersion);OnnxRuntimeFoundryVersion=$ortVer;OnnxRuntimeGenAIWinML=$genaiVer;WinAppSdkVersion=$winAppSdkVer"
$props = "id=$id;version=$(flcVersion);commitId=$(Build.SourceVersion);OnnxRuntimeFoundryVersionForWinML=$ortVer;OnnxRuntimeGenAIFoundryVersion=$genaiVer;WinAppSdkVersion=$winAppSdkVer"
} else {
$nuspec = "$nsRoot/src/FoundryLocalCore/Core/NativeNuget.nuspec"
$id = "Microsoft.AI.Foundry.Local.Core"
Expand Down
1 change: 1 addition & 0 deletions .pipelines/templates/test-cs-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ steps:
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="LocalFLC" value="${{ parameters.flcNugetDir }}" />
<add key="ORT-Nightly" value="https://pkgs.dev.azure.com/aiinfra/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json" />
</packageSources>
Expand Down
8 changes: 6 additions & 2 deletions .pipelines/templates/test-python-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ steps:
Write-Warning "No FLC wheel found matching $filter"
}
- script: pip install onnxruntime-core==1.24.3 onnxruntime-genai-core==0.12.1
displayName: 'Install ORT native packages'
- ${{ if eq(parameters.isWinML, true) }}:
- script: pip install onnxruntime-core==1.23.2.3 onnxruntime-genai-core==0.12.1
displayName: 'Install ORT native packages (WinML)'
- ${{ else }}:
- script: pip install onnxruntime-core==1.24.3 onnxruntime-genai-core==0.12.1
displayName: 'Install ORT native packages'

- script: pip install "pydantic>=2.0.0" "requests>=2.32.4" "openai>=2.24.0"
displayName: 'Install pure python dependencies'
Expand Down
4 changes: 2 additions & 2 deletions samples/cs/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<OnnxRuntimeVersion>1.23.2</OnnxRuntimeVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.AI.Foundry.Local" Version="1.0.0-rc1" />
<PackageVersion Include="Microsoft.AI.Foundry.Local.WinML" Version="1.0.0-rc1" />
<PackageVersion Include="Microsoft.AI.Foundry.Local" Version="1.0.0-rc2" />
<PackageVersion Include="Microsoft.AI.Foundry.Local.WinML" Version="1.0.0-rc2" />
<PackageVersion Include="Betalgo.Ranul.OpenAI" Version="9.1.1" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.10" />
Expand Down
14 changes: 12 additions & 2 deletions sdk/cs/src/Detail/CoreInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public CallbackHelper(CallbackFn callback)
}
}

private static void HandleCallback(nint data, int length, nint callbackHelper)
private static int HandleCallback(nint data, int length, nint callbackHelper)
{
var callbackData = string.Empty;
CallbackHelper? helper = null;
Expand All @@ -196,14 +196,24 @@ private static void HandleCallback(nint data, int length, nint callbackHelper)

helper = (CallbackHelper)GCHandle.FromIntPtr(callbackHelper).Target!;
helper.Callback.Invoke(callbackData);
return 0; // continue
}
catch (Exception ex) when (ex is not OperationCanceledException)
catch (OperationCanceledException ex)
{
if (helper != null && helper.Exception == null)
{
helper.Exception = ex;
}
return 1; // cancel
}
catch (Exception ex)
{
FoundryLocalManager.Instance.Logger.LogError(ex, $"Error in callback. Callback data: {callbackData}");
if (helper != null && helper.Exception == null)
{
helper.Exception = ex;
}
return 1; // cancel on error
}
}

Expand Down
3 changes: 2 additions & 1 deletion sdk/cs/src/Detail/ICoreInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ protected unsafe struct ResponseBuffer
}

// native callback function signature
// Return: 0 = continue, 1 = cancel
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
protected unsafe delegate void NativeCallbackFn(nint data, int length, nint userData);
protected unsafe delegate int NativeCallbackFn(nint data, int length, nint userData);

Response ExecuteCommand(string commandName, CoreInteropRequest? commandInput = null);
Response ExecuteCommandWithCallback(string commandName, CoreInteropRequest? commandInput, CallbackFn callback);
Expand Down
6 changes: 3 additions & 3 deletions sdk/cs/src/Microsoft.AI.Foundry.Local.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<GenerateDocumentationFile Condition="'$(Configuration)' == 'Release'">true</GenerateDocumentationFile>

<!--
Set to 'true' to use OnnxRuntimeGenAI.WinML with EP download on Windows
Set to 'true' to enable EP download on Windows
Command line value overrides the default value here.
-->
<UseWinML>false</UseWinML>
Expand Down Expand Up @@ -100,8 +100,8 @@
<PropertyGroup>
<!-- default version unless overridden during dotnet build/restore command -->
<FoundryLocalCoreWinMLVersion Condition="'$(FoundryLocalCoreVersion)' != ''">$(FoundryLocalCoreVersion)</FoundryLocalCoreWinMLVersion>
<FoundryLocalCoreWinMLVersion Condition="'$(FoundryLocalCoreVersion)' == ''">1.0.0-rc1</FoundryLocalCoreWinMLVersion>
<FoundryLocalCoreVersion Condition="'$(FoundryLocalCoreVersion)' == ''">1.0.0-rc1</FoundryLocalCoreVersion> </PropertyGroup>
<FoundryLocalCoreWinMLVersion Condition="'$(FoundryLocalCoreVersion)' == ''">1.0.0-rc2</FoundryLocalCoreWinMLVersion>
<FoundryLocalCoreVersion Condition="'$(FoundryLocalCoreVersion)' == ''">1.0.0-rc2</FoundryLocalCoreVersion> </PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
Expand Down
8 changes: 3 additions & 5 deletions sdk/js/script/install-standard.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
const os = require('os');
const { NUGET_FEED, ORT_NIGHTLY_FEED, runInstall } = require('./install-utils.cjs');

const useNightly = process.env.npm_config_nightly === 'true';

const ARTIFACTS = [
{ name: 'Microsoft.AI.Foundry.Local.Core', version: '1.0.0-rc1', feed: ORT_NIGHTLY_FEED, nightly: useNightly },
{ name: os.platform() === 'linux' ? 'Microsoft.ML.OnnxRuntime.Gpu.Linux' : 'Microsoft.ML.OnnxRuntime.Foundry', version: '1.24.3', feed: NUGET_FEED, nightly: false },
{ name: 'Microsoft.ML.OnnxRuntimeGenAI.Foundry', version: '0.12.2', feed: NUGET_FEED, nightly: false },
{ name: 'Microsoft.AI.Foundry.Local.Core', version: '1.0.0-rc2', feed: ORT_NIGHTLY_FEED },
{ name: os.platform() === 'linux' ? 'Microsoft.ML.OnnxRuntime.Gpu.Linux' : 'Microsoft.ML.OnnxRuntime.Foundry', version: '1.24.4', feed: NUGET_FEED },
{ name: 'Microsoft.ML.OnnxRuntimeGenAI.Foundry', version: '0.13.0', feed: NUGET_FEED },
];

(async () => {
Expand Down
26 changes: 3 additions & 23 deletions sdk/js/script/install-utils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,9 @@ async function getBaseAddress(feedUrl) {
return baseAddress.endsWith('/') ? baseAddress : baseAddress + '/';
}

async function resolveLatestVersion(feedUrl, packageName) {
const baseAddress = await getBaseAddress(feedUrl);
const versionsUrl = `${baseAddress}${packageName.toLowerCase()}/index.json`;
const versionData = await downloadJson(versionsUrl);
const versions = versionData.versions || [];
if (versions.length === 0) throw new Error(`No versions found for ${packageName}`);
versions.sort((a, b) => b.localeCompare(a));
console.log(`[foundry-local] Latest version of ${packageName}: ${versions[0]}`);
return versions[0];
}

async function installPackage(artifact, tempDir) {
const pkgName = artifact.name;
let pkgVer = artifact.version;
if (artifact.nightly) {
console.log(` Resolving latest version for ${pkgName}...`);
pkgVer = await resolveLatestVersion(artifact.feed, pkgName);
}
const pkgVer = artifact.version;

const baseAddress = await getBaseAddress(artifact.feed);
const nameLower = pkgName.toLowerCase();
Expand Down Expand Up @@ -167,13 +152,8 @@ async function runInstall(artifacts) {
}

if (fs.existsSync(BIN_DIR) && REQUIRED_FILES.every(f => fs.existsSync(path.join(BIN_DIR, f)))) {
if (process.env.npm_config_nightly === 'true') {
console.log(`[foundry-local] Nightly requested. Forcing reinstall...`);
fs.rmSync(BIN_DIR, { recursive: true, force: true });
} else {
console.log(`[foundry-local] Native libraries already installed.`);
return;
}
console.log(`[foundry-local] Native libraries already installed.`);
return;
}

console.log(`[foundry-local] Installing native libraries for ${RID}...`);
Expand Down
8 changes: 3 additions & 5 deletions sdk/js/script/install-winml.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

const { NUGET_FEED, ORT_NIGHTLY_FEED, runInstall } = require('./install-utils.cjs');

const useNightly = process.env.npm_config_nightly === 'true';

const ARTIFACTS = [
{ name: 'Microsoft.AI.Foundry.Local.Core.WinML', version: '1.0.0-rc1', feed: ORT_NIGHTLY_FEED, nightly: useNightly },
{ name: 'Microsoft.ML.OnnxRuntime.Foundry', version: '1.23.2.3', feed: NUGET_FEED, nightly: false },
{ name: 'Microsoft.ML.OnnxRuntimeGenAI.WinML', version: '0.12.2', feed: NUGET_FEED, nightly: false },
{ name: 'Microsoft.AI.Foundry.Local.Core.WinML', version: '1.0.0-rc2', feed: ORT_NIGHTLY_FEED },
{ name: 'Microsoft.ML.OnnxRuntime.Foundry', version: '1.23.2.3', feed: NUGET_FEED },
{ name: 'Microsoft.ML.OnnxRuntimeGenAI.Foundry', version: '0.13.0', feed: NUGET_FEED },
];

(async () => {
Expand Down
11 changes: 8 additions & 3 deletions sdk/js/src/detail/coreInterop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ koffi.struct('ResponseBuffer', {
ErrorLength: 'int32_t',
});

const CallbackType = koffi.proto('void CallbackType(void *data, int32_t length, void *userData)');
const CallbackType = koffi.proto('int32_t CallbackType(void *data, int32_t length, void *userData)');

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down Expand Up @@ -139,8 +139,13 @@ export class CoreInterop {
koffi.encode(dataBuf, 'char', dataStr, dataBytes.length + 1);

const cb = koffi.register((data: any, length: number, userData: any) => {
const chunk = koffi.decode(data, 'char', length);
callback(chunk);
try {
const chunk = koffi.decode(data, 'char', length);
callback(chunk);
return 0; // continue
} catch {
return 1; // cancel on error
}
}, koffi.pointer(CallbackType));

return new Promise<string>((resolve, reject) => {
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/requirements-winml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ pydantic>=2.0.0
requests>=2.32.4
openai>=2.24.0
# WinML native binary packages from the ORT-Nightly PyPI feed.
foundry-local-core-winml==1.0.0-rc1
onnxruntime-core==1.24.3
onnxruntime-genai-core==0.12.1
foundry-local-core-winml==1.0.0-rc2
onnxruntime-core==1.23.2.3
onnxruntime-genai-core==0.13.0
8 changes: 5 additions & 3 deletions sdk/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ pydantic>=2.0.0
requests>=2.32.4
openai>=2.24.0
# Standard native binary packages from the ORT-Nightly PyPI feed.
foundry-local-core==1.0.0-rc1
onnxruntime-core==1.24.3
onnxruntime-genai-core==0.12.1
foundry-local-core==1.0.0-rc2
onnxruntime-core==1.24.4; sys_platform != "linux"
onnxruntime-gpu==1.24.4; sys_platform == "linux"
onnxruntime-genai-core==0.13.0; sys_platform != "linux"
onnxruntime-genai-cuda==0.13.0; sys_platform == "linux"
11 changes: 7 additions & 4 deletions sdk/python/src/detail/core_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ def callback(data_ptr, length, self_ptr):
data_bytes = ctypes.string_at(data_ptr, length)
data_str = data_bytes.decode('utf-8')
self._py_callback(data_str)
return 0 # continue
except Exception as e:
if self is not None and self.exception is None:
self.exception = e # keep the first only as they are likely all the same
return 1 # cancel on error

def __init__(self, py_callback: Callable[[str], None]):
self._py_callback = py_callback
Expand All @@ -103,8 +105,8 @@ class CoreInterop:
instance = None

# Callback function for native interop.
# This returns a string and its length, and an optional user provided object.
CALLBACK_TYPE = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p)
# Returns c_int: 0 = continue, 1 = cancel.
CALLBACK_TYPE = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p)

@staticmethod
def _initialize_native_libraries() -> 'NativeBinaryPaths':
Expand All @@ -129,8 +131,9 @@ def _initialize_native_libraries() -> 'NativeBinaryPaths':
logger.info("Native libraries found — Core: %s ORT: %s GenAI: %s",
paths.core, paths.ort, paths.genai)

# Create the onnxruntime.dll symlink on Linux/macOS if needed.
# create_ort_symlinks(paths)
# Create compatibility symlinks on Linux/macOS so Core can resolve
# ORT/GenAI names regardless of package layout.
create_ort_symlinks(paths)
os.environ["ORT_LIB_PATH"] = str(paths.ort) # For ORT-GENAI to find ORT dependency

if sys.platform.startswith("win"):
Expand Down
4 changes: 3 additions & 1 deletion sdk/python/src/detail/model_data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# --------------------------------------------------------------------------

from typing import Optional, List
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field

from enum import StrEnum

Expand Down Expand Up @@ -53,6 +53,8 @@ class ModelInfo(BaseModel):
Fields are populated from the JSON response of the ``get_model_list`` command.
"""

model_config = ConfigDict(protected_namespaces=())

id: str = Field(alias="id", description="Unique identifier of the model. Generally <name>:<version>")
name: str = Field(alias="name", description="Model variant name")
version: int = Field(alias="version")
Expand Down
Loading
Loading