Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[.NET] Return ChatCompletions instead of ChatResponseMessage for token usage. #2545

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
254 commits
Select commit Hold shift + click to select a range
0b265a3
update
LittleLittleCloud Dec 6, 2023
c6bc251
update
LittleLittleCloud Dec 7, 2023
1befc88
update
LittleLittleCloud Dec 7, 2023
47900f8
update
LittleLittleCloud Dec 8, 2023
521b76a
update
LittleLittleCloud Dec 8, 2023
5ad414c
add sample project
LittleLittleCloud Dec 9, 2023
75e4e69
revert notebook change back
LittleLittleCloud Dec 9, 2023
56e5741
update
LittleLittleCloud Dec 12, 2023
cc254b4
Merge branch 'main' into dotnet
LittleLittleCloud Dec 14, 2023
ddb2d69
update interactive version
LittleLittleCloud Dec 14, 2023
e6b7417
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Dec 14, 2023
72f1778
add nuget package
LittleLittleCloud Dec 15, 2023
cebc2ed
refactor Message
LittleLittleCloud Dec 15, 2023
0744f0e
update example
LittleLittleCloud Dec 19, 2023
a1d98ab
Merge branch 'main' into dotnet
LittleLittleCloud Dec 30, 2023
9538a0b
Merge branch 'main' into dotnet
LittleLittleCloud Jan 1, 2024
cb198ac
add azure nightly build pipeline
LittleLittleCloud Jan 1, 2024
36f09b1
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 1, 2024
0177888
Set up CI with Azure Pipelines
LittleLittleCloud Jan 1, 2024
048ee55
Update nightly-build.yml for Azure Pipelines
LittleLittleCloud Jan 1, 2024
3bbfee1
add dotnet interactive package
LittleLittleCloud Jan 2, 2024
b27012c
add dotnet interactive package
LittleLittleCloud Jan 2, 2024
d33066d
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 2, 2024
2f558af
update pipeline
LittleLittleCloud Jan 2, 2024
b22c55b
add nuget feed back
LittleLittleCloud Jan 2, 2024
9556c3e
remove dotnet-tool feed
LittleLittleCloud Jan 2, 2024
970c6f1
remove dotnet-tool feed comment
LittleLittleCloud Jan 2, 2024
63eec7d
update pipeline
LittleLittleCloud Jan 2, 2024
638f37e
update build name
LittleLittleCloud Jan 2, 2024
0b5c1ad
Update nightly-build.yml
LittleLittleCloud Jan 2, 2024
37da646
Delete .github/workflows/dotnet-ci.yml
LittleLittleCloud Jan 2, 2024
c05a1dd
update
LittleLittleCloud Jan 2, 2024
bc6f3ab
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 2, 2024
b011bbb
Merge branch 'main' into dotnet
LittleLittleCloud Jan 2, 2024
0f9fb74
add working_dir to use step
LittleLittleCloud Jan 2, 2024
c2b33c6
add initateChat api
LittleLittleCloud Jan 2, 2024
508f0ac
update oai package
LittleLittleCloud Jan 2, 2024
4bdd229
Update dotnet-build.yml
LittleLittleCloud Jan 2, 2024
72e7ffd
Update dotnet-run-openai-test-and-notebooks.yml
LittleLittleCloud Jan 2, 2024
7ce258a
update build workflow
LittleLittleCloud Jan 2, 2024
c00ad1e
update build workflow
LittleLittleCloud Jan 2, 2024
a371809
update nuget feed
LittleLittleCloud Jan 2, 2024
997c11e
update nuget feed
LittleLittleCloud Jan 2, 2024
e8000bb
Merge branch 'main' into dotnet
LittleLittleCloud Jan 3, 2024
2484916
update aoai and sk version
LittleLittleCloud Jan 3, 2024
2683bf8
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 3, 2024
9fe94df
Update InteractiveService.cs
LittleLittleCloud Jan 3, 2024
4996384
add support for GPT 4V
LittleLittleCloud Jan 4, 2024
ced9aa9
add DalleAndGPT4V example
LittleLittleCloud Jan 4, 2024
70134ff
update example
LittleLittleCloud Jan 4, 2024
68151e7
Merge branch 'main' into dotnet
LittleLittleCloud Jan 4, 2024
79fe89f
add user proxy agent
LittleLittleCloud Jan 4, 2024
44c1909
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 4, 2024
77bc229
add readme
LittleLittleCloud Jan 4, 2024
3a30558
bump version
LittleLittleCloud Jan 4, 2024
e58ffe3
Merge branch 'main' into dotnet
LittleLittleCloud Jan 4, 2024
ecc3d5f
update example
LittleLittleCloud Jan 5, 2024
21c558d
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 5, 2024
bd1bb55
add dotnet interactive hook
LittleLittleCloud Jan 5, 2024
be28b7f
update
LittleLittleCloud Jan 6, 2024
aeb4d5d
udpate tests
LittleLittleCloud Jan 6, 2024
3af11a9
add website
LittleLittleCloud Jan 8, 2024
e63fce1
update index.md
LittleLittleCloud Jan 8, 2024
25fcd44
add docs
LittleLittleCloud Jan 8, 2024
6c3cae2
update doc
LittleLittleCloud Jan 9, 2024
0200371
move sk dependency out of core package
LittleLittleCloud Jan 9, 2024
f92f2c5
udpate doc
LittleLittleCloud Jan 9, 2024
72bee7a
Update Use-function-call.md
LittleLittleCloud Jan 9, 2024
65beb33
add type safe function call document
LittleLittleCloud Jan 9, 2024
0f6ff32
update doc
LittleLittleCloud Jan 9, 2024
35cc2db
update doc
LittleLittleCloud Jan 9, 2024
b7f406f
add dock
LittleLittleCloud Jan 9, 2024
d3e089c
Update Use-function-call.md
LittleLittleCloud Jan 10, 2024
b46f9ae
add GenerateReplyOptions
LittleLittleCloud Jan 10, 2024
a962863
remove IChatLLM
LittleLittleCloud Jan 10, 2024
fabf047
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 10, 2024
1b8e042
update version
LittleLittleCloud Jan 10, 2024
a161fa1
Merge branch 'main' into dotnet
LittleLittleCloud Jan 10, 2024
5b25261
update doc
LittleLittleCloud Jan 10, 2024
5986659
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 10, 2024
0828b08
update website
LittleLittleCloud Jan 10, 2024
d2427f8
add sample
LittleLittleCloud Jan 11, 2024
16ec7ce
fix link
LittleLittleCloud Jan 11, 2024
46f081c
add middleware agent
LittleLittleCloud Jan 24, 2024
b5a79cd
clean up doc
LittleLittleCloud Jan 24, 2024
6d5c22a
bump version
LittleLittleCloud Jan 24, 2024
0d592b2
update doc
LittleLittleCloud Jan 24, 2024
9d31909
Merge branch 'main' into dotnet
LittleLittleCloud Jan 24, 2024
0693702
update
LittleLittleCloud Jan 24, 2024
c349aa4
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Jan 24, 2024
b90ca63
add Other Language
LittleLittleCloud Jan 24, 2024
06c3cf5
remove warnings
LittleLittleCloud Jan 26, 2024
8e93a28
add sign.props
LittleLittleCloud Jan 26, 2024
e1f1674
add sign step
LittleLittleCloud Jan 26, 2024
aa01ffb
fix pipelien
LittleLittleCloud Jan 26, 2024
fde4369
auth
LittleLittleCloud Jan 26, 2024
feda84f
real sign
LittleLittleCloud Jan 26, 2024
e175e0a
disable PR trigger
LittleLittleCloud Jan 26, 2024
674dee8
update
LittleLittleCloud Jan 26, 2024
0e7efba
disable PR trigger
LittleLittleCloud Jan 26, 2024
fb0dd72
use microbuild machine
LittleLittleCloud Jan 26, 2024
2cf0768
update build pipeline to add publish to internal feed
LittleLittleCloud Feb 1, 2024
d0387ec
add internal feed
LittleLittleCloud Feb 1, 2024
7a113e5
fix build pipeline
LittleLittleCloud Feb 1, 2024
b6a68eb
add dotnet prefix
LittleLittleCloud Feb 1, 2024
bf4fa7a
update ci
LittleLittleCloud Feb 1, 2024
37be1f4
add build number
LittleLittleCloud Feb 1, 2024
f9d1f2e
update run number
LittleLittleCloud Feb 1, 2024
43892f0
update source
LittleLittleCloud Feb 1, 2024
01b15c4
update token
LittleLittleCloud Feb 1, 2024
4bb63f5
update
LittleLittleCloud Feb 1, 2024
1ca29af
remove adding source
LittleLittleCloud Feb 1, 2024
aa96c44
add publish to github package
LittleLittleCloud Feb 1, 2024
f24d36b
try again
LittleLittleCloud Feb 1, 2024
d3ae10e
Merge branch 'main' into dotnet
LittleLittleCloud Feb 1, 2024
067386f
try again
LittleLittleCloud Feb 1, 2024
b742403
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Feb 1, 2024
75ecb8a
ask for write pacakge
LittleLittleCloud Feb 1, 2024
cb3a430
disable package when branch is not main
LittleLittleCloud Feb 1, 2024
f7b5062
update
LittleLittleCloud Feb 8, 2024
a4ee32c
implement streaming agent
LittleLittleCloud Feb 8, 2024
2005552
add test for streaming function call
LittleLittleCloud Feb 8, 2024
f23ca73
update
LittleLittleCloud Feb 9, 2024
221bb8f
fix #1588
LittleLittleCloud Feb 10, 2024
becc618
enable PR check for dotnet branch
LittleLittleCloud Feb 10, 2024
71651c1
add website readme
LittleLittleCloud Feb 10, 2024
058947d
only publish to dotnet feed when pushing to dotnet branch
LittleLittleCloud Feb 10, 2024
6b9d61e
remove openai-test-and-notebooks workflow
LittleLittleCloud Feb 10, 2024
64b1fbf
update readme
LittleLittleCloud Feb 10, 2024
6c933ac
update readme
LittleLittleCloud Feb 10, 2024
f17601c
update workflow
LittleLittleCloud Feb 10, 2024
1007e44
update getting-start
LittleLittleCloud Feb 10, 2024
243fa40
upgrade test and sample proejct to use .net 8
LittleLittleCloud Feb 10, 2024
c3fc32c
fix global.json format && make loadFromConfig API internal only befor…
LittleLittleCloud Feb 10, 2024
3064f95
update
LittleLittleCloud Feb 11, 2024
d49cbfa
add support for LM studio
LittleLittleCloud Feb 11, 2024
30abd24
add doc
LittleLittleCloud Feb 12, 2024
1fe8fb7
Merge pull request #1634 from microsoft/u/xiaoyun/dotnet/LMStudio
LittleLittleCloud Feb 12, 2024
8f233b0
Merge pull request #1620 from microsoft/u/xiaoyun/dotnet/updateToNet8
LittleLittleCloud Feb 12, 2024
5ba675b
Merge branch 'dotnet' into u/xiaoyun/dotnet/#1588
LittleLittleCloud Feb 12, 2024
9d8d721
Merge pull request #1614 from microsoft/u/xiaoyun/dotnet/#1588
LittleLittleCloud Feb 12, 2024
a71ebcb
Merge branch 'dotnet' into u/xiaoyun/dotnet-publish
LittleLittleCloud Feb 12, 2024
2546a5f
Update README.md
LittleLittleCloud Feb 12, 2024
fe2400e
Merge pull request #1619 from microsoft/u/xiaoyun/dotnet-publish
LittleLittleCloud Feb 12, 2024
43fe148
Merge branch 'main' into dotnet
LittleLittleCloud Feb 12, 2024
2c6914a
add push and workflow_dispatch trigger
LittleLittleCloud Feb 12, 2024
2ea68f9
disable PR for main
LittleLittleCloud Feb 12, 2024
b94c81b
add dotnet env
LittleLittleCloud Feb 12, 2024
634dee8
Merge pull request #1649 from microsoft/u/xiaoyun/dotnet/0212
LittleLittleCloud Feb 12, 2024
72272b6
Update Installation.md
LittleLittleCloud Feb 12, 2024
4137d87
add nuget
LittleLittleCloud Feb 12, 2024
283878a
refer to newtonsoft 13
LittleLittleCloud Feb 12, 2024
0235b99
update branch to dotnet in docfx
LittleLittleCloud Feb 12, 2024
bfb59d6
Update Installation.md
LittleLittleCloud Feb 12, 2024
38f4102
Merge branch 'dotnet' into u/xiaoyun/dotnet/middleware
LittleLittleCloud Feb 12, 2024
b95652f
pull out HumanInputMiddleware and FunctionCallMiddleware
LittleLittleCloud Feb 13, 2024
ce81c76
fix tests
LittleLittleCloud Feb 13, 2024
f47e0cc
add link to sample folder
LittleLittleCloud Feb 13, 2024
ef92c1c
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Feb 13, 2024
1486f4b
refactor message
LittleLittleCloud Feb 13, 2024
02997dc
Merge branch 'main' into dotnet
LittleLittleCloud Feb 13, 2024
df54732
Merge branch 'dotnet' into u/xiaoyun/dotnet/middleware
LittleLittleCloud Feb 13, 2024
f876431
refactor over IMessage
LittleLittleCloud Feb 14, 2024
e9a472f
add more tests
LittleLittleCloud Feb 14, 2024
8919058
add more test
LittleLittleCloud Feb 14, 2024
f99659e
fix build error
LittleLittleCloud Feb 14, 2024
1e3364b
rename header
LittleLittleCloud Feb 14, 2024
01e492e
add semantic kernel project
LittleLittleCloud Feb 14, 2024
bccfbc5
update sk example
LittleLittleCloud Feb 14, 2024
a4e592c
Merge branch 'dotnet' into u/xiaoyun/dotnet/message
LittleLittleCloud Feb 14, 2024
1935f70
update dotnet version
LittleLittleCloud Feb 14, 2024
33056d1
add LMStudio function call example
LittleLittleCloud Feb 18, 2024
b0f1693
Merge branch 'main' into dotnet
LittleLittleCloud Feb 18, 2024
a272413
rename LLaMAFunctin
LittleLittleCloud Feb 18, 2024
3875645
remove dotnet run openai test and notebook workflow
LittleLittleCloud Feb 18, 2024
58e27f2
Merge branch 'dotnet' of https://github.com/microsoft/autogen into do…
LittleLittleCloud Feb 18, 2024
5903c9c
Merge branch 'dotnet' into u/xiaoyun/dotnet/addLMStudioFunctionCallEx…
LittleLittleCloud Feb 18, 2024
4dfe314
Merge pull request #1717 from microsoft/u/xiaoyun/dotnet/addLMStudioF…
LittleLittleCloud Feb 18, 2024
4d24b68
Merge branch 'dotnet' into u/xiaoyun/dotnet/message
LittleLittleCloud Feb 20, 2024
3f7c648
Merge branch 'dotnet' into u/xiaoyun/dotnet/middleware
LittleLittleCloud Feb 20, 2024
1fa15a4
add FunctionContract and test
LittleLittleCloud Feb 20, 2024
1e07f47
Merge pull request #1736 from microsoft/u/xiaoyun/FunctionContract
LittleLittleCloud Feb 21, 2024
60356a7
Merge branch 'dotnet' into u/xiaoyun/dotnet/middleware
LittleLittleCloud Feb 21, 2024
4adec32
update doc
LittleLittleCloud Feb 21, 2024
417be15
add documents
LittleLittleCloud Feb 21, 2024
49b2a65
add workflow
LittleLittleCloud Feb 22, 2024
c81ea6f
update
LittleLittleCloud Feb 22, 2024
7a85f58
update sample
LittleLittleCloud Feb 22, 2024
f3570cf
fix warning in test
LittleLittleCloud Feb 22, 2024
7e97604
Merge pull request #1742 from microsoft/u/xiaoyun/updateDoc
LittleLittleCloud Feb 23, 2024
d5b127b
Merge branch 'dotnet' into u/xiaoyun/dotnet-workflow
LittleLittleCloud Feb 23, 2024
70c7dbd
Merge pull request #1761 from microsoft/u/xiaoyun/dotnet-workflow
LittleLittleCloud Feb 23, 2024
ef055b3
Merge branch 'dotnet' into u/xiaoyun/dotnet/middleware
LittleLittleCloud Feb 27, 2024
0cfbf2f
reult length can be less then maximumOutputToKeep (#1804)
mhensen Feb 28, 2024
87a745e
Merge branch 'dotnet' into u/xiaoyun/dotnet/middleware
LittleLittleCloud Feb 28, 2024
e422329
merge with main
LittleLittleCloud Feb 28, 2024
c28b0cc
Merge pull request #1656 from microsoft/u/xiaoyun/dotnet/middleware
LittleLittleCloud Feb 28, 2024
53a481d
Merge branch 'dotnet' into u/xiaoyun/dotnet/message
LittleLittleCloud Feb 28, 2024
3682e8e
Merge branch 'dotnet' into u/xiaoyun/dotnet/message
LittleLittleCloud Feb 29, 2024
979575a
add option to retrieve inner agent and middlewares from MiddlewareAgent
LittleLittleCloud Feb 29, 2024
85f7469
update doc
LittleLittleCloud Feb 29, 2024
138879b
adjust namespace
LittleLittleCloud Feb 29, 2024
463de1e
update readme
LittleLittleCloud Feb 29, 2024
077cb46
fix test
LittleLittleCloud Feb 29, 2024
25498f6
Merge pull request #1821 from microsoft/u/xiaoyun/refactorMiddleware
LittleLittleCloud Feb 29, 2024
4068373
Merge branch 'dotnet' into u/xiaoyun/dotnet/message
LittleLittleCloud Feb 29, 2024
f079405
use IMessage
LittleLittleCloud Feb 29, 2024
5194e23
more updates
LittleLittleCloud Feb 29, 2024
da89fb0
update
LittleLittleCloud Mar 1, 2024
fb36566
fix test
LittleLittleCloud Mar 1, 2024
bc3e1df
add comments
LittleLittleCloud Mar 1, 2024
0d5fdac
use FunctionContract to replace FunctionDefinition
LittleLittleCloud Mar 1, 2024
4a1e288
move AutoGen contrac to AutoGen.Core
LittleLittleCloud Mar 1, 2024
5ed491d
update installation
LittleLittleCloud Mar 1, 2024
273b283
refactor streamingAgent by adding StreamingMessage type
LittleLittleCloud Mar 1, 2024
40265e6
update sample
LittleLittleCloud Mar 1, 2024
a392b23
update samples
LittleLittleCloud Mar 2, 2024
6a268a7
update
LittleLittleCloud Mar 2, 2024
d301ea3
update
LittleLittleCloud Mar 2, 2024
f9ff7e6
add test
LittleLittleCloud Mar 3, 2024
b32f5b5
fix test
LittleLittleCloud Mar 3, 2024
9bb9fd9
bump version
LittleLittleCloud Mar 3, 2024
cbacdc7
add openaichat test
LittleLittleCloud Mar 3, 2024
222a57c
update
LittleLittleCloud Mar 3, 2024
e12a824
Merge pull request #1676 from microsoft/u/xiaoyun/dotnet/message
LittleLittleCloud Mar 3, 2024
14bb413
Update Example03_Agent_FunctionCall.cs
LittleLittleCloud Mar 8, 2024
9f9b380
[.Net] improve docs (#1862)
LittleLittleCloud Mar 8, 2024
2319b7c
[.Net] Add fill form example (#1911)
LittleLittleCloud Mar 12, 2024
44e2aac
[.Net] Add using AutoGen.Core in source generator (#1983)
LittleLittleCloud Mar 12, 2024
c1ba016
disable PR test
LittleLittleCloud Mar 12, 2024
b93c6a3
Add .idea to .gitignore (#1988)
Krzysztof318 Mar 13, 2024
d58f2c8
Merge branch 'main' into dotnet
LittleLittleCloud Mar 13, 2024
0369ec7
[.Net] publish to nuget.org feed (#1987)
LittleLittleCloud Mar 13, 2024
b2d3474
[.Net] Rename some classes && APIs based on doc review (#1980)
LittleLittleCloud Mar 13, 2024
025684d
[.Net] Improve package description (#2161)
LittleLittleCloud Mar 27, 2024
8214a21
[.Net] Fix document comment from the most recent AutoGen.Net engineer…
LittleLittleCloud Apr 2, 2024
27f172f
[.Net] Enable JsonMode and deterministic output in AutoGen.OpenAI Ope…
LittleLittleCloud Apr 11, 2024
ebb4c8c
[.Net] Add AutoGen.Mistral package (#2330)
LittleLittleCloud Apr 20, 2024
e650cf0
Merge branch 'main' into dotnet
LittleLittleCloud Apr 21, 2024
1a60660
track (#2471)
LittleLittleCloud Apr 22, 2024
7cce072
[.Net] add mistral example (#2482)
LittleLittleCloud Apr 23, 2024
7cadfb0
Merge branch 'main' into dotnet
LittleLittleCloud Apr 23, 2024
09de3cc
Update dotnet-release.yml (#2488)
LittleLittleCloud Apr 23, 2024
de2b3a6
Merge branch 'main' into dotnet
LittleLittleCloud Apr 24, 2024
cc4564f
Merge branch 'main' into dotnet
LittleLittleCloud Apr 25, 2024
f34feb6
update
LittleLittleCloud Apr 25, 2024
999371a
revert gitattributes
LittleLittleCloud Apr 25, 2024
3c61969
Merge branch 'main' into dotnet
LittleLittleCloud Apr 25, 2024
5064387
Return ChatCompletions instead of ChatResponseMessage for token usage.
Apr 29, 2024
d6f0404
Merge main
Apr 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/src/AutoGen.Mistral/DTOs/ChatCompletionResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// ChatCompletionResponse.cs

using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/AutoGen.Mistral/DTOs/Error.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Error.cs

using System.Text.Json.Serialization;
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/AutoGen.Mistral/DTOs/Model.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Model.cs

using System;
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task<IMessage> GenerateReplyAsync(
var settings = this.CreateChatCompletionsOptions(options, messages);
var reply = await this.openAIClient.GetChatCompletionsAsync(settings, cancellationToken);

return new MessageEnvelope<ChatResponseMessage>(reply.Value.Choices.First().Message, from: this.Name);
return new MessageEnvelope<ChatCompletions>(reply, from: this.Name);
}

public Task<IAsyncEnumerable<IStreamingMessage>> GenerateStreamingReplyAsync(
Expand All @@ -101,7 +101,7 @@ private async IAsyncEnumerable<IStreamingMessage> StreamingReplyAsync(
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var settings = this.CreateChatCompletionsOptions(options, messages);
var response = await this.openAIClient.GetChatCompletionsStreamingAsync(settings);
var response = await this.openAIClient.GetChatCompletionsStreamingAsync(settings, cancellationToken);
await foreach (var update in response.WithCancellation(cancellationToken))
{
if (update.ChoiceIndex > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public IMessage PostProcessMessage(IMessage message)
Message => message,
AggregateMessage<ToolCallMessage, ToolCallResultMessage> => message,
IMessage<ChatResponseMessage> m => PostProcessMessage(m),
DavidLuong98 marked this conversation as resolved.
Show resolved Hide resolved
IMessage<ChatCompletions> m => PostProcessMessage(m),
_ => throw new InvalidOperationException("The type of message is not supported. Must be one of TextMessage, ImageMessage, MultiModalMessage, ToolCallMessage, ToolCallResultMessage, Message, IMessage<ChatRequestMessage>, AggregateMessage<ToolCallMessage, ToolCallResultMessage>"),
};
}
Expand Down Expand Up @@ -129,15 +130,24 @@ public IMessage PostProcessMessage(IMessage message)

private IMessage PostProcessMessage(IMessage<ChatResponseMessage> message)
{
var chatResponseMessage = message.Content;
return PostProcessMessage(message.Content, message.From);
}

private IMessage PostProcessMessage(IMessage<ChatCompletions> message)
{
return PostProcessMessage(message.Content.Choices[0].Message, message.From);
}

private IMessage PostProcessMessage(ChatResponseMessage chatResponseMessage, string? from)
{
if (chatResponseMessage.Content is string content)
{
return new TextMessage(Role.Assistant, content, message.From);
return new TextMessage(Role.Assistant, content, from);
}

if (chatResponseMessage.FunctionCall is FunctionCall functionCall)
{
return new ToolCallMessage(functionCall.Name, functionCall.Arguments, message.From);
return new ToolCallMessage(functionCall.Name, functionCall.Arguments, from);
}

if (chatResponseMessage.ToolCalls.Where(tc => tc is ChatCompletionsFunctionToolCall).Any())
Expand All @@ -148,7 +158,7 @@ private IMessage PostProcessMessage(IMessage<ChatResponseMessage> message)

var toolCalls = functionToolCalls.Select(tc => new ToolCall(tc.Name, tc.Arguments));

return new ToolCallMessage(toolCalls, message.From);
return new ToolCallMessage(toolCalls, from);
}

throw new InvalidOperationException("Invalid ChatResponseMessage");
Expand Down
7 changes: 4 additions & 3 deletions dotnet/test/AutoGen.Tests/OpenAIChatAgentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ public async Task BasicConversationTestAsync()
var chatMessageContent = MessageEnvelope.Create(new ChatRequestUserMessage("Hello"));
var reply = await openAIChatAgent.SendAsync(chatMessageContent);

reply.Should().BeOfType<MessageEnvelope<ChatResponseMessage>>();
reply.As<MessageEnvelope<ChatResponseMessage>>().From.Should().Be("assistant");
reply.As<MessageEnvelope<ChatResponseMessage>>().Content.Role.Should().Be(ChatRole.Assistant);
reply.Should().BeOfType<MessageEnvelope<ChatCompletions>>();
reply.As<MessageEnvelope<ChatCompletions>>().From.Should().Be("assistant");
reply.As<MessageEnvelope<ChatCompletions>>().Content.Choices.First().Message.Role.Should().Be(ChatRole.Assistant);
reply.As<MessageEnvelope<ChatCompletions>>().Content.Usage.TotalTokens.Should().BeGreaterThan(0);

// test streaming
var streamingReply = await openAIChatAgent.GenerateStreamingReplyAsync(new[] { chatMessageContent });
Expand Down
Loading