Skip to content
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 @@ -4,4 +4,4 @@
"packages": {
"Aspire.Hosting.GitHub.Models": ""
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1E14FFBC022E165AF28594D89038A62157C344105538488ECA98C041C3422D03
C13880F095DBA862665782C34D611AD1BB6B65C79C0D482A6EB5C7CACE3CDB53

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,27 @@ export function registerCallback<TResult = void>(

if (argArray.length > 0) {
// Spread positional arguments to callback
return await callback(...argArray);
const result = await callback(...argArray);
// DTO writeback protocol: when a void callback returns undefined, we
// return the original args object so the .NET host can detect property
// mutations made by the callback and apply them back to the original
// C# DTO objects. DTO args are plain JS objects (not Handle wrappers),
// so any property changes the callback made are reflected in args.
//
// Non-void callbacks (result !== undefined) return their actual result.
// The .NET side only activates writeback for void delegates whose
// parameters include [AspireDto] types — all other cases discard the
// returned args object, so the extra wire payload is harmless.
//
// IMPORTANT: callbacks that intentionally return undefined will also
// trigger this path. For non-void delegate types, the C# proxy uses
// a result-unmarshalling path (not writeback), so returning args will
// cause an unmarshal error. Void callbacks should never return a
// meaningful value; non-void callbacks should always return one.
return result !== undefined ? result : args;
}

// No positional params found - call with no args
// No positional params found — nothing to write back
return await callback();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
import { createBuilder } from './.modules/aspire.js';
import { createBuilder, GitHubModelName } from './.modules/aspire.js';

const builder = await createBuilder();

const githubModel = builder.addGitHubModel('validation-model');
githubModel.withApiKey({ secret: true });
await builder.build().run();
// 1) addGitHubModel — using the GitHubModelName enum
const githubModel = await builder.addGitHubModel("chat", GitHubModelName.OpenAIGpt4o);

// 2) addGitHubModel — with organization parameter
const orgParam = await builder.addParameter("gh-org");
const githubModelWithOrg = await builder.addGitHubModel("chat-org", GitHubModelName.OpenAIGpt4oMini, { organization: orgParam });

// 3) addGitHubModelById — using a model identifier string for models not in the enum
const customModel = await builder.addGitHubModelById("custom-chat", "custom-vendor/custom-model");

// 3) withApiKey — configure a custom API key parameter
const apiKey = await builder.addParameter("gh-api-key", { secret: true });
await githubModel.withApiKey(apiKey);

// 4) enableHealthCheck — integration-specific no-args health check
await githubModel.enableHealthCheck();

// 5) withReference — pass GitHubModelResource as a connection string source to a container
const container = await builder.addContainer("my-service", "mcr.microsoft.com/dotnet/samples:latest");
await container.withReference(githubModel);

// 6) withReference — pass GitHubModelResource as a source to another container with custom connection name
await container.withReference(githubModelWithOrg, { connectionName: "github-model-org" });

const app = await builder.build();
await app.run();
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"outDir": "./dist",
"rootDir": "."
},
"include": ["apphost.ts", ".modules/**/*.ts"],
"include": ["apphost.ts", ".modules/**/*.ts", ".modules/**/*.d.ts"],
"exclude": ["node_modules"]
}
272 changes: 272 additions & 0 deletions src/Aspire.Hosting.GitHub.Models/GitHubModel.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,276 @@ public static partial class XAI
/// </summary>
public static readonly GitHubModel Grok3Mini = new() { Id = "xai/grok-3-mini" };
}

/// <summary>
/// Gets the model identifier string for the specified <see cref="GitHubModelName"/>.
/// </summary>
internal static string GetModelId(GitHubModelName name) => name switch
{
GitHubModelName.AI21Jamba15Large => "ai21-labs/ai21-jamba-1.5-large",
GitHubModelName.CohereCommandA => "cohere/cohere-command-a",
GitHubModelName.CohereCommandR082024 => "cohere/cohere-command-r-08-2024",
GitHubModelName.CohereCommandRPlus082024 => "cohere/cohere-command-r-plus-08-2024",
GitHubModelName.DeepSeekR1 => "deepseek/deepseek-r1",
GitHubModelName.DeepSeekR10528 => "deepseek/deepseek-r1-0528",
GitHubModelName.DeepSeekV30324 => "deepseek/deepseek-v3-0324",
GitHubModelName.Llama4Maverick17B128EInstructFP8 => "meta/llama-4-maverick-17b-128e-instruct-fp8",
GitHubModelName.Llama4Scout17B16EInstruct => "meta/llama-4-scout-17b-16e-instruct",
GitHubModelName.Llama3211BVisionInstruct => "meta/llama-3.2-11b-vision-instruct",
GitHubModelName.Llama3290BVisionInstruct => "meta/llama-3.2-90b-vision-instruct",
GitHubModelName.Llama3370BInstruct => "meta/llama-3.3-70b-instruct",
GitHubModelName.MetaLlama31405BInstruct => "meta/meta-llama-3.1-405b-instruct",
GitHubModelName.MetaLlama318BInstruct => "meta/meta-llama-3.1-8b-instruct",
GitHubModelName.MaiDSR1 => "microsoft/mai-ds-r1",
GitHubModelName.Phi4 => "microsoft/phi-4",
GitHubModelName.Phi4MiniInstruct => "microsoft/phi-4-mini-instruct",
GitHubModelName.Phi4MiniReasoning => "microsoft/phi-4-mini-reasoning",
GitHubModelName.Phi4MultimodalInstruct => "microsoft/phi-4-multimodal-instruct",
GitHubModelName.Phi4Reasoning => "microsoft/phi-4-reasoning",
GitHubModelName.Codestral2501 => "mistral-ai/codestral-2501",
GitHubModelName.Ministral3B => "mistral-ai/ministral-3b",
GitHubModelName.MistralMedium32505 => "mistral-ai/mistral-medium-2505",
GitHubModelName.MistralSmall31 => "mistral-ai/mistral-small-2503",
GitHubModelName.OpenAIGpt41 => "openai/gpt-4.1",
GitHubModelName.OpenAIGpt41Mini => "openai/gpt-4.1-mini",
GitHubModelName.OpenAIGpt41Nano => "openai/gpt-4.1-nano",
GitHubModelName.OpenAIGpt4o => "openai/gpt-4o",
GitHubModelName.OpenAIGpt4oMini => "openai/gpt-4o-mini",
GitHubModelName.OpenAIGpt5 => "openai/gpt-5",
GitHubModelName.OpenAIGpt5ChatPreview => "openai/gpt-5-chat",
GitHubModelName.OpenAIGpt5Mini => "openai/gpt-5-mini",
GitHubModelName.OpenAIGpt5Nano => "openai/gpt-5-nano",
GitHubModelName.OpenAIO1 => "openai/o1",
GitHubModelName.OpenAIO1Mini => "openai/o1-mini",
GitHubModelName.OpenAIO1Preview => "openai/o1-preview",
GitHubModelName.OpenAIO3 => "openai/o3",
GitHubModelName.OpenAIO3Mini => "openai/o3-mini",
GitHubModelName.OpenAIO4Mini => "openai/o4-mini",
GitHubModelName.OpenAITextEmbedding3Large => "openai/text-embedding-3-large",
GitHubModelName.OpenAITextEmbedding3Small => "openai/text-embedding-3-small",
GitHubModelName.Grok3 => "xai/grok-3",
GitHubModelName.Grok3Mini => "xai/grok-3-mini",
_ => throw new System.ArgumentOutOfRangeException(nameof(name), name, "Unknown GitHub model name.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an overload that takes a string model name as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, addGitHubModelById(name, id)

};
}

