Skip to content

Commit ebffbca

Browse files
mongodbenBen PerlmutternlarewASteinheiser
authored
Documentation page for Responses API (#872)
* document responses api * overview on index page * typo fix * Copy editz * Apply suggestions from code review Co-authored-by: Nick Larew <[email protected]> Co-authored-by: Andrew Steinheiser <[email protected]> * NL feedback --------- Co-authored-by: Ben Perlmutter <[email protected]> Co-authored-by: Nick Larew <[email protected]> Co-authored-by: Andrew Steinheiser <[email protected]>
1 parent c6c47d8 commit ebffbca

File tree

4 files changed

+564
-77
lines changed

4 files changed

+564
-77
lines changed

docs/docs/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ description: MongoDB Knowledge Service
77

88
The MongoDB Knowledge Service lets you learn about MongoDB using generative AI.
99

10-
## Server
10+
## Responses API
11+
12+
To build MongoDB-related conversational AI applications, use the [Responses API](./server/responses-api.md). The Responses API is compatible with the OpenAI API and provides MongoDB-specific knowledge through retrieval-augmented generation.
13+
14+
## Server OpenAPI Specification
1115

1216
To call the MongoDB Knowledge Service API, refer to the [OpenAPI specification](/server/openapi/).
1317

docs/docs/server/openapi.yaml

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -304,82 +304,7 @@ paths:
304304
305305
You can rate or comment on a message using the [rateMessage](#operation/rateMessage) and [commentMessage](#operation/commentMessage) endpoints.
306306
307-
### Basic Example Usage
308-
309-
Example usage with OpenAI client `openai`:
310-
```ts
311-
import { OpenAI } from "openai";
312-
313-
const openai = new OpenAI({ baseURL: "https://knowledge.mongodb.com/api/v1" });
314-
315-
const response = await openai.responses.create({
316-
model: "mongodb-chat-latest",
317-
stream: true,
318-
input: [
319-
{
320-
role: "user",
321-
content: "So what's MongoDB anyways??",
322-
},
323-
],
324-
instructions: "You are located on the MongoDB Atlas cloud platform. Use that as context to inform your response."
325-
});
326-
327-
for await (const event of response) {
328-
console.log(event);
329-
}
330-
```
331-
332-
Example usage with Vercel AI SDK client `@ai-sdk/openai` and `ai`:
333-
```ts
334-
import { streamText } from "ai";
335-
// NOTE: we are using the AI SDK v5-beta with LanguageModelV2
336-
import { createOpenAI } from "@ai-sdk/openai";
337-
338-
const model = createOpenAI({
339-
baseURL: origin + API_PREFIX,
340-
apiKey: TEST_OPENAI_API_KEY,
341-
}).responses("mongodb-chat-latest");
342-
343-
const result = await streamText({
344-
model,
345-
prompt: "What is MongoDB?",
346-
});
347-
348-
for await (const chunk of result.toUIMessageStream()) {
349-
console.log(chunk);
350-
}
351-
```
352-
**NOTE:** We currently only support streaming responses via `streamText`. Methods like `generateText` will not work.
353-
354-
### Features
355-
356-
#### Retrieval-Informed Answers
357-
358-
By default, the API performs retrieval augmented generation under the hood
359-
to generate accurate and up-to-date responses about MongoDB products.
360-
If you provide custom tools to the API via the `tools` parameter,
361-
the API will choose to use the tool or the retrieval tool based on the `tool_choice` parameter.
362-
363-
Default behavior is to allow the model to choose the tool to use.
364-
365-
#### Personality
366-
367-
The AI API has the personality of a helpful MongoDB assistant. You cannot change this core personality.
368-
369-
You can augment the personality via the `instructions` parameter. (E.g. "You are a technical services engineer at MongoDB. Use that as context to inform your response.")
370-
371-
#### Guardrail
372-
373-
The API features a guardrail that helps ensure the input is appropriate for a MongoDB assistant.
374-
This helps ensure the API isn't used for irrelevant or malicious purposes.
375-
376-
#### Tracing and Storage
377-
378-
All messages to the chatbot are traced and stored if `store: true`.
379-
380-
For access to chatbot data, reach out to the Education AI team (`#ask-education-ai` on Slack).
381-
382-
All data retention is in line with MongoDB data retention policies.
307+
For more information on using the Responses API, refer to the [Responses API documentation](./responses-api).
383308
384309
tags:
385310
- Responses

0 commit comments

Comments
 (0)