feat: 完成图片生成功能
This commit is contained in:
@@ -36,10 +36,32 @@ public static class GeminiGenerateContentAcquirer
|
||||
/// </summary>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetImageBase64(JsonElement response)
|
||||
public static string GetImagePrefixBase64(JsonElement response)
|
||||
{
|
||||
//todo
|
||||
//获取他的base64字符串
|
||||
return string.Empty;
|
||||
// 获取 candidates[0].content.parts[0].text
|
||||
var text = response.GetPath("candidates", 0, "content", "parts", 0, "text").GetString();
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// 解析 markdown 图片格式: 
|
||||
// 提取括号内的 data:image/xxx;base64,xxx 部分
|
||||
var startMarker = "(data:image/";
|
||||
var startIndex = text.IndexOf(startMarker);
|
||||
if (startIndex < 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// 从 "data:" 开始
|
||||
startIndex += 1; // 跳过 "("
|
||||
var endIndex = text.IndexOf(')', startIndex);
|
||||
if (endIndex < 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return text.Substring(startIndex, endIndex - startIndex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 发布状态枚举
|
||||
/// </summary>
|
||||
public enum PublishStatusEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 未发布
|
||||
/// </summary>
|
||||
Unpublished = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 已发布
|
||||
/// </summary>
|
||||
Published = 1
|
||||
}
|
||||
Reference in New Issue
Block a user