-
Notifications
You must be signed in to change notification settings - Fork 1
Alex/first-version #1
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
13 commits
Select commit
Hold shift + click to select a range
790fcb8
Add Langfuse-integrated prompt provider library
KrastyTC 17daea7
Restructure PromptProvider and add default prompts support
KrastyTC 0104468
Update publish-nuget.yml
KrastyTC ccef8f0
Remove PromptProvider test project and tests
KrastyTC a47eb0f
Delete ci.yml
KrastyTC 28562c0
Update README.md
KrastyTC 6020d16
Update DependencyInjection.cs
KrastyTC 09b45d9
Update Services/LangfuseService.cs
KrastyTC 24b06f8
Update LICENSE
KrastyTC 6c5a4a9
Update Options/PromptConfiguration.cs
KrastyTC 95e6d90
Update Services/LangfuseService.cs
KrastyTC ba082e1
Update publish-nuget.yml
KrastyTC f38bb68
Merge branch 'alex/all-original-files' of https://github.com/Zio-Net/…
KrastyTC 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,84 @@ | ||
| name: publish-nuget | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Override version (optional, e.g. 0.1.2)' | ||
| required: false | ||
| type: string | ||
|
|
||
| jobs: | ||
| pack-and-push: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| env: | ||
| LIB_PROJ: PromptProvider/PromptProvider.csproj | ||
| TEST_PROJ: Tests/PromptProvider.Tests/PromptProvider.Tests.csproj | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
|
|
||
| - name: Verify projects exist | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| [[ -f "$LIB_PROJ" ]] || { echo "Library not found: $LIB_PROJ"; exit 1; } | ||
| echo "Library: $LIB_PROJ" | ||
| - name: Restore | ||
| shell: bash | ||
| run: | | ||
| dotnet restore "$TEST_PROJ" | ||
|
|
||
| - name: Build library | ||
| shell: bash | ||
| run: | | ||
| dotnet build "$LIB_PROJ" -c Release -p:ContinuousIntegrationBuild=true --no-restore | ||
| - name: Resolve version | ||
| id: ver | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -n "${{ github.event.inputs.version }}" ]; then | ||
| PKGVER="${{ github.event.inputs.version }}" | ||
| else | ||
| PKGVER=$(grep -oPm1 '(?<=<Version>)[^<]+' "$LIB_PROJ" || true) | ||
| if [ -z "$PKGVER" ]; then | ||
| echo "<Version> not found in $LIB_PROJ" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
| echo "PKGVER=$PKGVER" >> $GITHUB_ENV | ||
| echo "Using version: $PKGVER" | ||
|
|
||
| - name: Pack | ||
| shell: bash | ||
| run: | | ||
| dotnet pack "$LIB_PROJ" -c Release \ | ||
| -p:Version="${PKGVER}" \ | ||
| -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg \ | ||
| -o ./artifacts \ | ||
| --no-build | ||
|
|
||
| - name: Push to nuget.org | ||
| env: | ||
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -z "${NUGET_API_KEY:-}" ]; then | ||
| echo "NUGET_API_KEY secret is not set." >&2 | ||
| exit 1 | ||
| fi | ||
| dotnet nuget push "./artifacts/*.nupkg" --skip-duplicate --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json | ||
| if ls ./artifacts/*.snupkg 1> /dev/null 2>&1; then | ||
| dotnet nuget push "./artifacts/*.snupkg" --skip-duplicate --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json | ||
| else | ||
| echo "No symbol packages (.snupkg) found to push." | ||
| fi | ||
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,33 @@ | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using PromptProvider.Interfaces; | ||
| using PromptProvider.Options; | ||
| using PromptProvider.Services; | ||
|
|
||
| namespace PromptProvider; | ||
|
|
||
| public static class DependencyInjection | ||
| { | ||
| public static IServiceCollection AddPromptProvider( | ||
| this IServiceCollection services, | ||
| Action<LangfuseOptions>? configureLangfuse = null, | ||
| Action<PromptsOptions>? configurePrompts = null) | ||
| { | ||
| if (configureLangfuse is not null) services.Configure(configureLangfuse); | ||
| if (configurePrompts is not null) services.Configure(configurePrompts); | ||
|
|
||
| services.AddHttpClient<ILangfuseService, LangfuseService>((serviceProvider, client) => | ||
| { | ||
| var options = serviceProvider.GetRequiredService<Microsoft.Extensions.Options.IOptions<LangfuseOptions>>().Value; | ||
| if (options.IsConfigured() && !string.IsNullOrWhiteSpace(options.BaseUrl)) | ||
| { | ||
| client.BaseAddress = new Uri(options.BaseUrl); | ||
| } | ||
| }); | ||
| services.AddScoped<IPromptService, PromptService>(); | ||
|
|
||
| // Register default prompts provider (users may replace with custom implementation) | ||
| services.AddSingleton<IDefaultPromptsProvider, ConfigurationDefaultPromptsProvider>(); | ||
|
|
||
| return services; | ||
| } | ||
| } |
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,6 @@ | ||
| namespace PromptProvider.Interfaces; | ||
|
|
||
| public interface IDefaultPromptsProvider | ||
| { | ||
| IReadOnlyDictionary<string, string> GetDefaults(); | ||
| } |
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,51 @@ | ||
| using PromptProvider.Models; | ||
|
|
||
| namespace PromptProvider.Interfaces; | ||
|
|
||
| public interface ILangfuseService | ||
| { | ||
| /// <summary> | ||
| /// Get a prompt by name from Langfuse API. | ||
| /// </summary> | ||
| /// <param name="promptName">The name of the prompt</param> | ||
| /// <param name="version">Optional version of the prompt to retrieve</param> | ||
| /// <param name="label">Optional label of the prompt (defaults to "production" if no label or version is set)</param> | ||
| /// <param name="cancellationToken">Cancellation token</param> | ||
| /// <returns>The Langfuse prompt model</returns> | ||
| Task<LangfusePromptModel?> GetPromptAsync( | ||
| string promptName, | ||
| int? version = null, | ||
| string? label = null, | ||
| CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Get all prompts from Langfuse API. | ||
| /// </summary> | ||
| /// <param name="cancellationToken">Cancellation token</param> | ||
| /// <returns>List of Langfuse prompt list items</returns> | ||
| Task<List<LangfusePromptListItem>> GetAllPromptsAsync(CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Create a new version for the prompt with the given name in Langfuse API. | ||
| /// </summary> | ||
| /// <param name="request">The prompt creation request</param> | ||
| /// <param name="cancellationToken">Cancellation token</param> | ||
| /// <returns>The created prompt response</returns> | ||
| Task<CreateLangfusePromptResponse> CreatePromptAsync( | ||
| CreateLangfusePromptRequest request, | ||
| CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Update labels for a specific prompt version in Langfuse API. | ||
| /// </summary> | ||
| /// <param name="promptName">The name of the prompt</param> | ||
| /// <param name="version">The version number to update</param> | ||
| /// <param name="request">The update request containing new labels</param> | ||
| /// <param name="cancellationToken">Cancellation token</param> | ||
| /// <returns>The updated prompt model</returns> | ||
| Task<LangfusePromptModel> UpdatePromptLabelsAsync( | ||
| string promptName, | ||
| int version, | ||
| UpdatePromptLabelsRequest request, | ||
| CancellationToken cancellationToken = default); | ||
| } |
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,35 @@ | ||
| using PromptProvider.Models; | ||
|
|
||
| namespace PromptProvider.Interfaces; | ||
|
|
||
| public interface IPromptService | ||
| { | ||
| /// <summary> | ||
| /// Create a new prompt version in Langfuse | ||
| /// </summary> | ||
| Task<PromptResponse> CreatePromptAsync(CreatePromptRequest request, CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Get a prompt by key with optional version or label. Falls back to local defaults if Langfuse is unavailable. | ||
| /// </summary> | ||
| /// <param name="promptKey">The prompt key/name</param> | ||
| /// <param name="version">Optional specific version number</param> | ||
| /// <param name="label">Optional label (e.g., "production", "latest")</param> | ||
| /// <param name="cancellationToken">Cancellation token</param> | ||
| Task<PromptResponse?> GetPromptAsync(string promptKey, int? version = null, string? label = null, CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Get all prompts from Langfuse | ||
| /// </summary> | ||
| Task<List<LangfusePromptListItem>> GetAllPromptsAsync(CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Get multiple prompts by keys with optional label. Falls back to local defaults if Langfuse is unavailable. | ||
| /// </summary> | ||
| Task<List<PromptResponse>> GetPromptsAsync(IEnumerable<string> promptKeys, string? label = null, CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Update labels for a specific prompt version in Langfuse | ||
| /// </summary> | ||
| Task<PromptResponse> UpdatePromptLabelsAsync(string promptKey, int version, UpdatePromptLabelsRequest request, CancellationToken cancellationToken = default); | ||
| } |
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,26 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace PromptProvider.Models; | ||
| public record CreateLangfusePromptRequest | ||
| { | ||
| [JsonPropertyName("name")] | ||
| public required string Name { get; set; } | ||
|
|
||
| [JsonPropertyName("prompt")] | ||
| public required string Prompt { get; set; } | ||
|
|
||
| [JsonPropertyName("type")] | ||
| public required string Type { get; set; } | ||
|
|
||
| [JsonPropertyName("commitMessage")] | ||
| public string? CommitMessage { get; set; } | ||
|
|
||
| [JsonPropertyName("config")] | ||
| public object? Config { get; set; } | ||
|
|
||
| [JsonPropertyName("labels")] | ||
| public string[]? Labels { get; set; } | ||
|
|
||
| [JsonPropertyName("tags")] | ||
| public string[]? Tags { get; set; } | ||
| } |
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,33 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace PromptProvider.Models; | ||
|
|
||
| public record CreateLangfusePromptResponse | ||
| { | ||
| [JsonPropertyName("name")] | ||
| public required string Name { get; set; } | ||
|
|
||
| [JsonPropertyName("prompt")] | ||
| public required string Prompt { get; set; } | ||
|
|
||
| [JsonPropertyName("type")] | ||
| public required string Type { get; set; } | ||
|
|
||
| [JsonPropertyName("version")] | ||
| public int Version { get; set; } | ||
|
|
||
| [JsonPropertyName("config")] | ||
| public object? Config { get; set; } | ||
|
|
||
| [JsonPropertyName("labels")] | ||
| public required string[] Labels { get; set; } | ||
|
|
||
| [JsonPropertyName("tags")] | ||
| public required string[] Tags { get; set; } | ||
|
|
||
| [JsonPropertyName("commitMessage")] | ||
| public string? CommitMessage { get; set; } | ||
|
|
||
| [JsonPropertyName("resolutionGraph")] | ||
| public object? ResolutionGraph { get; set; } | ||
| } |
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,10 @@ | ||
| namespace PromptProvider.Models; | ||
|
|
||
| public record CreatePromptRequest | ||
| { | ||
| public required string PromptKey { get; set; } | ||
| public required string Content { get; set; } | ||
| public string? CommitMessage { get; set; } | ||
| public string[]? Labels { get; set; } | ||
| public string[]? Tags { get; set; } | ||
| } |
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,6 @@ | ||
| namespace PromptProvider.Models; | ||
|
|
||
| public sealed record GetPromptsBatchRequest | ||
| { | ||
| public required List<PromptConfiguration> Prompts { get; init; } | ||
| } |
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,7 @@ | ||
| namespace PromptProvider.Models; | ||
|
|
||
| public sealed record GetPromptsBatchResponse | ||
| { | ||
| public required List<PromptResponse> Prompts { get; init; } | ||
| public required List<string> NotFound { get; init; } | ||
| } |
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,27 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace PromptProvider.Models; | ||
|
|
||
| public record LangfusePromptListItem | ||
| { | ||
| [JsonPropertyName("name")] | ||
| public required string Name { get; set; } | ||
|
|
||
| [JsonPropertyName("type")] | ||
| public required string Type { get; set; } | ||
|
|
||
| [JsonPropertyName("tags")] | ||
| public required string[] Tags { get; set; } | ||
|
|
||
| [JsonPropertyName("labels")] | ||
| public required string[] Labels { get; set; } | ||
|
|
||
| [JsonPropertyName("lastUpdatedAt")] | ||
| public string? LastUpdatedAt { get; set; } | ||
|
|
||
| [JsonPropertyName("versions")] | ||
| public int[]? Versions { get; set; } | ||
|
|
||
| [JsonPropertyName("lastConfig")] | ||
| public object? LastConfig { get; set; } | ||
| } |
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,39 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace PromptProvider.Models; | ||
|
|
||
| public record LangfusePromptModel | ||
| { | ||
| [JsonPropertyName("name")] | ||
| public required string Name { get; set; } | ||
|
|
||
| [JsonPropertyName("type")] | ||
| public required string Type { get; set; } | ||
|
|
||
| [JsonPropertyName("prompt")] | ||
| public required string Prompt { get; set; } | ||
|
|
||
| [JsonPropertyName("config")] | ||
| public LangfusePromptConfiguration? Config { get; set; } | ||
|
|
||
| [JsonPropertyName("version")] | ||
| public int Version { get; set; } | ||
|
|
||
| [JsonPropertyName("labels")] | ||
| public required string[] Labels { get; set; } | ||
|
|
||
| [JsonPropertyName("tags")] | ||
| public required string[] Tags { get; set; } | ||
| } | ||
|
|
||
| public record LangfusePromptConfiguration | ||
| { | ||
| [JsonPropertyName("model")] | ||
| public string? Model { get; set; } | ||
|
|
||
| [JsonPropertyName("temperature")] | ||
| public double? Temperature { get; set; } | ||
|
|
||
| [JsonPropertyName("supported_languages")] | ||
| public string[]? SupportedLanguages { get; set; } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.