-
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.
- Loading branch information
Showing
30 changed files
with
948 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Publish NuGet Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: # Enables the "Run workflow" button | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
6.0.x | ||
7.0.x | ||
8.0.x | ||
- name: Get version from source | ||
id: get-version | ||
run: | | ||
VERSION=$(cat SpongeEngine.LLMSharp.Core/SpongeEngine.LLMSharp.Core.csproj | grep '<Version>' | sed -E 's/.*<Version>(.*)<\/Version>.*/\1/') | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
echo "Using version: $VERSION" | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build for .NET 6.0 | ||
run: dotnet build --configuration Release --framework net6.0 --no-restore | ||
|
||
- name: Build for .NET 7.0 | ||
run: dotnet build --configuration Release --framework net7.0 --no-restore | ||
|
||
- name: Build for .NET 8.0 | ||
run: dotnet build --configuration Release --framework net8.0 --no-restore | ||
|
||
- name: Pack NuGet Package | ||
run: dotnet pack --configuration Release --output ./output /p:Version=${{ env.VERSION }} | ||
|
||
- name: Publish NuGet Package | ||
run: dotnet nuget push ./output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json |
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,31 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
6.0.x | ||
7.0.x | ||
8.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build --no-restore | ||
|
||
- name: Test | ||
run: dotnet test --no-build --verbosity normal |
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,67 @@ | ||
# Contributing to LLMSharp.Core | ||
|
||
## Publishing to NuGet | ||
|
||
### Prerequisites | ||
1. Create a NuGet account at https://www.nuget.org | ||
2. Generate an API key: | ||
- Go to https://www.nuget.org/account/apikeys | ||
- Click "Create" | ||
- Name: "SpongeEngine.LLMSharp.Core Publishing" (or your preferred name) | ||
- Expiration: 365 days | ||
- Select "Push new packages and package versions" | ||
- Glob Pattern: "SpongeEngine.LLMSharp.Core*" | ||
- Save the generated key securely | ||
|
||
### Publishing Process | ||
1. Update version in `SpongeEngine.LLMSharp/SpongeEngine.LLMSharp.csproj`: | ||
```xml | ||
<Version>1.0.1</Version> <!-- Change this to new version --> | ||
``` | ||
|
||
2. Clean and pack: | ||
```bash | ||
dotnet clean | ||
dotnet pack -c Release | ||
``` | ||
|
||
3. Push to NuGet: | ||
```bash | ||
dotnet nuget push .\SpongeEngine.LLMSharp\bin\Release\SpongeEngine.LLMSharp.1.0.1.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json | ||
``` | ||
Replace: | ||
- `1.0.0` with your new version number | ||
- `YOUR_API_KEY` with your NuGet API key | ||
|
||
4. Wait 15-30 minutes for the package to appear on NuGet.org | ||
|
||
### Version Guidelines | ||
- Use [Semantic Versioning](https://semver.org/): | ||
- MAJOR version for incompatible API changes | ||
- MINOR version for backwards-compatible functionality | ||
- PATCH version for backwards-compatible bug fixes | ||
|
||
## Development Guidelines | ||
|
||
### Code Style | ||
- Use C# latest features and best practices | ||
- Follow Microsoft's [C# Coding Conventions](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions) | ||
- Use meaningful names for variables, methods, and classes | ||
- Add XML documentation comments for public APIs | ||
|
||
### Testing | ||
1. Write unit tests for new features | ||
2. Ensure all tests pass before submitting PR: | ||
```bash | ||
dotnet test | ||
``` | ||
|
||
### Pull Request Process | ||
1. Fork the repository | ||
2. Create a feature branch | ||
3. Make your changes | ||
4. Update documentation and tests | ||
5. Submit a pull request | ||
|
||
## Questions? | ||
Open an issue on GitHub if you have questions or need help. |
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 |
---|---|---|
@@ -1 +1 @@ | ||
# LLMSharp.Core | ||
# LLMSharp.Core (In Progress) |
36 changes: 36 additions & 0 deletions
36
SpongeEngine.SpongeLLM.Core.Tests/SpongeEngine.SpongeLLM.Core.Tests.csproj
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,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<TargetFrameworks>net8.0;net6.0;net7.0</TargetFrameworks> | ||
<LangVersion>10</LangVersion> | ||
<Version>0.0.1</Version> | ||
<PackageId>SpongeEngine.SpongeLLM.Core.Tests</PackageId> | ||
<Authors>SpongeEngine.SpongeLLM.Core.Tests</Authors> | ||
<AssemblyName>SpongeEngine.SpongeLLM.Core.Tests</AssemblyName> | ||
<RootNamespace>SpongeEngine.SpongeLLM.Core.Tests</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="8.0.1" /> | ||
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.5.1" /> | ||
<PackageReference Include="MicroElements.Testing.xUnit" Version="0.4.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" /> | ||
<PackageReference Include="Moq" Version="4.20.72" /> | ||
<PackageReference Include="System.Linq.Async" Version="6.0.1" /> | ||
<PackageReference Include="WireMock.Net" Version="1.7.0" /> | ||
<PackageReference Include="xunit" Version="2.9.3" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.4"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<ProjectReference Include="..\SpongeEngine.SpongeLLM.Core\SpongeEngine.SpongeLLM.Core.csproj" /> | ||
</ItemGroup> | ||
</Project> |
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,21 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpongeEngine.SpongeLLM.Core", "SpongeEngine.SpongeLLM.Core\SpongeEngine.SpongeLLM.Core.csproj", "{3AA31654-601E-4A2D-ABAB-66B2C99C9886}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpongeEngine.SpongeLLM.Core.Tests", "SpongeEngine.SpongeLLM.Core.Tests\SpongeEngine.SpongeLLM.Core.Tests.csproj", "{B4C06852-1A11-45B9-8E83-CF7ABEE36F12}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{3AA31654-601E-4A2D-ABAB-66B2C99C9886}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3AA31654-601E-4A2D-ABAB-66B2C99C9886}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3AA31654-601E-4A2D-ABAB-66B2C99C9886}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3AA31654-601E-4A2D-ABAB-66B2C99C9886}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{B4C06852-1A11-45B9-8E83-CF7ABEE36F12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B4C06852-1A11-45B9-8E83-CF7ABEE36F12}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B4C06852-1A11-45B9-8E83-CF7ABEE36F12}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B4C06852-1A11-45B9-8E83-CF7ABEE36F12}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
19 changes: 19 additions & 0 deletions
19
SpongeEngine.SpongeLLM.Core/Exceptions/LLMSharpException.cs
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,19 @@ | ||
namespace SpongeEngine.LLMSharp.Core.Exceptions | ||
{ | ||
public class LlmSharpException : Exception | ||
{ | ||
public int? StatusCode { get; } | ||
public string? ResponseContent { get; } | ||
|
||
public LlmSharpException( | ||
string message, | ||
int? statusCode = null, | ||
string? responseContent = null, | ||
Exception? innerException = null) | ||
: base(message, innerException) | ||
{ | ||
StatusCode = statusCode; | ||
ResponseContent = responseContent; | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
SpongeEngine.SpongeLLM.Core/Exceptions/ModelNotFoundException.cs
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 @@ | ||
namespace SpongeEngine.LLMSharp.Core.Exceptions | ||
{ | ||
public class ModelNotFoundException : LlmSharpException | ||
{ | ||
public string ModelId { get; } | ||
|
||
public ModelNotFoundException( | ||
string modelId, | ||
string provider, | ||
string? message = null) | ||
: base(message ?? $"Model {modelId} not found") | ||
{ | ||
ModelId = modelId; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
SpongeEngine.SpongeLLM.Core/Exceptions/ProviderException.cs
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 SpongeEngine.LLMSharp.Core.Exceptions | ||
{ | ||
public class ProviderException : LlmSharpException | ||
{ | ||
public ProviderException( | ||
string message, | ||
string provider, | ||
Exception? innerException = null) | ||
: base(message, innerException: innerException) | ||
{ | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
SpongeEngine.SpongeLLM.Core/Exceptions/ValidationException.cs
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,15 @@ | ||
namespace SpongeEngine.LLMSharp.Core.Exceptions | ||
{ | ||
public class ValidationException : LlmSharpException | ||
{ | ||
public IDictionary<string, string> ValidationErrors { get; } | ||
|
||
public ValidationException( | ||
IDictionary<string, string> errors, | ||
string provider) | ||
: base("Validation failed") | ||
{ | ||
ValidationErrors = errors; | ||
} | ||
} | ||
} |
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,25 @@ | ||
using SpongeEngine.LLMSharp.Core.Models; | ||
|
||
namespace SpongeEngine.LLMSharp.Core.Interfaces | ||
{ | ||
/// <summary> | ||
/// Interface for chat-style interactions | ||
/// </summary> | ||
public interface IChatService | ||
{ | ||
/// <summary> | ||
/// Performs chat completion with a list of messages | ||
/// </summary> | ||
Task<ChatResponse> ChatCompleteAsync(ChatRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Streams chat response tokens as they're generated | ||
/// </summary> | ||
IAsyncEnumerable<ChatToken> StreamChatAsync(ChatRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Gets chat model configuration and limitations | ||
/// </summary> | ||
Task<ChatModelConfig> GetModelConfigAsync(string modelId, CancellationToken cancellationToken = default); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
SpongeEngine.SpongeLLM.Core/Interfaces/IEmbeddingService.cs
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,25 @@ | ||
using SpongeEngine.LLMSharp.Core.Models; | ||
|
||
namespace SpongeEngine.LLMSharp.Core.Interfaces | ||
{ | ||
/// <summary> | ||
/// Interface for generating text embeddings | ||
/// </summary> | ||
public interface IEmbeddingService | ||
{ | ||
/// <summary> | ||
/// Generates embeddings for the input text | ||
/// </summary> | ||
Task<EmbeddingResponse> CreateEmbeddingAsync(EmbeddingRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Creates embeddings for multiple texts in batch | ||
/// </summary> | ||
Task<BatchEmbeddingResponse> CreateEmbeddingsAsync(BatchEmbeddingRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Gets embedding model information including vector dimensions | ||
/// </summary> | ||
Task<EmbeddingModelInfo> GetModelInfoAsync(string modelId, CancellationToken cancellationToken = default); | ||
} | ||
} |
Oops, something went wrong.