/// <summary>
/// Enumerates known GitHub model names for polyglot app host support.
/// </summary>
internal enum GitHubModelName
{
/// <summary>
/// A 398B parameters (94B active) multilingual model, offering a 256K long context window, function calling, structured output, and grounded generation.
/// </summary>
AI21Jamba15Large,

/// <summary>
/// Command A is a highly efficient generative model that excels at agentic and multilingual use cases.
/// </summary>
CohereCommandA,

/// <summary>
/// Command R is a scalable generative model targeting RAG and Tool Use to enable production-scale AI for enterprise.
/// </summary>
CohereCommandR082024,

/// <summary>
/// Command R+ is a state-of-the-art RAG-optimized model designed to tackle enterprise-grade workloads.
/// </summary>
CohereCommandRPlus082024,

/// <summary>
/// DeepSeek-R1 excels at reasoning tasks using a step-by-step training process, such as language, scientific reasoning, and coding tasks.
/// </summary>
DeepSeekR1,

/// <summary>
/// The DeepSeek R1 0528 model has improved reasoning capabilities, this version also offers a reduced hallucination rate, enhanced support for function calling, and better experience for vibe coding.
/// </summary>
DeepSeekR10528,

/// <summary>
/// DeepSeek-V3-0324 demonstrates notable improvements over its predecessor, DeepSeek-V3, in several key aspects, including enhanced reasoning, improved function calling, and superior code generation capabilities.
/// </summary>
DeepSeekV30324,

/// <summary>
/// Llama 4 Maverick 17B 128E Instruct FP8 is great at precise image understanding and creative writing, offering high quality at a lower price compared to Llama 3.3 70B
/// </summary>
Llama4Maverick17B128EInstructFP8,

/// <summary>
/// Llama 4 Scout 17B 16E Instruct is great at multi-document summarization, parsing extensive user activity for personalized tasks, and reasoning over vast codebases.
/// </summary>
Llama4Scout17B16EInstruct,

/// <summary>
/// Excels in image reasoning capabilities on high-res images for visual understanding apps.
/// </summary>
Llama3211BVisionInstruct,

/// <summary>
/// Advanced image reasoning capabilities for visual understanding agentic apps.
/// </summary>
Llama3290BVisionInstruct,

/// <summary>
/// Llama 3.3 70B Instruct offers enhanced reasoning, math, and instruction following with performance comparable to Llama 3.1 405B.
/// </summary>
Llama3370BInstruct,

/// <summary>
/// The Llama 3.1 instruction tuned text only models are optimized for multilingual dialogue use cases and outperform many of the available open source and closed chat models on common industry benchmarks.
/// </summary>
MetaLlama31405BInstruct,

/// <summary>
/// The Llama 3.1 instruction tuned text only models are optimized for multilingual dialogue use cases and outperform many of the available open source and closed chat models on common industry benchmarks.
/// </summary>
MetaLlama318BInstruct,

/// <summary>
/// MAI-DS-R1 is a DeepSeek-R1 reasoning model that has been post-trained by the Microsoft AI team to fill in information gaps in the previous version of the model and improve its harm protections while maintaining R1 reasoning capabilities.
/// </summary>
MaiDSR1,

/// <summary>
/// Phi-4 14B, a highly capable model for low latency scenarios.
/// </summary>
Phi4,

/// <summary>
/// 3.8B parameters Small Language Model outperforming larger models in reasoning, math, coding, and function-calling
/// </summary>
Phi4MiniInstruct,

/// <summary>
/// Lightweight math reasoning model optimized for multi-step problem solving
/// </summary>
Phi4MiniReasoning,

/// <summary>
/// First small multimodal model to have 3 modality inputs (text, audio, image), excelling in quality and efficiency
/// </summary>
Phi4MultimodalInstruct,

/// <summary>
/// State-of-the-art open-weight reasoning model.
/// </summary>
Phi4Reasoning,

/// <summary>
/// Codestral 25.01 by Mistral AI is designed for code generation, supporting 80+ programming languages, and optimized for tasks like code completion and fill-in-the-middle
/// </summary>
Codestral2501,

/// <summary>
/// Ministral 3B is a state-of-the-art Small Language Model (SLM) optimized for edge computing and on-device applications. As it is designed for low-latency and compute-efficient inference, it it also the perfect model for standard GenAI applications that have
/// </summary>
Ministral3B,

/// <summary>
/// Mistral Medium 3 is an advanced Large Language Model (LLM) with state-of-the-art reasoning, knowledge, coding and vision capabilities.
/// </summary>
MistralMedium32505,

/// <summary>
/// Enhanced Mistral Small 3 with multimodal capabilities and a 128k context length.
/// </summary>
MistralSmall31,

/// <summary>
/// gpt-4.1 outperforms gpt-4o across the board, with major gains in coding, instruction following, and long-context understanding
/// </summary>
OpenAIGpt41,

/// <summary>
/// gpt-4.1-mini outperform gpt-4o-mini across the board, with major gains in coding, instruction following, and long-context handling
/// </summary>
OpenAIGpt41Mini,

/// <summary>
/// gpt-4.1-nano provides gains in coding, instruction following, and long-context handling along with lower latency and cost
/// </summary>
OpenAIGpt41Nano,

/// <summary>
/// OpenAI&apos;s most advanced multimodal model in the gpt-4o family. Can handle both text and image inputs.
/// </summary>
OpenAIGpt4o,

/// <summary>
/// An affordable, efficient AI solution for diverse text and image tasks.
/// </summary>
OpenAIGpt4oMini,

/// <summary>
/// gpt-5 is designed for logic-heavy and multi-step tasks.
/// </summary>
OpenAIGpt5,

/// <summary>
/// gpt-5-chat (preview) is an advanced, natural, multimodal, and context-aware conversations for enterprise applications.
/// </summary>
OpenAIGpt5ChatPreview,

/// <summary>
/// gpt-5-mini is a lightweight version for cost-sensitive applications.
/// </summary>
OpenAIGpt5Mini,

/// <summary>
/// gpt-5-nano is optimized for speed, ideal for applications requiring low latency.
/// </summary>
OpenAIGpt5Nano,

/// <summary>
/// Focused on advanced reasoning and solving complex problems, including math and science tasks. Ideal for applications that require deep contextual understanding and agentic workflows.
/// </summary>
OpenAIO1,

/// <summary>
/// Smaller, faster, and 80% cheaper than o1-preview, performs well at code generation and small context operations.
/// </summary>
OpenAIO1Mini,

/// <summary>
/// Focused on advanced reasoning and solving complex problems, including math and science tasks. Ideal for applications that require deep contextual understanding and agentic workflows.
/// </summary>
OpenAIO1Preview,

/// <summary>
/// o3 includes significant improvements on quality and safety while supporting the existing features of o1 and delivering comparable or better performance.
/// </summary>
OpenAIO3,

/// <summary>
/// o3-mini includes the o1 features with significant cost-efficiencies for scenarios requiring high performance.
/// </summary>
OpenAIO3Mini,

/// <summary>
/// o4-mini includes significant improvements on quality and safety while supporting the existing features of o3-mini and delivering comparable or better performance.
/// </summary>
OpenAIO4Mini,

/// <summary>
/// Text-embedding-3 series models are the latest and most capable embedding model from OpenAI.
/// </summary>
OpenAITextEmbedding3Large,

/// <summary>
/// Text-embedding-3 series models are the latest and most capable embedding model from OpenAI.
/// </summary>
OpenAITextEmbedding3Small,

/// <summary>
/// Grok 3 is xAI&apos;s debut model, pretrained by Colossus at supermassive scale to excel in specialized domains like finance, healthcare, and the law.
/// </summary>
Grok3,

/// <summary>
/// Grok 3 Mini is a lightweight model that thinks before responding. Trained on mathematic and scientific problems, it is great for logic-based tasks.
/// </summary>
Grok3Mini,
}
Loading
Loading