-
Notifications
You must be signed in to change notification settings - Fork 3
update marc-romu/chat from dev #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9ba9109
feat(security): enhanced security by signing providers and verifying …
marc-romu 720e62a
docs: update version badge for dev
actions-user 83736bf
docs: update version badge for dev to 0.3.0-dev.250423 (#175)
marc-romu 3b64d41
fix(mistralai): MistralAI provider not loading tools
marc-romu 8328e9e
chore(aiutils): adding debug logs to getresponse
marc-romu 458da27
feat(providers): validation of signature algorithm
marc-romu 2f9c264
feat(providers): verify strong name and authenticode before loading p…
marc-romu 3398aba
ci(tests): added multiple testing units
marc-romu 9eede00
reorganization
marc-romu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,28 @@ | ||
| name: .NET CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: windows-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v3 | ||
| with: | ||
| dotnet-version: '7.0.x' | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore SmartHopper.sln | ||
|
|
||
| - name: Build solution | ||
| run: dotnet build --no-restore --configuration Release SmartHopper.sln | ||
|
|
||
| - name: Run all tests | ||
| run: dotnet test --no-build --configuration Release --results-directory TestResults | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
src/SmartHopper.Components.Test/SmartHopper.Components.Test.csproj
This file contains hidden or 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 hidden or 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 hidden or 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,89 @@ | ||
| using System; | ||
| using System.Reflection; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using Newtonsoft.Json.Linq; | ||
| using Xunit; | ||
| using SmartHopper.Config.Managers; | ||
| using SmartHopper.Config.Models; | ||
|
|
||
| namespace SmartHopper.Config.Tests | ||
| { | ||
| public class AIToolManagerTests | ||
| { | ||
| private void ResetManager() | ||
| { | ||
| var managerType = typeof(AIToolManager); | ||
| var toolsField = managerType.GetField("_tools", BindingFlags.NonPublic | BindingFlags.Static); | ||
| var discoveredField = managerType.GetField("_toolsDiscovered", BindingFlags.NonPublic | BindingFlags.Static); | ||
| var toolsDict = (Dictionary<string, AITool>)toolsField.GetValue(null); | ||
| toolsDict.Clear(); | ||
| discoveredField.SetValue(null, false); | ||
| } | ||
|
|
||
| #if NET7_WINDOWS | ||
| [Fact(DisplayName = "RegisterTool_ShouldAddTool [Windows]")] | ||
| #else | ||
| [Fact(DisplayName = "RegisterTool_ShouldAddTool [Core]")] | ||
| #endif | ||
| public void RegisterTool_ShouldAddTool() | ||
| { | ||
| ResetManager(); | ||
| var tool = new AITool("TestTool", "Test Description", "{}", _ => Task.FromResult((object)"dummy")); | ||
| AIToolManager.RegisterTool(tool); | ||
| var tools = AIToolManager.GetTools(); | ||
| Assert.Contains("TestTool", tools.Keys); | ||
| Assert.Equal("Test Description", tools["TestTool"].Description); | ||
| } | ||
|
|
||
| #if NET7_WINDOWS | ||
| [Fact(DisplayName = "ExecuteTool_ShouldReturnError_WhenToolNotFound [Windows]")] | ||
| #else | ||
| [Fact(DisplayName = "ExecuteTool_ShouldReturnError_WhenToolNotFound [Core]")] | ||
| #endif | ||
| public async Task ExecuteTool_ShouldReturnError_WhenToolNotFound() | ||
| { | ||
| ResetManager(); | ||
| var result = await AIToolManager.ExecuteTool("UnknownTool", new JObject(), null); | ||
| dynamic dyn = result; | ||
| Assert.False(dyn.success); | ||
| Assert.Contains("UnknownTool", (string)dyn.error); | ||
| } | ||
|
|
||
| #if NET7_WINDOWS | ||
| [Fact(DisplayName = "ExecuteTool_ShouldExecuteRegisteredTool_WithMergedParameters [Windows]")] | ||
| #else | ||
| [Fact(DisplayName = "ExecuteTool_ShouldExecuteRegisteredTool_WithMergedParameters [Core]")] | ||
| #endif | ||
| public async Task ExecuteTool_ShouldExecuteRegisteredTool_WithMergedParameters() | ||
| { | ||
| ResetManager(); | ||
| JObject captured = null; | ||
| var tool = new AITool("Compute", "Computes value", "{}", p => | ||
| { | ||
| captured = p; | ||
| int value = p["value"].Value<int>(); | ||
| return Task.FromResult((object)(value * 2)); | ||
| }); | ||
| AIToolManager.RegisterTool(tool); | ||
| var parameters = new JObject { ["value"] = 10 }; | ||
| var extra = new JObject { ["extra"] = 5 }; | ||
| var result = await AIToolManager.ExecuteTool("Compute", (JObject)parameters.DeepClone(), extra); | ||
| Assert.IsType<int>(result); | ||
| Assert.Equal(20, (int)result); | ||
| Assert.Equal(5, captured["extra"].Value<int>()); | ||
| } | ||
|
|
||
| #if NET7_WINDOWS | ||
| [Fact(DisplayName = "GetTools_ShouldBeEmpty_WhenNoToolsRegistered [Windows]")] | ||
| #else | ||
| [Fact(DisplayName = "GetTools_ShouldBeEmpty_WhenNoToolsRegistered [Core]")] | ||
| #endif | ||
| public void GetTools_ShouldBeEmpty_WhenNoToolsRegistered() | ||
| { | ||
| ResetManager(); | ||
| var tools = AIToolManager.GetTools(); | ||
| Assert.Empty(tools); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium