Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 4 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"cliVersion": "3.91.2",
"cliVersion": "4.65.2",
"generatorName": "fernapi/fern-csharp-sdk",
"generatorVersion": "2.22.7",
"generatorVersion": "2.59.6",
"generatorConfig": {
"namespace": "Hume",
"client-class-name": "HumeClient",
Expand All @@ -25,5 +25,6 @@
}
}
},
"sdkVersion": "0.2.6"
"originGitCommit": "089414edddad02c1799299617e095fcd687046cf",
"sdkVersion": "0.2.7"
}
34 changes: 16 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ name: ci

on:
push:
branches: [main]
tags: ['*']
pull_request:
types: [synchronize, reopened, ready_for_review]
types: [opened, synchronize, reopened, ready_for_review]

jobs:
compile:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- uses: actions/checkout@master
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.x
dotnet-version: 10.x

- name: Install tools
run: |
Expand All @@ -32,14 +32,12 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4

- uses: actions/checkout@master
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.x
dotnet-version: 10.x

- name: Install tools
run: |
Expand All @@ -56,12 +54,12 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.x
dotnet-version: 10.x

- name: Publish
env:
Expand All @@ -77,23 +75,23 @@ jobs:
contents: read
steps:
- name: Checkout SDK repo (PR branch)
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
path: sdk
# checkout the PR branch, not main
ref: ${{ github.event.pull_request.head.sha || github.head_ref || github.ref }}
fetch-depth: 0

- name: Checkout examples repo
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: humeai/hume-api-examples
path: examples

- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v5
with:
dotnet-version: 9.x
dotnet-version: 10.x

- name: Build SDK
working-directory: ./sdk
Expand Down
53 changes: 49 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ The Hume C# library provides convenient access to the Hume APIs from C#.
- [Installation](#installation)
- [Reference](#reference)
- [Usage](#usage)
- [Environments](#environments)
- [Exception Handling](#exception-handling)
- [Pagination](#pagination)
- [Advanced](#advanced)
- [Retries](#retries)
- [Timeouts](#timeouts)
- [Raw Response](#raw-response)
- [Additional Headers](#additional-headers)
- [Additional Query Parameters](#additional-query-parameters)
- [Forward Compatible Enums](#forward-compatible-enums)
- [Contributing](#contributing)

Expand All @@ -43,10 +46,20 @@ using Hume.EmpathicVoice;
using Hume;

var client = new HumeClient("API_KEY");
await client.EmpathicVoice.ControlPlane.SendAsync(
"chat_id",
new SessionSettings { Type = "session_settings" }
);
await client.EmpathicVoice.ControlPlane.SendAsync("chat_id", new SessionSettings());
```

## Environments

This SDK allows you to configure different environments for API requests.

```csharp
using Hume;

var client = new HumeClient(new ClientOptions
{
Environment = HumeClientEnvironment.Prod
});
```

## Exception Handling
Expand Down Expand Up @@ -156,6 +169,38 @@ if (headers.TryGetValue("X-Request-Id", out var requestId))
var data = await client.EmpathicVoice.ControlPlane.SendAsync(...);
```

### Additional Headers

If you would like to send additional headers as part of the request, use the `AdditionalHeaders` request option.

```csharp
var response = await client.EmpathicVoice.ControlPlane.SendAsync(
...,
new RequestOptions {
AdditionalHeaders = new Dictionary<string, string?>
{
{ "X-Custom-Header", "custom-value" }
}
}
);
```

### Additional Query Parameters

If you would like to send additional query parameters as part of the request, use the `AdditionalQueryParameters` request option.

```csharp
var response = await client.EmpathicVoice.ControlPlane.SendAsync(
...,
new RequestOptions {
AdditionalQueryParameters = new Dictionary<string, string>
{
{ "custom_param", "custom-value" }
}
}
);
```

### Forward Compatible Enums

This SDK uses forward-compatible enums that can handle unknown values gracefully.
Expand Down
1 change: 1 addition & 0 deletions examples-repo
Submodule examples-repo added at 8e5971
9 changes: 3 additions & 6 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ Send a message to a specific chat.
<dd>

```csharp
await client.EmpathicVoice.ControlPlane.SendAsync(
"chat_id",
new SessionSettings { Type = "session_settings" }
);
await client.EmpathicVoice.ControlPlane.SendAsync("chat_id", new SessionSettings());
```
</dd>
</dl>
Expand Down Expand Up @@ -2606,7 +2603,7 @@ await client.Tts.SynthesizeJsonAsync(
},
},
},
Format = new FormatMp3 { Type = "mp3" },
Format = new FormatMp3(),
NumGenerations = 1,
Utterances = new List<PostedUtterance>()
{
Expand Down Expand Up @@ -2679,7 +2676,7 @@ await client.Tts.SynthesizeFileAsync(
new PostedTts
{
Context = new PostedContextWithGenerationId { GenerationId = "" },
Format = new FormatMp3 { Type = "mp3" },
Format = new FormatMp3(),
NumGenerations = 1,
Utterances = new List<PostedUtterance>()
{
Expand Down
24 changes: 24 additions & 0 deletions src/Hume.Test/Core/Json/DateOnlyJsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,28 @@ public void DeserializeNullableDateOnly_ShouldMatchExpectedDateOnly()
Assert.That(dateOnly, Is.EqualTo(expected));
}
}

[Test]
public void ShouldSerializeDictionaryWithDateOnlyKey()
{
var key = new DateOnly(2023, 10, 5);
var dict = new Dictionary<DateOnly, string> { { key, "value_a" } };
var json = JsonUtils.Serialize(dict);
Assert.That(json, Does.Contain("2023-10-05"));
Assert.That(json, Does.Contain("value_a"));
}

[Test]
public void ShouldDeserializeDictionaryWithDateOnlyKey()
{
var json = """
{
"2023-10-05": "value_a"
}
""";
var dict = JsonUtils.Deserialize<Dictionary<DateOnly, string>>(json);
Assert.That(dict, Is.Not.Null);
var key = new DateOnly(2023, 10, 5);
Assert.That(dict![key], Is.EqualTo("value_a"));
}
}
24 changes: 24 additions & 0 deletions src/Hume.Test/Core/Json/DateTimeJsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,28 @@ public void DeserializeNullableDateTime_ShouldMatchExpectedDateTime()
Assert.That(dateTime, Is.EqualTo(expected));
}
}

[Test]
public void ShouldSerializeDictionaryWithDateTimeKey()
{
var key = new DateTime(2023, 10, 5, 14, 30, 0, DateTimeKind.Utc);
var dict = new Dictionary<DateTime, string> { { key, "value_a" } };
var json = JsonUtils.Serialize(dict);
Assert.That(json, Does.Contain("2023-10-05T14:30:00.000Z"));
Assert.That(json, Does.Contain("value_a"));
}

[Test]
public void ShouldDeserializeDictionaryWithDateTimeKey()
{
var json = """
{
"2023-10-05T14:30:00.000Z": "value_a"
}
""";
var dict = JsonUtils.Deserialize<Dictionary<DateTime, string>>(json);
Assert.That(dict, Is.Not.Null);
var key = new DateTime(2023, 10, 5, 14, 30, 0, DateTimeKind.Utc);
Assert.That(dict![key], Is.EqualTo("value_a"));
}
}
Loading
Loading