这是关于使用chatGPT模型创建助手。我使用的是Azure.AI.OpenAI.Assistants SDK。
在尝试使用以下代码创建助手时,报告OpenAI Retrieval V1工具不被支持,建议使用更先进的v2 file_search工具。
代码片段:
AssistantCreationOptions aco = new AssistantCreationOptions(modelName);aco.Tools.Add(new RetrievalToolDefinition());aco.FileIds.AddRange(fileIds); // 这是用户上传的文件列表,即框架详细信息文件aco.Instructions = "在10行内总结框架详情";Assistant assistant = await client?.CreateAssistantAsync(aco);
具体错误如下
Azure OpenAI Retrieval v1 tool is not supported in favor of the more advanced v2 file_search tool. Please use \`file_search\` in the v2 api.
我需要知道如何使用file_search选项
回答:
您需要使用Azure.AI.OpenAI
Nuget包的最新版本(撰写此回答时为2.1.0-beta.1
)。
然后,您可以创建一个AzureOpenAIClient
的新实例。使用这个,您可以使用最新版本的助手API。
以下是创建助手的样本代码:
var client = new AzureOpenAIClient(new Uri("endpoint"), new DefaultAzureCredential());var assistant = (await client.GetAssistantClient().CreateAssistantAsync(_chatCompletionAIConnectionSettings.DeploymentId, new AssistantCreationOptions() { Name = assistantName, Tools = { ToolDefinition.CreateFileSearch(), ToolDefinition.CreateCodeInterpreter() }, ToolResources = { FileSearch = new FileSearchToolResources() { NewVectorStores = { new VectorStoreCreationHelper("list of file ids")} } }, Instructions = "您是一个有帮助的助手,可以根据附件的文档回答用户查询。 " })).Value;