Conversation
Implements the Alpha2 Conversation API in the JS SDK with support for: - Multi-role messages (developer, system, user, assistant, tool) - Tool calling (function tools with parameters) - Tool choice control - PII scrubbing - Temperature control - Context/session management Adds both gRPC and HTTP client implementations. Agent-Logs-Url: https://github.com/dapr/js-sdk/sessions/86aa791b-557e-4db5-84a3-4f1aef4e1d0d Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
This is a tracking PR for implementing the Alpha2 Conversation API in the Dapr JS SDK. See PR description for full details. Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dapr/js-sdk/sessions/ebf22fdd-6d4d-4d62-9776-b5ed762be140 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
WhitWaldo
left a comment
There was a problem hiding this comment.
Please address the changes
There was a problem hiding this comment.
This file is not necessary and can be deleted.
…ConversationOptions, extract inputs as required param, add promptCacheRetention and responseFormat, rename name to conversationComponentName, delete issues/jobs-api-support.md Agent-Logs-Url: https://github.com/dapr/js-sdk/sessions/485d7ce7-4ca6-420b-be90-98ffa19b25db Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
WhitWaldo
left a comment
There was a problem hiding this comment.
Could you please add unit and integration tests proving that this works? Please strive for at least 80% test coverage for unit tests and as many integration test paths as you can manage.
Add comprehensive tests for HTTPClientConversation and GRPCClientConversation covering all message roles, options, request building, response mapping, tool calls, edge cases, and error handling. 68 tests total with 100% statement/function coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Added 68 unit tests across two test files in b56e5a2:
Coverage: 100% statements, 100% functions, 100% lines, ~91% branches. Tests cover all 5 message roles, all optional parameters, request/response mapping, tool calls, edge cases, and error propagation. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
WhitWaldo
left a comment
There was a problem hiding this comment.
Please also add integration tests utilizing Testcontainers
… + gRPC) Agent-Logs-Url: https://github.com/dapr/js-sdk/sessions/974b00f8-cad1-4955-bf91-95fd1cc4c8a0 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dapr/js-sdk/sessions/974b00f8-cad1-4955-bf91-95fd1cc4c8a0 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Added in 23c0044. Created Note: The conversation alpha2 API requires Dapr >= 1.16.0, so the test uses its own image constants defaulting to 1.16.0 instead of the shared 1.15.x constants. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Description
Adds first-class support for the Dapr Conversation API (Alpha2) to the JS SDK, including user-facing types, a client interface, both gRPC and HTTP implementations, comprehensive unit tests, and Testcontainers integration tests.
Changes Made
src/types/conversation/Conversation.type.ts): Added user-facing TypeScript types for the Alpha2 Conversation API, including message roles (developer, system, user, assistant, tool), tool definitions, tool calls, and response types.ConversationOptions: Optional parameters forconverse()includingcontextId,metadata,scrubPii,temperature,tools,toolChoice,promptCacheRetention, andresponseFormat.src/interfaces/Client/IClientConversation.ts): Definesconverse(conversationComponentName, inputs, options?)withinputsas a required parameter andconversationComponentNameas the first positional parameter for clarity.src/implementation/Client/GRPCClient/conversation.ts): Maps user-facing types to proto schemas via ConnectRPC bindings and callsconverseAlpha2.src/implementation/Client/HTTPClient/conversation.ts): Maps to thev1.0-alpha2/conversation/{name}/converseREST endpoint, includingpromptCacheRetentionandresponseFormatin the request body.src/implementation/Client/DaprClient.ts): Exposesclient.conversation.converse()for both gRPC and HTTP transports.src/index.ts): All new conversation types and interfaces are exported from the package index.test/unit/protocols/http/conversation.test.ts): 37 tests for HTTPClientConversation covering all message roles, optional parameters, request body building, response mapping, tool calls, edge cases, and error propagation.test/unit/protocols/grpc/conversation.test.ts): 31 tests for GRPCClientConversation covering all message roles, proto message building, tool building, response mapping, and edge cases.test/e2e/common/conversation.test.ts): 14 Testcontainers-based integration tests (7 HTTP + 7 gRPC) exercising the conversation API against a real Dapr 1.16 sidecar with theconversation.echocomponent. Tests cover simple user messages, system messages, metadata passing, temperature option, multiple inputs, multiple content items, and error handling for non-existent components.test/e2e/helpers/containers.ts): AddedbuildConversationEchoComponent()helper for creating the echo conversation component used in integration tests.package.json): Addedtest:e2e:common:conversationscript and wired it into thetest:e2e:commonpipeline.Note: The Conversation API Alpha2 requires Dapr >= 1.16.0. The integration tests use Dapr 1.16.0 images by default (overridable via
DAPR_RUNTIME_VERenv var).Issue reference
N/A — this implements the Alpha2 Conversation API surface for the JS SDK.
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: