Class OpenAIImageDescriptionCopilot
OpenAIImageDescriptionCopilot class
Provides image processing functionality for OpenAICopilot class. Example usage of creating an OpenAI client, configuration of ImageDescriptionCopilot options, and usage of the copilot to generate image descriptions and add descriptions to attached documents.
// 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>) | Initializes a new instance of the OpenAIImageDescriptionCopilot class. |
Properties
Methods
See Also