Valid Inputs
These can be passed to ask_llm:
- LLMDocument
strTuple[Literal["user", "assistant", "system", "developer"], str]PIL.Image.Imagepllm.FunctionCallRequestpllm.FunctionCallOutputpllm.MCPOutputpllm.FileInputpllm.ImageURLDocumentpllm.MultiPartDocument
- LLMResponse
- The provider's original
dictformat.
Description of possible inputs¶
All of the following can be passed into ask_llm directly:
-
An LLMDocument is an input document for an LLM, which falls under 2 categories.
-
Primitive documents include
str,PIL.Image.Image, andTuple[Literal["user", "assistant", "system", "developer"], str]. -
Non-primitive documents inherit from AskItem , and include
FunctionCallRequest,FunctionCallOutput,MCPOutput,FileInput,ImageURLDocument, andMultipartDocument.
-
-
An LLMResponse is an output obtained from an LLM.
OpenAI Chat Completions API¶
Documents are required to be 1-to-1 compatible and interconvertible with the OpenAI Chat Completions API, which has the form:
message = {
"role": "user"
"content": [
{
"type": xxx,
xxx: yyy
}
]
}
| ParaLLeM input type | OpenAI Chat Completions type |
|---|---|
str |
Message with 1 content part of type text |
PIL.Image.Image |
Message with 1 content part of type image_url, base64-encoded data |
Tuple[Literal["user", "assistant", "system", "developer"], str] |
Message with corresponding role |
FunctionCallRequest |
Message with assistant role and tool_calls field |
FunctionCallOutput |
Message with tool role |
MCPOutput |
Message with tool role |
FileInput |
Message with 1 content part of type file |
ImageURLDocument |
Message with 1 content part of type image_url |
MultiPartDocument |
Message with ≥1 content part(s) |
Use MultipartDocument to explicitly describe messages which have multiple parts.
Guarantees¶
-
While the exact conversion between ParaLLeM and OpenAI Chat Completions may be subject to change, it is guaranteed that valid OpenAI Chat Completions can always be losslessly converted to ParaLLeM's types and back (see
parallem.core.convert.completions.py) -
If a
dictis provided, it will remain untouched.- For example, if your provider is OpenAI Responses API, you can pass a
dictto configure their settings. However, it will not be model agnostic.
- For example, if your provider is OpenAI Responses API, you can pass a