Meili.Chat (Meili v0.1.0)

Copy Markdown View Source

Manages Meilisearch conversational search workspaces and chat completions.

Summary

Functions

Performs a chat completion request in a specific workspace.

Gets settings for a specific chat workspace.

Gets settings for a specific chat workspace, raising on error.

Resets settings for a specific chat workspace to their defaults.

Resets settings for a specific chat workspace, raising on error.

Updates settings for a specific chat workspace, raising on error.

Functions

completions(client_or_workspace, workspace_or_body \\ nil, body_or_opts \\ [], opts \\ [])

Performs a chat completion request in a specific workspace.

Additional Req options (like :into for streaming chunks) can be passed in the opts keyword list.

Examples

body = %{
  model: "gpt-4",
  messages: [%{role: "user", content: "Hello!"}],
  stream: true
}
# Streaming with into:
Meili.Chat.completions("default", body, into: fn {:data, chunk}, state ->
  IO.write(chunk)
  {:cont, state}
end)

completions!(client_or_workspace, workspace_or_body \\ nil, body_or_opts \\ [], opts \\ [])

Performs a chat completion request, raising on error.

get_settings(client_or_workspace, workspace_or_nil \\ nil)

Gets settings for a specific chat workspace.

Examples

Meili.Chat.get_settings("default")
Meili.Chat.get_settings(client, "default")

get_settings!(client_or_workspace, workspace_or_nil \\ nil)

Gets settings for a specific chat workspace, raising on error.

reset_settings(client_or_workspace, workspace_or_nil \\ nil)

Resets settings for a specific chat workspace to their defaults.

Examples

Meili.Chat.reset_settings("default")
Meili.Chat.reset_settings(client, "default")

reset_settings!(client_or_workspace, workspace_or_nil \\ nil)

Resets settings for a specific chat workspace, raising on error.

update_settings(client_or_workspace, workspace_or_settings \\ nil, settings_or_nil \\ nil)

Updates settings for a specific chat workspace.

Examples

settings = %{
  searchable_attributes: ["title"],
  system_prompt: "You are a helpful assistant."
}
Meili.Chat.update_settings("default", settings)
Meili.Chat.update_settings(client, "default", settings)

update_settings!(client_or_workspace, workspace_or_settings \\ nil, settings_or_nil \\ nil)

Updates settings for a specific chat workspace, raising on error.