mistral_common.experimental.app.main
cli()
create_app(tokenizer, validation_mode=ValidationMode.test, engine_url='127.0.0.1', engine_backend=EngineBackend.llama_cpp, timeout=60)
Create a Mistral-common FastAPI app with the given tokenizer and validation mode.
The app exposes tokenize, decode, and health routes backed by the given tokenizer, and can proxy completions to an external engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tokenizer
|
str | Path | MistralTokenizer
|
Path to a tokenizer file, or an already-loaded MistralTokenizer instance. |
required |
validation_mode
|
ValidationMode
|
The validation mode applied to incoming requests. Only used when tokenizer is a path. |
test
|
engine_url
|
str
|
The URL of the engine API used for chat completions. |
'127.0.0.1'
|
engine_backend
|
EngineBackend
|
The backend type of the engine API. |
llama_cpp
|
timeout
|
int
|
The timeout of the engine API in seconds. |
60
|
Returns:
| Type | Description |
|---|---|
FastAPI
|
The configured FastAPI application. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If tokenizer is neither a path nor a MistralTokenizer. |
Source code in src/mistral_common/experimental/app/main.py
serve(tokenizer_path, validation_mode=ValidationMode.test, host='127.0.0.1', port=0, engine_url='http://127.0.0.1:8080', engine_backend=EngineBackend.llama_cpp.value, timeout=60)
Serve the Mistral-common API with the given tokenizer path and validation mode.