Skip to content

Commit

Permalink
refactor namespace to SpongeLLM
Browse files Browse the repository at this point in the history
  • Loading branch information
dclipca committed Jan 26, 2025
1 parent 4045ef0 commit 160073d
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<IsPackable>false</IsPackable>
<TargetFrameworks>net8.0;net6.0;net7.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<Version>0.0.1</Version>
<Version>0.0.2</Version>
<PackageId>SpongeEngine.SpongeLLM.Core.Tests</PackageId>
<Authors>SpongeEngine.SpongeLLM.Core.Tests</Authors>
<AssemblyName>SpongeEngine.SpongeLLM.Core.Tests</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Exceptions
namespace SpongeEngine.SpongeLLM.Core.Exceptions
{
public class LlmSharpException : Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Exceptions
namespace SpongeEngine.SpongeLLM.Core.Exceptions
{
public class ModelNotFoundException : LlmSharpException
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Exceptions
namespace SpongeEngine.SpongeLLM.Core.Exceptions
{
public class ProviderException : LlmSharpException
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Exceptions
namespace SpongeEngine.SpongeLLM.Core.Exceptions
{
public class ValidationException : LlmSharpException
{
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.SpongeLLM.Core/Interfaces/IChatService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SpongeEngine.LLMSharp.Core.Models;
using SpongeEngine.SpongeLLM.Core.Models;

namespace SpongeEngine.LLMSharp.Core.Interfaces
namespace SpongeEngine.SpongeLLM.Core.Interfaces
{
/// <summary>
/// Interface for chat-style interactions
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.SpongeLLM.Core/Interfaces/IEmbeddingService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SpongeEngine.LLMSharp.Core.Models;
using SpongeEngine.SpongeLLM.Core.Models;

namespace SpongeEngine.LLMSharp.Core.Interfaces
namespace SpongeEngine.SpongeLLM.Core.Interfaces
{
/// <summary>
/// Interface for generating text embeddings
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.SpongeLLM.Core/Interfaces/IModelManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SpongeEngine.LLMSharp.Core.Models;
using SpongeEngine.SpongeLLM.Core.Models;

namespace SpongeEngine.LLMSharp.Core.Interfaces
namespace SpongeEngine.SpongeLLM.Core.Interfaces
{
/// <summary>
/// Interface for managing LLM models
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.SpongeLLM.Core/Interfaces/IProgressTracker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SpongeEngine.LLMSharp.Core.Models;
using SpongeEngine.SpongeLLM.Core.Models;

namespace SpongeEngine.LLMSharp.Core.Interfaces
namespace SpongeEngine.SpongeLLM.Core.Interfaces
{
/// <summary>
/// Interface for tracking operation progress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SpongeEngine.LLMSharp.Core.Models;
using SpongeEngine.SpongeLLM.Core.Models;

namespace SpongeEngine.LLMSharp.Core.Interfaces
namespace SpongeEngine.SpongeLLM.Core.Interfaces
{
public interface IStreamableTextCompletion {
IAsyncEnumerable<TextCompletionToken> CompleteTextStreamAsync(TextCompletionRequest request, CancellationToken cancellationToken = default);
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.SpongeLLM.Core/Interfaces/ITextCompletion.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SpongeEngine.LLMSharp.Core.Models;
using SpongeEngine.SpongeLLM.Core.Models;

namespace SpongeEngine.LLMSharp.Core.Interfaces
namespace SpongeEngine.SpongeLLM.Core.Interfaces
{
public interface ITextCompletion {
Task<TextCompletionResult> CompleteTextAsync(TextCompletionRequest request, CancellationToken cancellationToken = default);
Expand Down
2 changes: 1 addition & 1 deletion SpongeEngine.SpongeLLM.Core/LLMClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Polly.CircuitBreaker;
using Polly.Retry;

namespace SpongeEngine.LLMSharp.Core
namespace SpongeEngine.SpongeLLM.Core
{
public abstract class LLMClientBase
{
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.SpongeLLM.Core/LLMClientBaseOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using Polly;
using Polly.CircuitBreaker;
using Polly.Retry;
using SpongeEngine.LLMSharp.Core.Exceptions;
using SpongeEngine.SpongeLLM.Core.Exceptions;

namespace SpongeEngine.LLMSharp.Core
namespace SpongeEngine.SpongeLLM.Core
{
public class LLMClientBaseOptions
{
Expand Down
2 changes: 1 addition & 1 deletion SpongeEngine.SpongeLLM.Core/Models/ChatModels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Models
namespace SpongeEngine.SpongeLLM.Core.Models
{
public class ChatRequest
{
Expand Down
2 changes: 1 addition & 1 deletion SpongeEngine.SpongeLLM.Core/Models/CompletionOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Models
namespace SpongeEngine.SpongeLLM.Core.Models
{
public class CompletionOptions
{
Expand Down
2 changes: 1 addition & 1 deletion SpongeEngine.SpongeLLM.Core/Models/EmbeddingModels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Models
namespace SpongeEngine.SpongeLLM.Core.Models
{
public class EmbeddingRequest
{
Expand Down
2 changes: 1 addition & 1 deletion SpongeEngine.SpongeLLM.Core/Models/ModelInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Models
namespace SpongeEngine.SpongeLLM.Core.Models
{
public class ModelInfo
{
Expand Down
2 changes: 1 addition & 1 deletion SpongeEngine.SpongeLLM.Core/Models/ProgressModels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Models
namespace SpongeEngine.SpongeLLM.Core.Models
{
public class ProgressUpdate
{
Expand Down
2 changes: 1 addition & 1 deletion SpongeEngine.SpongeLLM.Core/Models/ProviderInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Models
namespace SpongeEngine.SpongeLLM.Core.Models
{
public class ProviderInfo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SpongeEngine.LLMSharp.Core.Models
namespace SpongeEngine.SpongeLLM.Core.Models
{
public class TextCompletionRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Package Info -->
<PackageId>SpongeEngine.SpongeLLM.Core</PackageId>
<Title>SpongeEngine.SpongeLLM.Core</Title>
<Version>0.0.1</Version>
<Version>0.0.2</Version>
<Authors>Dan Clipca</Authors>
<Company>Sponge Engine</Company>
<Description>Common logic for SpongeLLM, unified C# client for LLM providers.</Description>
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.SpongeLLM.Core/Utils/RetryPolicy.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
using SpongeEngine.LLMSharp.Core.Exceptions;
using SpongeEngine.SpongeLLM.Core.Exceptions;

namespace SpongeEngine.LLMSharp.Core.Utils
namespace SpongeEngine.SpongeLLM.Core.Utils
{
public class RetryPolicy
{
Expand Down
16 changes: 13 additions & 3 deletions SpongeEngine.SpongeLLM.Core/Utils/ValidationHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using SpongeEngine.LLMSharp.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Models;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.SpongeLLM.Core.Models;

namespace SpongeEngine.LLMSharp.Core.Utils
namespace SpongeEngine.SpongeLLM.Core.Utils
{
public static class ValidationHelper
{
Expand All @@ -22,24 +22,34 @@ public static void ValidateCompletionRequest(TextCompletionRequest request)
errors.Add("TopP", "TopP must be between 0 and 1");

if (errors.Any())
{
throw new ValidationException(errors, "Validation");
}
}

public static void ValidateChatRequest(ChatRequest request)
{
var errors = new Dictionary<string, string>();

if (string.IsNullOrEmpty(request.ModelId))
{
errors.Add("ModelId", "Model ID must be specified");
}

if (!request.Messages.Any())
{
errors.Add("Messages", "At least one message is required");
}

if (request.Messages.Any(m => string.IsNullOrEmpty(m.Role)))
{
errors.Add("Message.Role", "Message role cannot be empty");
}

if (errors.Any())
{
throw new ValidationException(errors, "Validation");
}
}
}
}

0 comments on commit 160073d

Please sign in to comment.