Functions
FUNC extract_model_tool_requests
tools: Mapping of tool name toAbstractMelleaToolfor lookup.response: Dict representation of an OpenAI-compatible chat completion message (must contain a"message"key).
- Mapping of tool name to
[ModelToolCall](../core/base#class-modeltoolcall)for each requested tool call, or Noneif no tool calls were found.
FUNC chat_completion_delta_merge
ChatCompletionChunks into a single dict representing the ChatCompletion choice.
Args:
chunks: The list of dicts that represent the message deltas.force_all_tool_calls_separate: IfTrue, tool calls in separate message deltas will not be merged even if their index values are the same. Use when providers do not return the correct index value for tool calls; all tool calls must then be fully populated in a single delta.
- A single merged dict representing the assembled
ChatCompletionchoice, - with
finish_reason,index, and amessagesub-dict containing content,role, andtool_calls.
FUNC message_to_openai_message
Message to the format required by OpenAI-compatible API providers.
Args:
msg: TheMessageobject to serialise.
- A dict with
"role"and"content"fields. When the message carries - images,
"content"is a list of text and image-URL dicts; otherwise it - is a plain string.
FUNC messages_to_docs
Document objects from a list of Message objects.
Args:
msgs: List ofMessageobjects whose_docsattributes are inspected.
- A list of dicts, each with a
"text"key and optional"title"and "doc_id"keys, suitable for passing to an OpenAI-compatible RAG API.