rust: add Responses web-service sample#682
Open
MaanavD wants to merge 5 commits intomicrosoft:mainfrom
Open
Conversation
|
@MaanavD is attempting to deploy a commit to the MSFT-AIP Team on Vercel. A member of the Team first needs to authorize it. |
fc958c9 to
815c0db
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Rust HTTP-based OpenAI Responses API client to the Foundry Local SDK, including request/response types, SSE streaming support, manager factory wiring, public re-exports, and new unit/integration tests plus an example.
Changes:
- Introduce
ResponsesClient(+ settings) with non-streaming and SSE streaming APIs. - Add
responses_typesmodels for request/response payloads and streaming event shapes; re-export viaopenaiand crate root. - Add unit/integration coverage and a
responsesexample demonstrating non-streaming, streaming, multi-turn, and tool calling.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/rust/src/openai/responses_client.rs | New HTTP client implementation (create/get/delete/cancel/list) + SSE parser. |
| sdk/rust/src/openai/responses_types.rs | New serde models for Responses API payloads + streaming events. |
| sdk/rust/src/openai/mod.rs | Wires new modules and re-exports Responses API surface. |
| sdk/rust/src/lib.rs | Public re-exports of Responses API types/client from crate root. |
| sdk/rust/src/foundry_local_manager.rs | Adds get_responses_client factory based on started web service URL. |
| sdk/rust/examples/responses.rs | End-to-end example for Responses API (streaming + tools + multi-turn). |
| sdk/rust/tests/unit/main.rs | Adds unit test harness for Responses API tests. |
| sdk/rust/tests/unit/responses_test.rs | Adds serverless unit tests for types/serialization and some SSE-related behavior. |
| sdk/rust/tests/integration/main.rs | Registers the new integration test module. |
| sdk/rust/tests/integration/responses_test.rs | Adds end-to-end integration tests for Responses API flows. |
| sdk/rust/Cargo.toml | Adds deps needed for SSE streaming (reqwest stream, bytes, async-stream) and example entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Implements the HTTP Responses API client, wire types, SSE streaming parser, manager factory, tests, and example for the Rust SDK. Also aligns the Rust implementation with resolved Responses API review feedback: opt-in storage, request timeouts, image source validation, optional media type, list pagination fields, get_responses_client naming, and server-matching streaming event shapes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Make responses_client/responses_types modules private; expose only the re-exported public surface (matching audio_client/chat_client/etc). - Introduce ResponseCreateOptions for per-call overrides so callers no longer need to materialize a full ResponseCreateRequest; ResponseCreateRequest stays as the wire-serialized request body. - Move SSE parser tests inline into responses_client.rs so they exercise parse_sse_stream directly instead of duplicating the framing logic in tests/unit. - Skip vision_image_base64 only when FOUNDRY_VISION_MODEL_ID is unset; when set, surface real failures so regressions are caught. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pivot the Rust Responses work away from SDK-native client/types and demonstrate the intended pattern instead: use FoundryLocalManager for setup/model/web-service lifecycle, then call /v1/responses via raw HTTP. Adds a focused responses_web_service example and integration tests for non-streaming, streaming SSE, and function-calling flows against the local OpenAI-compatible web service. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mirror the JavaScript Responses web-service PR by adding a Rust samples/rust/web-server-responses package, registering it in the Rust samples workspace, and documenting it in the sample indexes. Tighten the Rust Responses integration tests to use cached variants, skip CI/local-missing prerequisites, assert response object/status and streaming event types, and use the same simple get_weather tool flow as the reference. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a37cda9 to
9f89490
Compare
Document the Rust web-server Responses sample with prerequisites, restored Cargo dependencies, runtime downloads, and commands for running from either the samples workspace or sample directory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FoundryLocalManagerhandles SDK initialization, model lifecycle, and local OpenAI-compatible web service startup/shutdown./v1/responsesfor the actual Responses calls; no SDK-native Responses client/types or FFI/native Responses surface are added.samples/rust/web-server-responsesplus SDK example coverage for non-streaming, streaming SSE, and tool-calling Responses flows.samples/rustor the sample directory.response.output_text.delta/response.completedstreaming events, and aget_weatherfunction-calling round trip withprevious_response_id.Validation
cargo buildcargo test --test integration responses_test -- --nocapturecargo test --libcargo clippy --all-targetscargo check -p web-server-responsesfromsamples/rustcargo clippy -p web-server-responsesfromsamples/rustNotes
qwen2.5-0.5bmodel is not cached.responses-api-sdk-spec.mdremains local/untracked and is not included in this PR.