Skip to content

Commit

Permalink
switch to SpongeLLM.Core v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dclipca committed Jan 31, 2025
1 parent 777fd4a commit 4bf8d1c
Show file tree
Hide file tree
Showing 39 changed files with 143 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<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="WireMock.Net" Version="1.7.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.KoboldSharp.Tests/Unit/Extra/AbortGenerate.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -66,7 +66,7 @@ public async Task AbortGenerate_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.AbortGenerateAsync())
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to abort generation");
}
}
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.KoboldSharp.Tests/Unit/Extra/CountTokensAsync.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -57,7 +57,7 @@ public async Task CountTokensAsync_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.CountTokensAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to count tokens");
}
}
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.KoboldSharp.Tests/Unit/Extra/DetokenizeAsync.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -82,7 +82,7 @@ public async Task DetokenizeAsync_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.DetokenizeAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to detokenize");
}
}
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.KoboldSharp.Tests/Unit/Extra/LogProbs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -105,7 +105,7 @@ public async Task GetLastLogProbs_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.GetLastLogProbsAsync())
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get last log probabilities");
}
}
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.KoboldSharp.Tests/Unit/Extra/PendingOutput.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -87,7 +87,7 @@ public async Task GetPendingOutput_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.GetPendingOutputAsync())
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get pending output");
}
}
Expand Down
4 changes: 2 additions & 2 deletions SpongeEngine.KoboldSharp.Tests/Unit/Extra/PerfInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -99,7 +99,7 @@ public async Task GetPerfInfo_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.GetPerfInfoAsync())
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get performance info");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -67,7 +67,7 @@ public async Task GetMultiplayerStory_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.GetMultiplayerStoryAsync())
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get multiplayer story");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -97,7 +97,7 @@ public async Task GetMultiplayerStatus_WithInvalidSender_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.GetMultiplayerStatusAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get multiplayer status");
}

Expand All @@ -121,7 +121,7 @@ public async Task GetMultiplayerStatus_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.GetMultiplayerStatusAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get multiplayer status");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -108,7 +108,7 @@ public async Task SetMultiplayerStory_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.SetMultiplayerStoryAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to set multiplayer story");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentAssertions;
using Microsoft.Extensions.Logging;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -121,7 +121,7 @@ public async Task ImageToImage_WithNoInitialImage_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.ImageToImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to generate image from image");
}

Expand All @@ -145,7 +145,7 @@ public async Task ImageToImage_WithInvalidImage_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.ImageToImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to generate image from image");
}

Expand All @@ -169,7 +169,7 @@ public async Task ImageToImage_WithServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.ImageToImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to generate image from image");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -58,7 +58,7 @@ public async Task InterrogateImage_WithInvalidImage_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.InterrogateImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to interrogate image");
}

Expand All @@ -81,7 +81,7 @@ public async Task InterrogateImage_WithEmptyImage_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.InterrogateImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to interrogate image");
}

Expand All @@ -104,7 +104,7 @@ public async Task InterrogateImage_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.InterrogateImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to interrogate image");
}

Expand All @@ -127,7 +127,7 @@ public async Task InterrogateImage_WithNullResponse_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.InterrogateImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to interrogate image");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -84,7 +84,7 @@ public async Task GetStableDiffusionModels_WhenServerError_ShouldThrowException(

// Act & Assert
await Client.Invoking(c => c.GetStableDiffusionModelsAsync())
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get Stable Diffusion models");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -87,7 +87,7 @@ public async Task GetStableDiffusionSamplers_WhenServerError_ShouldThrowExceptio

// Act & Assert
await Client.Invoking(c => c.GetStableDiffusionSamplersAsync())
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get Stable Diffusion samplers");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -112,7 +112,7 @@ public async Task TextToImage_WithInvalidDimensions_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.TextToImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to generate image from text");
}

Expand All @@ -135,7 +135,7 @@ public async Task TextToImage_WithServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.TextToImageAsync(request))
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to generate image from text");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FluentAssertions;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using Xunit;
Expand Down Expand Up @@ -45,7 +45,7 @@ public async Task GetVersionInfoAsync_WhenServerError_ShouldThrowException()

// Act & Assert
await Client.Invoking(c => c.GetVersionInfoAsync())
.Should().ThrowAsync<LlmSharpException>()
.Should().ThrowAsync<SpongeLLMException>()
.WithMessage("Failed to get version info");
}
}
Expand Down
8 changes: 4 additions & 4 deletions SpongeEngine.KoboldSharp/Extra/AbortGenerateAsync.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;

namespace SpongeEngine.KoboldSharp
{
Expand Down Expand Up @@ -32,7 +32,7 @@ public async Task<bool> AbortGenerateAsync(string? genKey = null, CancellationTo

if (!response.IsSuccessStatusCode)
{
throw new LlmSharpException(
throw new SpongeLLMException(
"Failed to abort generation",
(int)response.StatusCode,
content);
Expand All @@ -41,9 +41,9 @@ public async Task<bool> AbortGenerateAsync(string? genKey = null, CancellationTo
var result = JsonSerializer.Deserialize<AbortResponse>(content);
return result?.Success == "true";
}
catch (Exception ex) when (ex is not LlmSharpException)
catch (Exception ex) when (ex is not SpongeLLMException)
{
throw new LlmSharpException("Failed to abort generation", innerException: ex);
throw new SpongeLLMException("Failed to abort generation", innerException: ex);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions SpongeEngine.KoboldSharp/Extra/CountTokensAsync.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using SpongeEngine.SpongeLLM.Core.Exceptions;
using SpongeEngine.LLMSharp.Core.Exceptions;

namespace SpongeEngine.KoboldSharp
{
Expand Down Expand Up @@ -41,17 +41,17 @@ public async Task<CountTokensResponse> CountTokensAsync(CountTokensRequest reque

if (!response.IsSuccessStatusCode)
{
throw new LlmSharpException(
throw new SpongeLLMException(
"Failed to count tokens",
(int)response.StatusCode,
content);
}

return JsonSerializer.Deserialize<CountTokensResponse>(content) ?? throw new LlmSharpException("Failed to deserialize token count response");
return JsonSerializer.Deserialize<CountTokensResponse>(content) ?? throw new SpongeLLMException("Failed to deserialize token count response");
}
catch (Exception ex) when (ex is not LlmSharpException)
catch (Exception ex) when (ex is not SpongeLLMException)
{
throw new LlmSharpException("Failed to count tokens", innerException: ex);
throw new SpongeLLMException("Failed to count tokens", innerException: ex);
}
}
}
Expand Down
Loading

0 comments on commit 4bf8d1c

Please sign in to comment.