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.providerinconfig/schema.yaml. - Regenerate types:
cd config
uv run python generate_types.py
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.pyexposes 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.yamlunderdatabaseDefinition.type. - Regenerate types and document configuration fields.
Add a Parser or Extractor
- Implement the parser/extractor (Python) with the required
processsignature. - Register it in the ingestion pipeline.
- Append the new enum to
rag/schema.yaml(parsersorextractorsdefinitions) 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.goif 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 docsto 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.mdor example configs if appropriate.
Have questions? Open a discussion or join the Discord. We’re excited to see what you build.