Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AI.Playground.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<Project Path="src\0-hello-world\AI.HelloWorld.PromptApi\AI.HelloWorld.PromptApi.csproj" Type="Classic C#" />
<File Path="src\0-hello-world\README.md" />
</Folder>
<Folder Name="/1-StatefulPrompts/">
<Project Path="src\1-stateful-prompts\AI.StatefulPrompts.Business\AI.StatefulPrompts.Business.csproj" Type="Classic C#" />
<Project Path="src\1-stateful-prompts\AI.StatefulPrompts.WebUI\AI.StatefulPrompts.WebUI.csproj" Type="Classic C#" />
</Folder>
<Folder Name="/build/">
<File Path="Directory.Build.props" />
<File Path="Directory.Packages.props" />
Expand Down
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup Label="Common">
<PackageVersion Include="Akka.Hosting" Version="1.5.40" />
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.4.0-preview.1.25207.5" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.4" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.11.1" />
Expand Down
1 change: 0 additions & 1 deletion src/0-hello-world/AI.HelloWorld.PromptApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using AI.Telemetry;
using Microsoft.Extensions.AI;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore;

var builder = WebApplication.CreateBuilder(args);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Akka.Hosting" />
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Immutable;
using Akka.Actor;
using Microsoft.Extensions.AI;

namespace AI.StatefulPrompts.Business;

/// <summary>
/// An immutable record that represents the history of a prompt.
/// </summary>
/// <param name="PromptTitle">The title, to be assigned later.</param>
/// <param name="CreatedAt">Start of the prompt history.</param>
/// <param name="Messages"></param>
public sealed record PromptHistory(string PromptTitle, DateTimeOffset CreatedAt, ImmutableStack<ChatMessage> Messages)
{
public DateTimeOffset LastUpdatedAt { get; } = DateTimeOffset.UtcNow;
}

public sealed class PromptHistoryActor : UntypedActor
{
private IActorRef _signalRMessagingActor;

Check warning on line 20 in src/1-stateful-prompts/AI.StatefulPrompts.Business/PromptHistory.cs

View workflow job for this annotation

GitHub Actions / Validate on ubuntu-latest

Non-nullable field '_signalRMessagingActor' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 20 in src/1-stateful-prompts/AI.StatefulPrompts.Business/PromptHistory.cs

View workflow job for this annotation

GitHub Actions / Validate on ubuntu-latest

The field 'PromptHistoryActor._signalRMessagingActor' is never used

Check warning on line 20 in src/1-stateful-prompts/AI.StatefulPrompts.Business/PromptHistory.cs

View workflow job for this annotation

GitHub Actions / Validate on ubuntu-latest

Non-nullable field '_signalRMessagingActor' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 20 in src/1-stateful-prompts/AI.StatefulPrompts.Business/PromptHistory.cs

View workflow job for this annotation

GitHub Actions / Validate on ubuntu-latest

The field 'PromptHistoryActor._signalRMessagingActor' is never used

protected override void OnReceive(object message)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\shared\Telemetry\Telemetry.csproj" />
<ProjectReference Include="..\AI.StatefulPrompts.Business\AI.StatefulPrompts.Business.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@AI.StatefulPrompts.WebUI_HostAddress = http://localhost:5082

GET {{AI.StatefulPrompts.WebUI_HostAddress}}/weatherforecast/
Accept: application/json

###
18 changes: 18 additions & 0 deletions src/1-stateful-prompts/AI.StatefulPrompts.WebUI/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}

app.UseHttpsRedirection();


app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading