-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c945ac
commit 2c5fa98
Showing
9 changed files
with
71 additions
and
22 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/Infrastructure/BotSharp.Abstraction/MLTasks/IChatCompletion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using BotSharp.Abstraction.Models; | ||
|
||
namespace BotSharp.Abstraction.MLTasks; | ||
|
||
public interface IChatCompletion | ||
{ | ||
Task<string> GetChatCompletionsAsync(List<RoleDialogModel> conversations); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Plugins/BotSharp.Plugin.AzureOpenAI/Services/ChatCompletionService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Azure.AI.OpenAI; | ||
using BotSharp.Abstraction.Infrastructures.ContentTransfers; | ||
using BotSharp.Abstraction.Infrastructures.ContentTransmitters; | ||
using BotSharp.Abstraction.MLTasks; | ||
using BotSharp.Abstraction.Models; | ||
using System.Threading.Tasks; | ||
|
||
namespace BotSharp.Plugin.AzureOpenAI.Services; | ||
|
||
public class ChatCompletionService : IServiceZone | ||
{ | ||
private readonly IChatCompletion _chatCompletion; | ||
|
||
public ChatCompletionService(IChatCompletion chatCompletion) | ||
{ | ||
_chatCompletion = chatCompletion; | ||
} | ||
|
||
public async Task Serving(ContentContainer content) | ||
{ | ||
var output = await _chatCompletion.GetChatCompletionsAsync(content.Conversations); | ||
|
||
content.Output = new RoleDialogModel | ||
{ | ||
Role = ChatRole.Assistant.ToString(), | ||
Content = output | ||
}; | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
...Plugin.AzureOpenAI/AzureOpenAiSettings.cs → ...ureOpenAI/Settings/AzureOpenAiSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
namespace BotSharp.Platform.AzureAi; | ||
namespace BotSharp.Plugin.AzureOpenAI.Settings; | ||
|
||
public class AzureOpenAiSettings | ||
{ | ||
public string ApiKey { get; set; } = string.Empty; | ||
public string Endpoint { get; set; } = string.Empty; | ||
public string DeploymentName { get; set; } = string.Empty; | ||
public DeploymentModelSetting DeploymentModel { get; set; } | ||
= new DeploymentModelSetting(); | ||
public string InstructionFile { get; set; } = string.Empty; | ||
public string ChatSampleFile { get; set; } = string.Empty; | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Plugins/BotSharp.Plugin.AzureOpenAI/Settings/DeploymentModelSetting.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace BotSharp.Plugin.AzureOpenAI.Settings; | ||
|
||
public class DeploymentModelSetting | ||
{ | ||
public string? ChatCompletionModel { get; set; } | ||
public string? TextCompletionModel { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters