Class OpenAIChatCopilot
OpenAIChatCopilot sınıfı
AI modelleri aracılığıyla belgelerle etkileşimde bulunan bir sohbet yardımcı pilotunu temsil eder. OpenAI istemcisi oluşturma, seçenekleri yapılandırma ve kullanıcı sorguları ile etkileşimde bulunmak ve konuşma bağlamını yönetmek için ChatCopilot kullanma örneği.
// 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 = OpenAIChatCopilotOptions
.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("DocumentInputPath") // Attach documents using .WithDocument(s) methods allows to add text, pdf and paths to documents.
.WithContextBackupJsonPath("PathToContextBackup") // Supply context backup to resume the conversation session.
.WithRestoreContextFromBackup(true); // If set to true, the context
// Create summary copilot.
var chatCopilot = AICopilotFactory.CreateChatCopilot(openAiClient, options);
// Get response on a user query.
string copilotResponse1 = await chatCopilot.GetResponseAsync("user message");
// Get response on a list of queries.
string copilotResponse2 = await chatCopilot.GetResponseAsync(new List<string>
{
"message1",
"message2"
});
// Save summary as PDF document.
await chatCopilot.SaveResponseAsync("message1", "outputPath");
// Save summary with specified format.
await chatCopilot.SaveResponseAsync("message1", "outputPath", SaveFormat.DocX);
// Save summary as PDF document.
await chatCopilot.SaveResponseAsync(new List<string>
{
"message1",
"message2"
}, "outputPath");
// Save summary with specified format.
await chatCopilot.SaveResponseAsync(new List<string>
{
"message1",
"message2"
}, "outputPath", SaveFormat.DocX);
// Save the context.
await chatCopilot.SaveContextAsync("outputPath");
// Delete the context.
await chatCopilot.DeleteContextAsync();
public class OpenAIChatCopilot : IChatCopilot
Yapıcılar
İsim | Açıklama |
---|
OpenAIChatCopilot(IOpenAIClient, IChatCopilotOptions<OpenAIChatCopilotOptions>) | Belirtilen istemci ve seçeneklerle OpenAIChatCopilot sınıfının yeni bir örneğini başlatır. |
Özellikler
Yöntemler
İsim | Açıklama |
---|
DeleteContextAsync(CancellationToken?) | |
GetResponseAsync(List<string>, CancellationToken?) | |
GetResponseAsync(string, CancellationToken?) | |
SaveContextAsync(string, CancellationToken?) | |
SaveResponseAsync(List<string>, string, CancellationToken?) | |
SaveResponseAsync(string, string, CancellationToken?) | |
SaveResponseAsync(List<string>, string, SaveFormat, CancellationToken?) | |
SaveResponseAsync(string, string, SaveFormat, CancellationToken?) | |
Ayrıca Bakınız