Skip to content

Commit

Permalink
test: Added Account.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Aug 21, 2024
1 parent 85d7a1e commit badb517
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 26 deletions.
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,17 @@ Examples and documentation can be found here: https://tryagi.github.io/Replicate
```csharp
using Replicate;

using var client = new HttpClient();
var api = new ReplicateApi(apiKey, client);
var response = await api.GenerateTextAsync(
RecommendedModelIds.Gpt2,
new GenerateTextRequest
{
Inputs = "Hello",
Parameters = new GenerateTextRequestParameters
{
Max_new_tokens = 250,
Return_full_text = false,
},
Options = new GenerateTextRequestOptions
{
Use_cache = true,
Wait_for_model = false,
},
});
var api = new ReplicateApi();
api.AuthorizeUsingBearer(apiKey);
var response = await api.AccountGetAsync();
```
```json
{
"Type": "organization",
"Username": "acme",
"Name": "Acme Corp, Inc.",
"GithubUrl": "https://github.com/acme"
}
```

## Support
Expand Down
15 changes: 15 additions & 0 deletions src/tests/Replicate.IntegrationTests/Tests.Account.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Replicate.IntegrationTests;

public partial class Tests
{
[TestMethod]
public async Task Account()
{
using var api = GetAuthorizedApi();

var response = await api.AccountGetAsync();

response.Should().NotBeNull();
response.Type.HasValue.Should().BeTrue();
}
}
10 changes: 2 additions & 8 deletions src/tests/Replicate.IntegrationTests/Tests.CreatePrediction.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
namespace Replicate.IntegrationTests;

[TestClass]
public class GeneralTests
public partial class Tests
{
[TestMethod]
public async Task CreatePrediction()
{
var apiKey =
Environment.GetEnvironmentVariable("REPLICATE_API_KEY") ??
throw new AssertInconclusiveException("REPLICATE_API_KEY environment variable is not found.");

using var api = new ReplicateApi();
api.AuthorizeUsingBearer(apiKey);
using var api = GetAuthorizedApi();

await api.PredictionsCreateAsync(
input: new VersionPredictionRequestInput
Expand Down
17 changes: 17 additions & 0 deletions src/tests/Replicate.IntegrationTests/Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Replicate.IntegrationTests;

[TestClass]
public partial class Tests
{
public static ReplicateApi GetAuthorizedApi()
{
var apiKey =
Environment.GetEnvironmentVariable("REPLICATE_API_KEY") ??
throw new AssertInconclusiveException("REPLICATE_API_KEY environment variable is not found.");

var api = new ReplicateApi();
api.AuthorizeUsingBearer(apiKey);

return api;
}
}

0 comments on commit badb517

Please sign in to comment.