forked from autogenhub/autogen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor project structure (autogenhub#14)
* refactor abstractions * refactor structure * refactor projects WIP * refactor WIP * refactoring WIP * fixes
- Loading branch information
1 parent
04ddb4b
commit ec84924
Showing
72 changed files
with
531 additions
and
434 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/libs/Elsa.SemanticKernel/Elsa.SemanticKernel.csproj.DotSettings
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using Microsoft.SemanticKernel; | ||
using Microsoft.SemanticKernel.Connectors.OpenAI; | ||
using Orleans.Runtime; | ||
|
||
namespace Microsoft.AI.Agents.Abstractions; | ||
|
||
public abstract class AiAgent<T> : Agent | ||
{ | ||
public AiAgent( | ||
[PersistentState("state", "messages")] IPersistentState<AgentState<T>> state) | ||
{ | ||
_state = state; | ||
} | ||
protected IPersistentState<AgentState<T>> _state; | ||
|
||
protected void AddToHistory(string message, ChatUserType userType) | ||
{ | ||
if (_state.State.History == null) _state.State.History = new List<ChatHistoryItem>(); | ||
_state.State.History.Add(new ChatHistoryItem | ||
{ | ||
Message = message, | ||
Order = _state.State.History.Count + 1, | ||
UserType = userType | ||
}); | ||
} | ||
|
||
protected string AppendChatHistory(string ask) | ||
{ | ||
AddToHistory(ask, ChatUserType.User); | ||
return string.Join("\n", _state.State.History.Select(message => $"{message.UserType}: {message.Message}")); | ||
} | ||
|
||
protected virtual async Task<string> CallFunction(string template, KernelArguments arguments, Kernel kernel, OpenAIPromptExecutionSettings? settings = null) | ||
{ | ||
var propmptSettings = (settings == null) ? new OpenAIPromptExecutionSettings { MaxTokens = 18000, Temperature = 0.8, TopP = 1 } | ||
: settings; | ||
var function = kernel.CreateFunctionFromPrompt(template, propmptSettings); | ||
var result = (await kernel.InvokeAsync(function, arguments)).ToString(); | ||
AddToHistory(result, ChatUserType.Agent); | ||
return result; | ||
} | ||
|
||
protected async Task<T> ShareContext() | ||
{ | ||
return _state.State.Data; | ||
} | ||
} | ||
|
||
[Serializable] | ||
public class ChatHistoryItem | ||
{ | ||
public string Message { get; set; } | ||
public ChatUserType UserType { get; set; } | ||
public int Order { get; set; } | ||
|
||
} | ||
|
||
public class AgentState<T> | ||
{ | ||
public List<ChatHistoryItem> History { get; set; } | ||
public T Data { get; set; } | ||
} | ||
|
||
public enum ChatUserType | ||
{ | ||
System, | ||
User, | ||
Agent | ||
} |
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,13 @@ | ||
namespace Microsoft.AI.Agents.Abstractions | ||
{ | ||
[GenerateSerializer] | ||
public class Event | ||
{ | ||
[Id(0)] | ||
public string Message { get; set; } | ||
[Id(1)] | ||
public Dictionary<string, string> Data { get; set; } | ||
[Id(2)] | ||
public string Type { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Orleans.Sdk" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Orleans.Runtime" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.SemanticKernel" Version="1.6.2" /> | ||
<PackageReference Include="Microsoft.Orleans.Streaming" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
src/libs/Microsoft.AI.DevTeam.Skills/Microsoft.AI.DevTeam.Skills.csproj
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.