Skip to content

Commit a748341

Browse files
init commit for phi silica agent
1 parent 3776879 commit a748341

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

build.psm1

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function Start-Build
2020
[string] $Runtime = [NullString]::Value,
2121

2222
[Parameter()]
23-
[ValidateSet('openai-gpt', 'msaz', 'interpreter', 'ollama')]
23+
[ValidateSet('openai-gpt', 'msaz', 'interpreter', 'ollama', 'phisilica')]
2424
[string[]] $AgentToInclude,
2525

2626
[Parameter()]
@@ -69,6 +69,7 @@ function Start-Build
6969
$msaz_dir = Join-Path $agent_dir "Microsoft.Azure.Agent"
7070
$interpreter_agent_dir = Join-Path $agent_dir "AIShell.Interpreter.Agent"
7171
$ollama_agent_dir = Join-Path $agent_dir "AIShell.Ollama.Agent"
72+
$phisilica_agent_dir = Join-Path $agent_dir "AIShell.PhiSilica.Agent"
7273

7374
$config = $Configuration.ToLower()
7475
$out_dir = Join-Path $PSScriptRoot "out"
@@ -79,6 +80,7 @@ function Start-Build
7980
$msaz_out_dir = Join-Path $app_out_dir "agents" "Microsoft.Azure.Agent"
8081
$interpreter_out_dir = Join-Path $app_out_dir "agents" "AIShell.Interpreter.Agent"
8182
$ollama_out_dir = Join-Path $app_out_dir "agents" "AIShell.Ollama.Agent"
83+
$phisilica_out_dir = Join-Path $app_out_dir "agents" "AIShell.PhiSilica.Agent"
8284

8385
if ($Clean) {
8486
if (Test-Path $out_dir) {
@@ -152,6 +154,12 @@ function Start-Build
152154
dotnet publish $ollama_csproj -c $Configuration -o $ollama_out_dir
153155
}
154156

157+
if ($LASTEXITCODE -eq 0 -and $AgentToInclude -contains 'phisilica') {
158+
Write-Host "`n[Build the PhiSilica agent ...]`n" -ForegroundColor Green
159+
$phisilica_csproj = GetProjectFile $phisilica_agent_dir
160+
dotnet publish $phisilica_csproj -c $Configuration -o $phisilica_out_dir
161+
}
162+
155163
if ($LASTEXITCODE -eq 0 -and -not $NotIncludeModule) {
156164
Write-Host "`n[Build the AIShell module ...]`n" -ForegroundColor Green
157165
$aish_module_csproj = GetProjectFile $module_dir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net8.0-windows10.0.26100.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<Platforms>AnyCPU</Platforms>
9+
<WindowsPackageType>None</WindowsPackageType>
10+
<EnableDynamicLoading>true</EnableDynamicLoading>
11+
<WindowsAppSdkBootstrapInitialize>true</WindowsAppSdkBootstrapInitialize>
12+
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
13+
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
14+
<EnableMsixTooling>true</EnableMsixTooling>
15+
16+
</PropertyGroup>
17+
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\AIShell.Abstraction\AIShell.Abstraction.csproj">
21+
<!-- Disable copying AIShell.Abstraction.dll to output folder -->
22+
<Private>false</Private>
23+
<!-- Disable copying the transitive dependencies to output folder -->
24+
<ExcludeAssets>runtime</ExcludeAssets>
25+
</ProjectReference>
26+
</ItemGroup>
27+
28+
29+
<ItemGroup>
30+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.250410001-experimental1" />
31+
</ItemGroup>
32+
33+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
using Microsoft.Windows.AI.Generative;
3+
4+
using AIShell.Abstraction;
5+
using Microsoft.Windows.AI;
6+
7+
namespace phisilicaagent_041825
8+
{
9+
public class PhiSilicaAgent : ILLMAgent
10+
{
11+
public string Name => "PhiSilica";
12+
13+
public string Description => "This is the Phi Silica agent, an offline local agent on Copilot+ PCs";
14+
15+
public string SettingFile => null;
16+
17+
public bool CanAcceptFeedback(UserAction action) => false;
18+
19+
20+
public async Task<bool> ChatAsync(string input, IShell shell)
21+
{
22+
IHost host = shell.Host;
23+
if (LanguageModel.GetReadyState() == AIFeatureReadyState.EnsureNeeded)
24+
{
25+
var op = await LanguageModel.EnsureReadyAsync();
26+
27+
}
28+
29+
var languageModel = await LanguageModel.CreateAsync();
30+
31+
var results = await languageModel.GenerateResponseAsync(input);
32+
33+
if (results != null && !string.IsNullOrEmpty(results.Text))
34+
{
35+
host.RenderFullResponse(results.Text);
36+
}
37+
else
38+
{
39+
host.WriteErrorLine("No response received from the language model.");
40+
}
41+
//host.RenderFullResponse("Goodbye World");
42+
43+
return true;
44+
}
45+
46+
public void Dispose()
47+
{
48+
49+
}
50+
51+
public IEnumerable<CommandBase> GetCommands() => null;
52+
53+
public void Initialize(AgentConfig config)
54+
{
55+
56+
}
57+
58+
public void OnUserAction(UserActionPayload actionPayload)
59+
{
60+
61+
}
62+
63+
public Task RefreshChatAsync(IShell shell, bool force)
64+
{
65+
return Task.CompletedTask;
66+
}
67+
}
68+
69+
}

0 commit comments

Comments
 (0)