diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorChatCompletionsRequest.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorChatCompletionsRequest.cs index 2a906836..be52fb6a 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorChatCompletionsRequest.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorChatCompletionsRequest.cs @@ -28,64 +28,7 @@ public class ThorChatCompletionsRequest /// [JsonPropertyName("messages")] public List? Messages { get; set; } - - /// - /// 兼容-代码补全 - /// - [JsonPropertyName("suffix")] - public string? Suffix { get; set; } - - /// - /// 兼容-代码补全 - /// - [JsonPropertyName("prompt")] - public string? Prompt { get; set; } - - private const string CodeCompletionPrompt = """ - You are a code modification assistant. Your task is to modify the provided code based on the user's instructions. - - Rules: - 1. Return only the modified code, with no additional text or explanations. - 2. The first character of your response must be the first character of the code. - 3. The last character of your response must be the last character of the code. - 4. NEVER use triple backticks (```) or any other markdown formatting in your response. - 5. Do not use any code block indicators, syntax highlighting markers, or any other formatting characters. - 6. Present the code exactly as it would appear in a plain text editor, preserving all whitespace, indentation, and line breaks. - 7. Maintain the original code structure and only make changes as specified by the user's instructions. - 8. Ensure that the modified code is syntactically and semantically correct for the given programming language. - 9. Use consistent indentation and follow language-specific style guidelines. - 10. If the user's request cannot be translated into code changes, respond only with the word NULL (without quotes or any formatting). - 11. Do not include any comments or explanations within the code unless specifically requested. - 12. Assume that any necessary dependencies or libraries are already imported or available. - - IMPORTANT: Your response must NEVER begin or end with triple backticks, single backticks, or any other formatting characters. - - The relevant context before the current editing content is: {0}. - After the current editing content is: {1}. - """; - - /// - /// 兼容代码补全 - /// - public void CompatibleCodeCompletion() - { - if (Messages is null || !Messages.Any()) - { - //兼容代码补全模式,Prompt为当前代码前内容,Suffix为当前代码后内容 - Messages = new List() - { - new ThorChatMessage - { - Role = "system", - Content = string.Format(CodeCompletionPrompt, Prompt, Suffix) - } - }; - } - - Suffix = null; - Prompt = null; - } - + /// /// 模型唯一编码值,如 gpt-4,gpt-3.5-turbo,moonshot-v1-8k,看底层具体平台定义 /// diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorChatMessage.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorChatMessage.cs index b4afa44e..2de161ed 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorChatMessage.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorChatMessage.cs @@ -51,16 +51,17 @@ public class ThorChatMessage /// /// 发出的消息内容计算,用于json序列号和反序列化,Content 和 Contents 不能同时赋值,只能二选一 + /// 如果是工具调用,还真可能为空 /// [JsonPropertyName("content")] - public object ContentCalculated + public object? ContentCalculated { get { - if (Content is not null && Contents is not null) - { - throw new ValidationException("Messages 中 Content 和 Contents 字段不能同时有值"); - } + // if (Content is not null && Contents is not null) + // { + // throw new ValidationException("Messages 中 Content 和 Contents 字段不能同时有值"); + // } if (Content is not null) { diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorToolFunctionDefinition.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorToolFunctionDefinition.cs index ff5d32c9..385cc575 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorToolFunctionDefinition.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorToolFunctionDefinition.cs @@ -30,5 +30,5 @@ public class ThorToolFunctionDefinition /// documentation about the format. /// [JsonPropertyName("parameters")] - public ThorToolFunctionPropertyDefinition Parameters { get; set; } + public ThorToolFunctionPropertyDefinition? Parameters { get; set; } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorToolFunctionPropertyDefinition.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorToolFunctionPropertyDefinition.cs index b8a34e59..48c87d2d 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorToolFunctionPropertyDefinition.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/ThorToolFunctionPropertyDefinition.cs @@ -55,14 +55,14 @@ public class ThorToolFunctionPropertyDefinition /// 必填的。函数参数对象类型。默认值为“object”。 /// [JsonPropertyName("type")] - public string Type { get; set; } = "object"; + public object Type { get; set; } = "object"; /// /// 可选。“函数参数”列表,作为从参数名称映射的字典 /// 对于描述类型的对象,可能还有可能的枚举值等等。 /// [JsonPropertyName("properties")] - public IDictionary? Properties { get; set; } + public IDictionary? Properties { get; set; } /// /// 可选。列出必需的“function arguments”列表。 diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/YiFrameworkAiHubDomainModule.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/YiFrameworkAiHubDomainModule.cs index 31288d35..b98308c6 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/YiFrameworkAiHubDomainModule.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/YiFrameworkAiHubDomainModule.cs @@ -48,8 +48,6 @@ namespace Yi.Framework.AiHub.Domain //ai模型特殊性兼容处理 Configure(options => { - options.Handles.add(request => { request.CompatibleCodeCompletion(); }); - options.Handles.Add(request => { if (request.Model == "o1")