Skip to content

Commit e492101

Browse files
Merge branch 'release-1.16' into filinto/conversation-sdk-116
2 parents f6366a5 + 0c29b5d commit e492101

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

conversation/csharp/http/conversation/Program.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ limitations under the License.
3030

3131
var conversationRequestBody = JsonSerializer.Deserialize<Dictionary<string, object?>>("""
3232
{
33-
"name": "echo",
3433
"inputs": [{
3534
"messages": [{
3635
"of_user": {
@@ -67,7 +66,6 @@ limitations under the License.
6766

6867
var toolCallRequestBody = JsonSerializer.Deserialize<Dictionary<string, object?>>("""
6968
{
70-
"name": "demo",
7169
"inputs": [
7270
{
7371
"messages": [
@@ -135,24 +133,20 @@ limitations under the License.
135133
var toolCallingResponse = await httpClient.PostAsJsonAsync("http://localhost:3500/v1.0-alpha2/conversation/echo/converse", toolCallRequestBody);
136134
var toolCallingResult = await toolCallingResponse.Content.ReadFromJsonAsync<JsonElement>();
137135

138-
var toolCallingContent = toolCallingResult
136+
var messageElement = toolCallingResult
139137
.GetProperty("outputs")
140138
.EnumerateArray()
141139
.First()
142140
.GetProperty("choices")
143141
.EnumerateArray()
144142
.First()
145-
.GetProperty("message")
146-
.GetProperty("content");
143+
.GetProperty("message");
147144

148-
var functionCalled = toolCallingResult
149-
.GetProperty("outputs")
150-
.EnumerateArray()
151-
.First()
152-
.GetProperty("choices")
153-
.EnumerateArray()
154-
.First()
155-
.GetProperty("message")
145+
var toolCallingContent = messageElement.TryGetProperty("content", out var contentElement)
146+
? contentElement.GetString()
147+
: null;
148+
149+
var functionCalled = messageElement
156150
.GetProperty("toolCalls")
157151
.EnumerateArray()
158152
.First()

0 commit comments

Comments
 (0)