Skip to content

Commit

Permalink
feat: Updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed May 22, 2024
1 parent cf12bad commit afebfce
Show file tree
Hide file tree
Showing 13 changed files with 1,101 additions and 248 deletions.
7 changes: 7 additions & 0 deletions Replicate.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Replicate", "src\libs\Repli
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Replicate.IntegrationTests", "src\tests\Replicate.IntegrationTests\Replicate.IntegrationTests.csproj", "{592ADBC9-C951-4AF7-A163-B6C63B970B19}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Replicate.Models", "src\libs\Replicate.Models\Replicate.Models.csproj", "{B5C719C1-9F51-4874-9FBF-2D62CCCDBD1B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -40,13 +42,18 @@ Global
{592ADBC9-C951-4AF7-A163-B6C63B970B19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{592ADBC9-C951-4AF7-A163-B6C63B970B19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{592ADBC9-C951-4AF7-A163-B6C63B970B19}.Release|Any CPU.Build.0 = Release|Any CPU
{B5C719C1-9F51-4874-9FBF-2D62CCCDBD1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B5C719C1-9F51-4874-9FBF-2D62CCCDBD1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5C719C1-9F51-4874-9FBF-2D62CCCDBD1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5C719C1-9F51-4874-9FBF-2D62CCCDBD1B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0028BC85-0064-4CE8-A21A-C1F5E922BD59} = {61E7E11E-4558-434C-ACE8-06316A3097B3}
{592ADBC9-C951-4AF7-A163-B6C63B970B19} = {AAA11B78-2764-4520-A97E-46AA7089A588}
{B5C719C1-9F51-4874-9FBF-2D62CCCDBD1B} = {61E7E11E-4558-434C-ACE8-06316A3097B3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CED9A020-DBA5-4BE6-8096-75E528648EC1}
Expand Down
1,075 changes: 990 additions & 85 deletions docs/openapi.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@
<AnalysisMode>All</AnalysisMode>
</PropertyGroup>

<!-- <PropertyGroup Label="Trimmable" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">-->
<!-- <IsAotCompatible>true</IsAotCompatible>-->
<!-- <EnableTrimAnalyzer>true</EnableTrimAnalyzer>-->
<!-- <IsTrimmable>true</IsTrimmable>-->
<!-- <SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>-->
<!-- <TrimmerSingleWarn>false</TrimmerSingleWarn>-->
<!-- </PropertyGroup>-->

</Project>
52 changes: 52 additions & 0 deletions src/libs/Replicate.Models/Replicate.Models.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net4.6.2;net6.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<Using Include="System.Text.Json" />
</ItemGroup>

<PropertyGroup Label="Nuget">
<PackageId>tryAGI.Replicate.Models</PackageId>
<Description>Generated C# SDK based on Replicate OpenAPI specification.</Description>
<PackageTags>api;client;sdk;dotnet;swagger;openapi;specification;replicate;generated;nswag</PackageTags>
</PropertyGroup>

<PropertyGroup Label="OpenApiGenerator">
<OpenApiGenerator_Namespace>Replicate</OpenApiGenerator_Namespace>
<OpenApiGenerator_GenerateSdk>false</OpenApiGenerator_GenerateSdk>
<OpenApiGenerator_GenerateModels>true</OpenApiGenerator_GenerateModels>
<OpenApiGenerator_GenerateSuperTypeForJsonSerializerContext>true</OpenApiGenerator_GenerateSuperTypeForJsonSerializerContext>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)../../../docs/openapi.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenApiGenerator" Version="0.7.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PolySharp" Version="1.14.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net4.6.2'">
<Reference Include="System.Net.Http" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

</Project>
47 changes: 0 additions & 47 deletions src/libs/Replicate/Extensions/StringExtensions.cs

This file was deleted.

24 changes: 0 additions & 24 deletions src/libs/Replicate/Helpers/ApiHelpers.cs

This file was deleted.

17 changes: 0 additions & 17 deletions src/libs/Replicate/RecommendedModelIds.cs

This file was deleted.

33 changes: 25 additions & 8 deletions src/libs/Replicate/Replicate.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net4.6.2;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net4.6.2;net6.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<Using Include="System.Text.Json" />
<Using Include="System.Net.Http" />
</ItemGroup>

<PropertyGroup Label="Nuget">
<PackageId>tryAGI.Replicate</PackageId>
<Description>Generated C# SDK based on Replicate OpenAPI specification.</Description>
<PackageTags>api;client;sdk;dotnet;swagger;openapi;specification;replicate;generated;nswag</PackageTags>
</PropertyGroup>


<PropertyGroup Label="OpenApiGenerator">
<OpenApiGenerator_Namespace>Replicate</OpenApiGenerator_Namespace>
<OpenApiGenerator_ClassName>ReplicateApi</OpenApiGenerator_ClassName>
<OpenApiGenerator_GenerateSdk>false</OpenApiGenerator_GenerateSdk>
<OpenApiGenerator_GenerateMethods>true</OpenApiGenerator_GenerateMethods>
<OpenApiGenerator_GenerateConstructors>true</OpenApiGenerator_GenerateConstructors>
<OpenApiGenerator_MethodNamingConvention>OperationIdWithDots</OpenApiGenerator_MethodNamingConvention>
<!-- <OpenApiGenerator_JsonSerializerContext>Replicate.SourceGenerationContext</OpenApiGenerator_JsonSerializerContext>-->
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="$(SolutionDir)docs\openapi.nswag" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)../../../docs/openapi.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="H.NSwag.Generator" Version="14.0.7.76">
<PackageReference Include="OpenApiGenerator" Version="0.7.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -32,13 +43,19 @@

<ItemGroup Condition="'$(TargetFramework)' == 'net4.6.2'">
<Reference Include="System.Net.Http" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Replicate.Models\Replicate.Models.csproj" />
</ItemGroup>

</Project>
39 changes: 0 additions & 39 deletions src/libs/Replicate/ReplicateApi.Authorization.cs

This file was deleted.

17 changes: 0 additions & 17 deletions src/libs/Replicate/ReplicateApi.Constructors.cs

This file was deleted.

7 changes: 7 additions & 0 deletions src/libs/Replicate/SourceGenerationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System.Text.Json.Serialization;

namespace Replicate;

[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
[JsonSerializable(typeof(OpenApiGeneratorTrimmableSupport))]
internal sealed partial class SourceGenerationContext : JsonSerializerContext;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup Label="Base packages">
Expand Down
21 changes: 11 additions & 10 deletions src/tests/Replicate.IntegrationTests/Tests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Replicate;

namespace tryAGI.OpenAI.IntegrationTests;
namespace Replicate.IntegrationTests;

[TestClass]
public class GeneralTests
Expand All @@ -12,12 +10,15 @@ public async Task Generate()
Environment.GetEnvironmentVariable("REPLICATE_API_KEY") ??
throw new AssertInconclusiveException("REPLICATE_API_KEY environment variable is not found.");

using var client = new HttpClient();
var api = new ReplicateApi(apiKey, client);
await api.Predictions_createAsync(new Body2
{
Input = "",
Stream = false
});
using var api = new ReplicateApi();
api.AuthorizeUsingBearer(apiKey);

await api.CreatePredictionsAsync(
input: new
{
prompt = "I forgot how to kill a process in Linux, can you help?",
assistant = "Sure! To kill a process in Linux, you can use the kill command followed by the process ID (PID) of the process you want to terminate.",
},
version: "b063023ee937f28e922982abdbf97b041ffe34ad3b35a53d33e1d74bb19b36c4");
}
}

0 comments on commit afebfce

Please sign in to comment.