Class OpenAIImageDescriptionCopilot
OpenAIImageDescriptionCopilot class
为 OpenAICopilot 类提供图像处理功能。创建 OpenAI 客户端、配置 ImageDescriptionCopilot 选项的示例用法,以及使用 copilot 生成图像描述并将描述添加到附加文档中的用法。
// Create AI client.
var openAiClient = OpenAIClient
.CreateWithApiKey(ApiKey) // Create OpenAI client with the API key.
.WithProject("proj_RoywW1DLqDC89GoAW5ngoVN8") // Configure optional parameters.
.WithOrganization("org_123")
.Build(); // Build.
// Create copilot options.
var options = OpenAIImageDescriptionCopilotOptions
.Create() // Create options like this, or...
//.Create(options => { options.Model = OpenAIModels.Gpt35Turbo; }) // ...create using delegate.
.WithModel(OpenAIModels.Gpt35Turbo) // Configure other optional parameters.
.WithTemperature(0.5)
.WithTopP(1)
.WithDocument(new PdfDocument // Attach documents.
{
Name = "Another_Pdf_with_images",
Document = new Document(GetInputPath("Pdf_with_images_low_res_bw.pdf"))
})
.WithDocument(GetInputPath("Mona_liza.jpg")) // Attach images
.WithDocument(GetInputPath("Pdf_with_images.pdf")); // Attach document paths.
// Create copilot.
var copilot = AICopilotFactory.CreateImageDescriptionCopilot(openAiClient, options);
// Get Image descriptions.
List<ImageDescriptionResult> imageDescriptions = await copilot.GetImageDescriptionsAsync();
// Use extension method to add image descriptions to attached documents.
await copilot.AddPdfImageDescriptionsAsync("DocumentsOutputDirectory");
public class OpenAIImageDescriptionCopilot : IImageDescriptionCopilot
Constructors
Name | Description |
---|
OpenAIImageDescriptionCopilot(IOpenAIClient, IImageDescriptionCopilotOptions<OpenAIImageDescriptionCopilotOptions>) | 初始化 OpenAIImageDescriptionCopilot 类的新实例。 |
Properties
Methods
See Also