IntelligentAI 0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package IntelligentAI --version 0.0.2
                    
NuGet\Install-Package IntelligentAI -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IntelligentAI" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IntelligentAI" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="IntelligentAI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IntelligentAI --version 0.0.2
                    
#r "nuget: IntelligentAI, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package IntelligentAI@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IntelligentAI&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=IntelligentAI&version=0.0.2
                    
Install as a Cake Tool

Code Setup

Getting Started

Using our dotnet package

To start using the Intelligent SDK from scratch, you first need to install the main Nuget package in the project you want to use the components. You can use the NuGet package manager in your IDE for that or use the following command when using a CLI:


dotnet add package IntelligentAI

Register Services

Add the following in Program.cs:


builder.Services.AddAiService(new AiOptions("intelligent api address"));

Quick Start

This is literally all you need in your services to use intelligent components.


private readonly IAiModelService _model;

public YourClass(IAiModelService model)
{
    _model = model;
}

Argument


var request = new AiArguments("杭州西湖哪里好玩?");

int model = 6;  // 编号为 6 代表阿里云在线 qwen-long 模型

var _cts = new CancellationTokenSource();

var promptId = "prompt10";

var replaces = new Dictionary<string, string>()
{
    ["正文"] = Content  // 提示词占位符替换
};

Text answer


var answer = await  _model.AnswerTextAsync(request, model, cancellationToken: _cts.Token);

Streaming answer


StringBuilder streamingContentBuilder = new StringBuilder();

string botAnswer;

// ReturnType: IAsyncEnumerable<string>
// Requirements: .net 8.0 or above
var stream = _model.AnswerStringsAsync(request, model, cancellationToken: _cts.Token);

// ContentType: text/event-stream
var stream = _model.AnswerStreamAsync(request, model, cancellationToken: _cts.Token);

await foreach (var message in stream)
{
    streamingContentBuilder.Append(message);

    // You can get the answer here
    botAnswer = streamingContentBuilder.ToString(); 
}

// Or you can get the full answer here
botAnswer = streamingContentBuilder.ToString(); 

Prompt answer


var answer = await _model.AnswerTextByPromptAsync(promptId, replaces, 6, cancellationToken);

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

- 新增了许可证
 - 更新了文档