在unity3d中使用open ai时出现IHttpClientFactory不存在的错误如何解决?

问题描述 投票:0回答:1

错误出现在第38行 在这部分代码的最后一行:

public IHttpClientFactory HttpClientFactory { get; set; }

完整部分:

using OpenAI_API.Audio;
using OpenAI_API.Chat;
using OpenAI_API.Completions;
using OpenAI_API.Embedding;
using OpenAI_API.Files;
using OpenAI_API.Images;
using OpenAI_API.Models;
using OpenAI_API.Moderation;
using System.Net.Http;

namespace OpenAI_API
{
    /// <summary>
    /// Entry point to the OpenAPI API, handling auth and allowing access to the various API endpoints
    /// </summary>
    public class OpenAIAPI : IOpenAIAPI
    {
        /// <summary>
        /// Base url for OpenAI
        /// for OpenAI, should be "https://api.openai.com/{0}/{1}"
        /// for Azure, should be "https://(your-resource-name.openai.azure.com/openai/deployments/(deployment-id)/{1}?api-version={0}"
        /// </summary>
        public string ApiUrlFormat { get; set; } = "https://api.openai.com/{0}/{1}";

        /// <summary>
        /// Version of the Rest Api
        /// </summary>
        public string ApiVersion { get; set; } = "v1";

        /// <summary>
        /// The API authentication information to use for API calls
        /// </summary>
        public APIAuthentication Auth { get; set; }

        /// <summary>
        /// Optionally provide an IHttpClientFactory to create the client to send requests.
        /// </summary>
        public IHttpClientFactory HttpClientFactory { get; set; }

我将完整脚本放在链接中,因为它有点长:https://pastebin.com/mrmq72Pp

c# .net unity-game-engine http
1个回答
0
投票

接口

IHttpClientFactory
来自
Microsoft.Extensions.Http
,因此您需要包含此包参考。

© www.soinside.com 2019 - 2024. All rights reserved.