跳到正文
GitHub·· 5 天前AI 评分12

Soenneker.OpenHands.OpenApiClientUtil:OpenHands Cloud API 客户端工具库

soenneker/soenneker.openhands.openapiclientutil

AI 导读

Soenneker.OpenHands.OpenApiClientUtil 发布,为 OpenHands Cloud 提供已配置的 API 客户端,并在注册服务生命周期内复用。

正文

Provides a configured OpenHands Cloud API client and reuses it for the lifetime of the registered service.

Install

dotnet add package Soenneker.OpenHands.OpenApiClientUtil

Configuration

{
  "OpenHands": {
    "ApiKey": "your-api-key"
  }
}

Usage

using Soenneker.OpenHands.OpenApiClientUtil.Abstract;
using Soenneker.OpenHands.OpenApiClientUtil.Registrars;

services.AddOpenHandsOpenApiClientUtilAsSingleton();

IOpenHandsOpenApiClientUtil openHands = serviceProvider
    .GetRequiredService<IOpenHandsOpenApiClientUtil>();

var client = await openHands.Get(cancellationToken);
var conversations = await client.Api.V1.AppConversations.Search.GetAsync(request =>
{
    request.QueryParameters.Limit = 20;
}, cancellationToken);

Use AddOpenHandsOpenApiClientUtilAsScoped() when each application scope should have its own generated client wrapper. The underlying authenticated HTTP provider remains shared and is disposed by the service container at shutdown.

来源:GitHub · github.com