首页›.NET Blog›文章

Run local models in your .NET apps with Llama on Windows

Luis Quintanilla · 2026年11月23日

AI 摘要 AI 生成,可能有误

Llama on Windows 是一款由 Hugging Face 和 llama.cpp 团队打造的免费开源系统托盘应用,可让你查找、下载开源 AI 模型,并与在本地电脑上运行的模型进行对话。它管理着本地主机(localhost)上的一个 llama.cpp 服务器,该服务器提供与 OpenAI 兼容的 API,因此 .NET 应用可以使用熟悉的 OpenAI 客户端库以及 Microsoft.Extensions.AI 的 IChatClient 来调用本地模型,而无需任何 API 密钥。本文将逐步介绍如何安装 Llama、下载模型,以及构建一个支持流式响应和工具调用的基于文件的 .NET 11 聊天应用。

Running AI models locally lets you keep your prompts and responses on your PC, work offline after downloading a model, and experiment without paying per request. Getting started can take some setup: finding a model that fits your hardware, downloading it, and running a server your apps can call.

Llama on Windows takes care of that for you. It’s a tray app that helps you find, download, and chat with open models on your PC. Once a model is running, your .NET apps can use it too.

In this post, you’ll install Llama, download a model, and call it from a .NET 11 C# file-based app.

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 .NET Blog

Build a .NET decision agent with Microsoft Agent Framework and Foundry

AI 摘要The article walks through building a .NET agent that uses the Microsoft-Decision-1.1 decision model to route support tickets to the appropriate team, demonstrating that agents don't require conversational models to be useful. It shows how to implement the decision logic inside a Microsoft Agent Framework AIAgent, return structured results as typed C# records, and expose the agent through the Foundry Responses protocol. The same implementation can run locally with Azure CLI credentials or be hosted in Foundry using managed identity.

Introducing DocumentExtractionClient (preview): Extract documents in .NET

AI 摘要Microsoft has introduced a preview of DocumentExtractionClient in Microsoft.Extensions.DocumentExtraction, a unified .NET API that extracts structured content (headings, paragraphs, tables, figures, and sources) from PDFs, scans, images, and Office files. Starter providers in the .NET AI Community Toolkit—including PdfPig, vision language models via IChatClient, Azure Content Understanding, Azure AI Document Intelligence, and Mistral OCR—are interchangeable, so code can swap providers without rewrites, following the familiar IChatClient pattern with support for middleware and custom providers. Extracted documents can feed into Microsoft.Extensions.DataIngestion pipelines to power context engineering, agentic workflows, and retrieval-augmented generation (RAG), with single-file C# samples available in a GitHub repository.

AI is Changing the Cross-Platform Decision Matrix

AI 摘要The author ran an experiment using AI coding agents to rebuild the iOS and Android UIs of a .NET MAUI app with platform-specific UIs over a shared C# library, to assess how AI agents change the cross-platform technology decision. The agent-driven rewrite took under four hours of human time, and the platform UI versions outperformed .NET MAUI at runtime (roughly 50% faster startup on Android, 35% on iOS, and smaller packages), though adding a feature to two UIs cost about 1.4x the worker model time of the single MAUI version. The key finding is that AI agents make building a second UI cheap, but owning and verifying it still carries real costs—the coordinating agent consumed more model time than both implementation workers combined.

Introducing staged publishing on NuGet.org

AI 摘要NuGet.org has introduced staged publishing, a feature that lets package publishers upload packages privately for validation—such as malware scanning and signature checks—before an authorized maintainer explicitly promotes them to the public feed. Unlike unlisted packages, staged packages are completely unavailable to consumers, and publishers can organize related packages into staging groups for release-level review, with promotion requiring a signed-in authorized user with two-factor authentication. The feature is opt-in, supported in the .NET 11 RC2 SDK via a new stage push CLI command, and is recommended for security fixes awaiting coordinated disclosure, feature releases, and large updates, ideally combined with Trusted Publishing and staging-only credentials so compromised pipeline credentials cannot publish directly.

Announcing .NET 11

AI 摘要Microsoft has announced the release of .NET 11, a Standard Term Support release with two years of support, featuring improvements across C# 15 (including union types and closed hierarchies), ASP.NET Core, .NET MAUI, runtime performance, and SDK tooling. The release emphasizes AI-powered development with Microsoft.Extensions.AI, MCP server templates, and the Microsoft Agent Framework, alongside library enhancements such as Zstandard compression, expanded Process APIs, and new JSON capabilities. Developers can learn more at .NET Conf 2026, held November 10-13.