meta-llama / llama-stack

Model components of the Llama Stack APIs
MIT License
4.34k stars 553 forks source link

Add config file based CLI #60

Closed yanxi0830 closed 1 month ago

yanxi0830 commented 1 month ago

Example 1 - local + conda

Build

$ llama stack build
Enter value for name (required): a
Enter value for distribution (default: local) (required): 
Enter value for api_providers (optional): 
Enter value for image_type (default: conda) (required): 

...
...
YAML configuration has been written to /home/xiyan/.llama/builds/local/conda/a.yaml
Target `a` built with configuration at /home/xiyan/.llama/builds/local/conda/a.yaml
Build spec configuration saved at /home/xiyan/.llama/distributions/local/conda/a-build.yaml

Build from config file

$ cat ~/.llama/distributions/local/conda/8b-test-build.yaml
name: 8b-test
distribution: local
api_providers: null
package_type: conda_env

$ llama stack build --config ~/.llama/distributions/local/conda/a-build.yaml

Configure

# reconfigure the run.yaml file
$ llama stack configure ~/.llama/builds/local/conda/a.yaml

Configuration already exists for local. Will overwrite...
Configuring API: inference (meta-reference)
Enter value for model (existing: Meta-Llama3.1-8B-Instruct) (required): 
Enter value for quantization (optional): 
Enter value for torch_seed (optional): 
Enter value for max_seq_len (existing: 4096) (required): 
Enter value for max_batch_size (existing: 1) (required): 

Configuring API: memory (meta-reference-faiss)

Configuring API: safety (meta-reference)
Do you want to configure llama_guard_shield? (y/n): n
Do you want to configure prompt_guard_shield? (y/n): n

Configuring API: agentic_system (meta-reference)
Enter value for brave_search_api_key (optional): 
Enter value for wolfram_api_key (optional): 

YAML configuration has been written to /home/xiyan/.llama/builds/local/conda/a.yaml

Run

llama stack run ~/.llama/builds/local/conda/8b-test.yaml --port 5001
$ cat ~/.llama/builds/local/conda/8b-test.yaml
built_at: '2024-09-10T13:50:32.981692'
package_name: 8b-test
distribution_type: local
docker_image: null
conda_env: 8b-test
providers:
  inference:
    provider_type: meta-reference
    model: Meta-Llama3.1-8B-Instruct
    quantization: null
    torch_seed: null
    max_seq_len: 4096
    max_batch_size: 1
  memory:
    provider_type: meta-reference-faiss
  safety:
    provider_type: meta-reference
    llama_guard_shield: null
    prompt_guard_shield: null
  agentic_system:
    provider_type: meta-reference
    brave_search_api_key: null
    wolfram_api_key: null

EXAMPLE 2 - remote api + docker

Build

$ llama stack build
Enter value for name (required): pgvector
Enter value for distribution (default: local) (required): adhoc
Enter value for api_providers (optional): memory=remote::pgvector
Enter value for image_type (default: conda) (required):

Run

llama stack run ~/.llama/builds/local/conda/pgvector.yaml --port 5001
hardikjshah commented 1 month ago

In your test plan, when looking at the commands for the first time, its unclear what should be in the yaml file. Can you show your yaml file contents inline so that one can be clear about exactly what is required as part of the yaml.

Also, this might be useful in the --help of these commands so that a first time user can be made aware.