Skip to content

Commit bfd517f

Browse files
committed
Fix chat API field names and structure
- Change 'provider' to 'source' with correct camelCase values - Change 'prompt' to 'prompts' object with system field - Remove 'model' from settings (specified at runtime) - Fix workspace object to only have 'uid' field - Remove double quotes from Azure OpenAI in tabs - Remove managing conversations section from guide
1 parent a40b34c commit bfd517f

File tree

3 files changed

+73
-159
lines changed

3 files changed

+73
-159
lines changed

guides/ai/getting_started_with_chat.mdx

Lines changed: 25 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -42,69 +42,74 @@ Create a workspace with your LLM provider settings. Here are examples for differ
4242

4343
<CodeGroup>
4444

45-
```bash OpenAI
45+
```bash openAi
4646
curl \
4747
-X PUT 'http://localhost:7700/chats/my-assistant/settings' \
4848
-H 'Authorization: Bearer MASTER_KEY' \
4949
-H 'Content-Type: application/json' \
5050
--data-binary '{
51-
"provider": "openai",
52-
"model": "gpt-3.5-turbo",
51+
"source": "openAi",
5352
"apiKey": "sk-...",
54-
"prompt": "You are a helpful assistant. Answer questions based only on the provided context."
53+
"prompts": {
54+
"system": "You are a helpful assistant. Answer questions based only on the provided context."
55+
}
5556
}'
5657
```
5758

58-
```bash "Azure OpenAI"
59+
```bash azureOpenAi
5960
curl \
6061
-X PUT 'http://localhost:7700/chats/my-assistant/settings' \
6162
-H 'Authorization: Bearer MASTER_KEY' \
6263
-H 'Content-Type: application/json' \
6364
--data-binary '{
64-
"provider": "azure_openai",
65-
"model": "gpt-35-turbo",
65+
"source": "azureOpenAi",
6666
"apiKey": "your-azure-key",
6767
"baseUrl": "https://your-resource.openai.azure.com",
68-
"prompt": "You are a helpful assistant. Answer questions based only on the provided context."
68+
"prompts": {
69+
"system": "You are a helpful assistant. Answer questions based only on the provided context."
70+
}
6971
}'
7072
```
7173

72-
```bash Mistral
74+
```bash mistral
7375
curl \
7476
-X PUT 'http://localhost:7700/chats/my-assistant/settings' \
7577
-H 'Authorization: Bearer MASTER_KEY' \
7678
-H 'Content-Type: application/json' \
7779
--data-binary '{
78-
"provider": "mistral",
79-
"model": "mistral-small-latest",
80+
"source": "mistral",
8081
"apiKey": "your-mistral-key",
81-
"prompt": "You are a helpful assistant. Answer questions based only on the provided context."
82+
"prompts": {
83+
"system": "You are a helpful assistant. Answer questions based only on the provided context."
84+
}
8285
}'
8386
```
8487

85-
```bash Gemini
88+
```bash gemini
8689
curl \
8790
-X PUT 'http://localhost:7700/chats/my-assistant/settings' \
8891
-H 'Authorization: Bearer MASTER_KEY' \
8992
-H 'Content-Type: application/json' \
9093
--data-binary '{
91-
"provider": "gemini",
92-
"model": "gemini-1.5-flash",
94+
"source": "gemini",
9395
"apiKey": "your-gemini-key",
94-
"prompt": "You are a helpful assistant. Answer questions based only on the provided context."
96+
"prompts": {
97+
"system": "You are a helpful assistant. Answer questions based only on the provided context."
98+
}
9599
}'
96100
```
97101

98-
```bash vLLM
102+
```bash vllm
99103
curl \
100104
-X PUT 'http://localhost:7700/chats/my-assistant/settings' \
101105
-H 'Authorization: Bearer MASTER_KEY' \
102106
-H 'Content-Type: application/json' \
103107
--data-binary '{
104-
"provider": "vllm",
105-
"model": "meta-llama/Llama-3-8b-chat-hf",
108+
"source": "vllm",
106109
"baseUrl": "http://localhost:8000",
107-
"prompt": "You are a helpful assistant. Answer questions based only on the provided context."
110+
"prompts": {
111+
"system": "You are a helpful assistant. Answer questions based only on the provided context."
112+
}
108113
}'
109114
```
110115

@@ -210,96 +215,6 @@ for await (const chunk of stream) {
210215
211216
</CodeGroup>
212217
213-
## Managing conversations
214-
215-
Since the chat API is stateless, maintain conversation history client-side:
216-
217-
<CodeGroup>
218-
219-
```javascript JavaScript
220-
import OpenAI from 'openai';
221-
222-
class ChatConversation {
223-
constructor(apiKey) {
224-
this.client = new OpenAI({
225-
baseURL: 'http://localhost:7700/chats/my-assistant',
226-
apiKey: apiKey,
227-
});
228-
this.messages = [];
229-
}
230-
231-
async sendMessage(content) {
232-
// Add user message to history
233-
this.messages.push({ role: 'user', content });
234-
235-
// Send conversation with history
236-
const stream = await this.client.chat.completions.create({
237-
model: 'gpt-3.5-turbo',
238-
messages: this.messages,
239-
stream: true,
240-
});
241-
242-
// Collect assistant response
243-
let assistantMessage = '';
244-
for await (const chunk of stream) {
245-
const content = chunk.choices[0]?.delta?.content || '';
246-
assistantMessage += content;
247-
}
248-
249-
// Add assistant response to history
250-
this.messages.push({ role: 'assistant', content: assistantMessage });
251-
252-
return assistantMessage;
253-
}
254-
}
255-
256-
// Usage
257-
const chat = new ChatConversation('YOUR_MEILISEARCH_API_KEY');
258-
const response = await chat.sendMessage('What is Meilisearch?');
259-
console.log(response);
260-
```
261-
262-
```python Python
263-
from openai import OpenAI
264-
265-
class ChatConversation:
266-
def __init__(self, api_key):
267-
self.client = OpenAI(
268-
base_url="http://localhost:7700/chats/my-assistant",
269-
api_key=api_key
270-
)
271-
self.messages = []
272-
273-
def send_message(self, content):
274-
# Add user message to history
275-
self.messages.append({"role": "user", "content": content})
276-
277-
# Send conversation with history
278-
stream = self.client.chat.completions.create(
279-
model="gpt-3.5-turbo",
280-
messages=self.messages,
281-
stream=True
282-
)
283-
284-
# Collect assistant response
285-
assistant_message = ""
286-
for chunk in stream:
287-
if chunk.choices[0].delta.content is not None:
288-
assistant_message += chunk.choices[0].delta.content
289-
290-
# Add assistant response to history
291-
self.messages.append({"role": "assistant", "content": assistant_message})
292-
293-
return assistant_message
294-
295-
# Usage
296-
chat = ChatConversation("YOUR_MEILISEARCH_API_KEY")
297-
response = chat.send_message("What is Meilisearch?")
298-
print(response)
299-
```
300-
301-
</CodeGroup>
302-
303218
## Next steps
304219
305220
- Explore [advanced chat API features](/reference/api/chats)

learn/ai_powered_search/conversational_search_with_chat.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Meilisearch's chatCompletions consolidates these into one streamlined process:
6969

7070
The chatCompletions feature operates through workspaces, which are isolated configurations for different use cases or tenants. Each workspace can:
7171

72-
- Use different LLM providers (OpenAI, Azure OpenAI, Mistral, Gemini, vLLM)
72+
- Use different LLM sources (openAi, azureOpenAi, mistral, gemini, vllm)
7373
- Apply custom prompts
7474
- Access specific indexes based on API keys
7575
- Maintain separate conversation contexts

reference/api/chats.mdx

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,33 @@ The chatCompletions feature is experimental and must be enabled through [experim
1717

1818
```json
1919
{
20-
"workspace": "customer-support",
21-
"createdAt": "2024-01-15T09:30:00Z",
22-
"updatedAt": "2024-01-15T14:45:00Z"
20+
"uid": "customer-support"
2321
}
2422
```
2523

26-
| Name | Type | Description |
27-
| :--------------- | :----- | :---------------------------------------------------------------------------------------------- |
28-
| **`workspace`** | String | Unique identifier for the chatCompletions workspace |
29-
| **`createdAt`** | String | Creation date of the workspace, represented in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format |
30-
| **`updatedAt`** | String | Latest update date of the workspace, represented in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format |
24+
| Name | Type | Description |
25+
| :---------- | :----- | :-------------------------------------------------- |
26+
| **`uid`** | String | Unique identifier for the chatCompletions workspace |
3127

3228
## ChatCompletions settings object
3329

3430
```json
3531
{
36-
"provider": "openai",
37-
"model": "gpt-3.5-turbo",
32+
"source": "openAi",
3833
"apiKey": "sk-...",
3934
"baseUrl": "https://api.openai.com/v1",
40-
"prompt": "You are a helpful assistant that answers questions based on the provided context."
35+
"prompts": {
36+
"system": "You are a helpful assistant that answers questions based on the provided context."
37+
}
4138
}
4239
```
4340

4441
| Name | Type | Description |
4542
| :------------- | :----- | :------------------------------------------------------------------------------------ |
46-
| **`provider`** | String | LLM provider: `"openai"`, `"azure_openai"`, `"mistral"`, `"gemini"`, or `"vllm"` |
47-
| **`model`** | String | Model identifier (e.g., `"gpt-3.5-turbo"`) |
48-
| **`apiKey`** | String | API key for the LLM provider (write-only, optional for vLLM) |
49-
| **`baseUrl`** | String | Base URL for the provider (required for Azure OpenAI and vLLM) |
50-
| **`prompt`** | String | System prompt to guide the assistant's behavior |
43+
| **`source`** | String | LLM source: `"openAi"`, `"azureOpenAi"`, `"mistral"`, `"gemini"`, or `"vllm"` |
44+
| **`apiKey`** | String | API key for the LLM provider (write-only, optional for vllm) |
45+
| **`baseUrl`** | String | Base URL for the provider (required for azureOpenAi and vllm) |
46+
| **`prompts`** | Object | Prompts object containing system prompts and other configuration |
5147

5248
## Chat completions
5349

@@ -179,10 +175,11 @@ Configure the LLM provider and settings for a chat workspace.
179175

180176
```json
181177
{
182-
"provider": "openai",
183-
"model": "gpt-3.5-turbo",
178+
"source": "openAi",
184179
"apiKey": "sk-...",
185-
"prompt": "You are a helpful assistant."
180+
"prompts": {
181+
"system": "You are a helpful assistant."
182+
}
186183
}
187184
```
188185

@@ -196,69 +193,74 @@ Returns the updated settings object. Note that `apiKey` is write-only and will n
196193

197194
<CodeGroup>
198195

199-
```bash OpenAI
196+
```bash openAi
200197
curl \
201198
-X PUT 'http://localhost:7700/chats/customer-support/settings' \
202199
-H 'Authorization: Bearer MASTER_KEY' \
203200
-H 'Content-Type: application/json' \
204201
--data-binary '{
205-
"provider": "openai",
206-
"model": "gpt-4",
202+
"source": "openAi",
207203
"apiKey": "sk-...",
208-
"prompt": "You are a helpful customer support assistant."
204+
"prompts": {
205+
"system": "You are a helpful customer support assistant."
206+
}
209207
}'
210208
```
211209

212-
```bash "Azure OpenAI"
210+
```bash azureOpenAi
213211
curl \
214212
-X PUT 'http://localhost:7700/chats/customer-support/settings' \
215213
-H 'Authorization: Bearer MASTER_KEY' \
216214
-H 'Content-Type: application/json' \
217215
--data-binary '{
218-
"provider": "azure_openai",
219-
"model": "gpt-4",
216+
"source": "azureOpenAi",
220217
"apiKey": "your-azure-api-key",
221218
"baseUrl": "https://your-resource.openai.azure.com",
222-
"prompt": "You are a helpful customer support assistant."
219+
"prompts": {
220+
"system": "You are a helpful customer support assistant."
221+
}
223222
}'
224223
```
225224

226-
```bash Mistral
225+
```bash mistral
227226
curl \
228227
-X PUT 'http://localhost:7700/chats/customer-support/settings' \
229228
-H 'Authorization: Bearer MASTER_KEY' \
230229
-H 'Content-Type: application/json' \
231230
--data-binary '{
232-
"provider": "mistral",
233-
"model": "mistral-large-latest",
231+
"source": "mistral",
234232
"apiKey": "your-mistral-api-key",
235-
"prompt": "You are a helpful customer support assistant."
233+
"prompts": {
234+
"system": "You are a helpful customer support assistant."
235+
}
236236
}'
237237
```
238238

239-
```bash Gemini
239+
```bash gemini
240240
curl \
241241
-X PUT 'http://localhost:7700/chats/customer-support/settings' \
242242
-H 'Authorization: Bearer MASTER_KEY' \
243243
-H 'Content-Type: application/json' \
244244
--data-binary '{
245-
"provider": "gemini",
246-
"model": "gemini-1.5-pro",
245+
"source": "gemini",
247246
"apiKey": "your-gemini-api-key",
248-
"prompt": "You are a helpful customer support assistant."
247+
"prompts": {
248+
"system": "You are a helpful customer support assistant."
249+
}
249250
}'
250251
```
251252

252-
```bash vLLM
253+
```bash vllm
253254
curl \
254255
-X PUT 'http://localhost:7700/chats/customer-support/settings' \
255256
-H 'Authorization: Bearer MASTER_KEY' \
256257
-H 'Content-Type: application/json' \
257258
--data-binary '{
258-
"provider": "vllm",
259-
"model": "llama-3-8b",
259+
"source": "vllm",
260260
"baseUrl": "http://your-vllm-server:8000",
261-
"prompt": "You are a helpful customer support assistant."
261+
"prompts": {
262+
"system": "You are a helpful customer support assistant."
263+
}
262264
}'
263265
```
264266

@@ -282,9 +284,10 @@ Returns the settings object without the `apiKey` field.
282284

283285
```json
284286
{
285-
"provider": "openai",
286-
"model": "gpt-3.5-turbo",
287-
"prompt": "You are a helpful assistant."
287+
"source": "openAi",
288+
"prompts": {
289+
"system": "You are a helpful assistant."
290+
}
288291
}
289292
```
290293

@@ -340,14 +343,10 @@ curl \
340343
{
341344
"results": [
342345
{
343-
"workspace": "customer-support",
344-
"createdAt": "2024-01-15T09:30:00Z",
345-
"updatedAt": "2024-01-15T14:45:00Z"
346+
"uid": "customer-support"
346347
},
347348
{
348-
"workspace": "internal-docs",
349-
"createdAt": "2024-01-16T10:00:00Z",
350-
"updatedAt": "2024-01-16T10:00:00Z"
349+
"uid": "internal-docs"
351350
}
352351
],
353352
"offset": 0,

0 commit comments

Comments
 (0)