Extending LlamaFarm
LlamaFarm is designed to be extended. This guide shows how to add new runtime providers, vector stores, parsers, extractors, and CLI commands while keeping schema validation intact.
Extend Runtimes
- Update the schema: add your provider to
runtime.provider
inconfig/schema.yaml
. - Regenerate types:
cd config
./generate-types.sh
cd .. - Implement routing:
- Server: update runtime selection (e.g.,
server/services/runtime_service.py
) to handle the new provider and base URL. - CLI: ensure
config/datamodel.py
exposes your provider; if special flags are needed, add them undercli/cmd
.
- Server: update runtime selection (e.g.,
- Document usage: add a section to this guide and the Configuration doc showing sample
llamafarm.yaml
.
Example (vLLM running with OpenAI-compatible API):
runtime:
provider: openai
model: mistral-small
base_url: http://localhost:8000/v1
api_key: sk-test
No code changes required—just point base_url
to your gateway.
Extend RAG Components
Add a Vector Store
- Implement a store class (Python) that matches the existing store interface.
- Register it with the RAG service so the server can instantiate it.
- Add the store name to
rag/schema.yaml
underdatabaseDefinition.type
. - Regenerate types and document configuration fields.
Add a Parser or Extractor
- Implement the parser/extractor (Python) with the required
process
signature. - Register it in the ingestion pipeline.
- Append the new enum to
rag/schema.yaml
(parsers
orextractors
definitions) and define its config schema. - Regenerate types and update docs with usage examples.
Extend the CLI
lf
is built with Cobra.
- Create a new file under
cli/cmd
(e.g.,backup.go
). - Define a
var myCmd = &cobra.Command{...}
and add it ininit()
withrootCmd.AddCommand(myCmd)
or attach it to a namespace (datasets/rag). - Follow existing patterns for config resolution (
config.GetServerConfig
), auto-starting the server (ensureServerAvailable
), and output formatting. - Write tests in
cli/cmd/..._test.go
if behaviour is complex. - Document the command in the CLI reference.
Testing Extensions
- Schema validation: run
uv run --group test python -m pytest config/tests
. - CLI:
cd cli && go test ./...
. - Server: execute relevant pytest suites (e.g.,
tests/test_project_chat_orchestrator.py
). - Docs: update this page and run
nx build docs
to ensure navigation stays intact.
Contribution Checklist
- Update schemas and regenerate types.
- Add or update server/CLI logic.
- Write tests covering new behaviour.
- Document configuration and usage.
- Note changes in
README.md
or example configs if appropriate.
Have questions? Open a discussion or join the Discord. We’re excited to see what you build.