using AllInAI.Sharp.API.Dto;using AllInAI.Sharp.API.Enums;using AllInAI.Sharp.API.IService;using AllInAI.Sharp.API.Req;using AllInAI.Sharp.API.Res;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace AllInAI.Sharp.API.Service {public class ImgService {private readonly HttpClient _httpClient;private readonly IImageService _imageService;public ImgService(AuthOption option, HttpClient? httpClient = null) {if (httpClient == null) {_httpClient = new HttpClient();}else {_httpClient = httpClient;}_httpClient.BaseAddress = new Uri(option.BaseUrl);switch (option.AIType) {case AITypeEnum.Baidu:accessToken = option.Key;_imageService = new BaiduImgService();break;case AITypeEnum.SD:_imageService = new SDImgService();break;case AITypeEnum.MJ:_imageService = new MJImgService();break;case AITypeEnum.OpenAi:default:_imageService = new OpenAIImgService();_httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {option.Key}");break;}}private string? accessToken;public async Task<ImgRes> Txt2Img(Txt2ImgReq req) {return await _imageService.Txt2Img(_httpClient, req, accessToken);}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。