diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..85de9cf93 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +src diff --git a/docs/source/distributions/index.md b/docs/source/distributions/index.md new file mode 100644 index 000000000..157747a49 --- /dev/null +++ b/docs/source/distributions/index.md @@ -0,0 +1,134 @@ +# Building Distributions + + +```{toctree} +:maxdepth: 2 +:hidden: + +self_hosted_distro/index +remote_hosted_distro/index +ondevice_distro/index +``` + +## Decide Your Build Type +There are two ways to start a Llama Stack: + +- **Docker**: we provide a number of pre-built Docker containers allowing you to get started instantly. If you are focused on application development, we recommend this option. +- **Conda**: the `llama` CLI provides a simple set of commands to build, configure and run a Llama Stack server containing the exact combination of providers you wish. We have provided various templates to make getting started easier. + +Both of these provide options to run model inference using our reference implementations, Ollama, TGI, vLLM or even remote providers like Fireworks, Together, Bedrock, etc. + +### Decide Your Inference Provider + +Running inference on the underlying Llama model is one of the most critical requirements. Depending on what hardware you have available, you have various options. Note that each option have different necessary prerequisites. + +- **Do you have access to a machine with powerful GPUs?** +If so, we suggest: + - [distribution-meta-reference-gpu](./self_hosted_distro/meta-reference-gpu.md) + - [distribution-tgi](./self_hosted_distro/tgi.md) + +- **Are you running on a "regular" desktop machine?** +If so, we suggest: + - [distribution-ollama](./self_hosted_distro/ollama.md) + +- **Do you have an API key for a remote inference provider like Fireworks, Together, etc.?** If so, we suggest: + - [distribution-together](./remote_hosted_distro/together.md) + - [distribution-fireworks](./remote_hosted_distro/fireworks.md) + +- **Do you want to run Llama Stack inference on your iOS / Android device** If so, we suggest: + - [iOS](./ondevice_distro/ios_sdk.md) + - [Android](https://github.com/meta-llama/llama-stack-client-kotlin) (coming soon) + +Please see our pages in detail for the types of distributions we offer: + +1. [Self-Hosted Distribution](./self_hosted_distro/index.md): If you want to run Llama Stack inference on your local machine. +2. [Remote-Hosted Distribution](./remote_hosted_distro/index.md): If you want to connect to a remote hosted inference provider. +3. [On-device Distribution](./ondevice_distro/index.md): If you want to run Llama Stack inference on your iOS / Android device. + +## Building Your Own Distribution + +### Prerequisites + +```bash +$ git clone git@github.com:meta-llama/llama-stack.git +``` + +### System Requirements + +::::{tab-set} + +:::{tab-item} meta-reference-gpu +##### System Requirements +Access to Single-Node GPU to start a local server. + +##### Downloading Models +Please make sure you have Llama model checkpoints downloaded in `~/.llama` before proceeding. See [installation guide](../cli_reference/download_models.md) here to download the models. + +``` +$ ls ~/.llama/checkpoints +Llama3.1-8B Llama3.2-11B-Vision-Instruct Llama3.2-1B-Instruct Llama3.2-90B-Vision-Instruct Llama-Guard-3-8B +Llama3.1-8B-Instruct Llama3.2-1B Llama3.2-3B-Instruct Llama-Guard-3-1B Prompt-Guard-86M +``` + +::: + +:::{tab-item} vLLM +##### System Requirements +Access to Single-Node GPU to start a vLLM server. +::: + +:::{tab-item} tgi +##### System Requirements +Access to Single-Node GPU to start a TGI server. +::: + +:::{tab-item} ollama +##### System Requirements +Access to Single-Node CPU/GPU able to run ollama. +::: + +:::{tab-item} together +##### System Requirements +Access to Single-Node CPU with Together hosted endpoint via API_KEY from [together.ai](https://api.together.xyz/signin). +::: + +:::{tab-item} fireworks +##### System Requirements +Access to Single-Node CPU with Fireworks hosted endpoint via API_KEY from [fireworks.ai](https://fireworks.ai/). +::: + +:::: + +### Starting the Distribution + +::::{tab-set} +:::{tab-item} meta-reference-gpu +- [Start Meta Reference GPU Distribution](./self_hosted_distro/meta-reference-gpu.md) +::: + +:::{tab-item} vLLM +- [Start vLLM Distribution](./self_hosted_distro/remote-vllm.md) +::: + +:::{tab-item} tgi +- [Start TGI Distribution](./self_hosted_distro/tgi.md) +::: + +:::{tab-item} ollama +- [Start Ollama Distribution](./self_hosted_distro/ollama.md) +::: + +:::{tab-item} together +- [Start Together Distribution](./self_hosted_distro/together.md) +::: + +:::{tab-item} fireworks +- [Start Fireworks Distribution](./self_hosted_distro/fireworks.md) +::: + +:::: + +### Troubleshooting + +- If you encounter any issues, search through our [GitHub Issues](https://github.com/meta-llama/llama-stack/issues), or file an new issue. +- Use `--port ` flag to use a different port number. For docker run, update the `-p :` flag. diff --git a/docs/source/getting_started/distributions/ondevice_distro/index.md b/docs/source/distributions/ondevice_distro/index.md similarity index 100% rename from docs/source/getting_started/distributions/ondevice_distro/index.md rename to docs/source/distributions/ondevice_distro/index.md diff --git a/docs/source/getting_started/distributions/ondevice_distro/ios_sdk.md b/docs/source/distributions/ondevice_distro/ios_sdk.md similarity index 100% rename from docs/source/getting_started/distributions/ondevice_distro/ios_sdk.md rename to docs/source/distributions/ondevice_distro/ios_sdk.md diff --git a/docs/source/getting_started/distributions/remote_hosted_distro/index.md b/docs/source/distributions/remote_hosted_distro/index.md similarity index 98% rename from docs/source/getting_started/distributions/remote_hosted_distro/index.md rename to docs/source/distributions/remote_hosted_distro/index.md index 76d5fdf27..308d29fa1 100644 --- a/docs/source/getting_started/distributions/remote_hosted_distro/index.md +++ b/docs/source/distributions/remote_hosted_distro/index.md @@ -1,5 +1,12 @@ # Remote-Hosted Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +remote +``` + Remote-Hosted distributions are available endpoints serving Llama Stack API that you can directly connect to. | Distribution | Endpoint | Inference | Agents | Memory | Safety | Telemetry | diff --git a/docs/source/getting_started/distributions/self_hosted_distro/bedrock.md b/docs/source/distributions/self_hosted_distro/bedrock.md similarity index 98% rename from docs/source/getting_started/distributions/self_hosted_distro/bedrock.md rename to docs/source/distributions/self_hosted_distro/bedrock.md index 28691d4e3..edef88390 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/bedrock.md +++ b/docs/source/distributions/self_hosted_distro/bedrock.md @@ -1,4 +1,10 @@ # Bedrock Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` ### Connect to a Llama Stack Bedrock Endpoint - You may connect to Amazon Bedrock APIs for running LLM inference diff --git a/docs/source/getting_started/distributions/self_hosted_distro/dell-tgi.md b/docs/source/distributions/self_hosted_distro/dell-tgi.md similarity index 98% rename from docs/source/getting_started/distributions/self_hosted_distro/dell-tgi.md rename to docs/source/distributions/self_hosted_distro/dell-tgi.md index 90d6a87c9..c74cccfe2 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/dell-tgi.md +++ b/docs/source/distributions/self_hosted_distro/dell-tgi.md @@ -1,5 +1,12 @@ # Dell-TGI Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` + The `llamastack/distribution-tgi` distribution consists of the following provider configurations. diff --git a/docs/source/getting_started/distributions/self_hosted_distro/fireworks.md b/docs/source/distributions/self_hosted_distro/fireworks.md similarity index 97% rename from docs/source/getting_started/distributions/self_hosted_distro/fireworks.md rename to docs/source/distributions/self_hosted_distro/fireworks.md index cca1155e1..e30bb1480 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/fireworks.md +++ b/docs/source/distributions/self_hosted_distro/fireworks.md @@ -1,5 +1,12 @@ # Fireworks Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` + The `llamastack/distribution-fireworks` distribution consists of the following provider configurations. | API | Provider(s) | diff --git a/docs/source/getting_started/distributions/self_hosted_distro/index.md b/docs/source/distributions/self_hosted_distro/index.md similarity index 99% rename from docs/source/getting_started/distributions/self_hosted_distro/index.md rename to docs/source/distributions/self_hosted_distro/index.md index 502b95cb4..b89d24bc1 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/index.md +++ b/docs/source/distributions/self_hosted_distro/index.md @@ -1,5 +1,20 @@ # Self-Hosted Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +meta-reference-gpu +meta-reference-quantized-gpu +ollama +tgi +dell-tgi +together +fireworks +remote-vllm +bedrock +``` + We offer deployable distributions where you can host your own Llama Stack server using local inference. | **Distribution** | **Llama Stack Docker** | Start This Distribution | **Inference** | **Agents** | **Memory** | **Safety** | **Telemetry** | @@ -11,18 +26,3 @@ We offer deployable distributions where you can host your own Llama Stack server | Together | [llamastack/distribution-together](https://hub.docker.com/repository/docker/llamastack/distribution-together/general) | [Guide](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/together.html) | remote::together | meta-reference | remote::weaviate | meta-reference | meta-reference | | Fireworks | [llamastack/distribution-fireworks](https://hub.docker.com/repository/docker/llamastack/distribution-fireworks/general) | [Guide](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/fireworks.html) | remote::fireworks | meta-reference | remote::weaviate | meta-reference | meta-reference | | Bedrock | [llamastack/distribution-bedrock](https://hub.docker.com/repository/docker/llamastack/distribution-bedrock/general) | [Guide](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/bedrock.html) | remote::bedrock | meta-reference | remote::weaviate | meta-reference | meta-reference | - - -```{toctree} -:maxdepth: 1 - -meta-reference-gpu -meta-reference-quantized-gpu -ollama -tgi -dell-tgi -together -fireworks -remote-vllm -bedrock -``` diff --git a/docs/source/getting_started/distributions/self_hosted_distro/meta-reference-gpu.md b/docs/source/distributions/self_hosted_distro/meta-reference-gpu.md similarity index 98% rename from docs/source/getting_started/distributions/self_hosted_distro/meta-reference-gpu.md rename to docs/source/distributions/self_hosted_distro/meta-reference-gpu.md index 74a838d2f..65e1c8cf8 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/meta-reference-gpu.md +++ b/docs/source/distributions/self_hosted_distro/meta-reference-gpu.md @@ -1,5 +1,12 @@ # Meta Reference Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` + The `llamastack/distribution-meta-reference-gpu` distribution consists of the following provider configurations: | API | Provider(s) | diff --git a/docs/source/getting_started/distributions/self_hosted_distro/meta-reference-quantized-gpu.md b/docs/source/distributions/self_hosted_distro/meta-reference-quantized-gpu.md similarity index 97% rename from docs/source/getting_started/distributions/self_hosted_distro/meta-reference-quantized-gpu.md rename to docs/source/distributions/self_hosted_distro/meta-reference-quantized-gpu.md index afe1e3e20..7dcc642d5 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/meta-reference-quantized-gpu.md +++ b/docs/source/distributions/self_hosted_distro/meta-reference-quantized-gpu.md @@ -1,5 +1,12 @@ # Meta Reference Quantized Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` + The `llamastack/distribution-meta-reference-quantized-gpu` distribution consists of the following provider configurations. diff --git a/docs/source/getting_started/distributions/self_hosted_distro/ollama.md b/docs/source/distributions/self_hosted_distro/ollama.md similarity index 99% rename from docs/source/getting_started/distributions/self_hosted_distro/ollama.md rename to docs/source/distributions/self_hosted_distro/ollama.md index d1e9ea67a..fe65172f3 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/ollama.md +++ b/docs/source/distributions/self_hosted_distro/ollama.md @@ -1,5 +1,12 @@ # Ollama Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` + The `llamastack/distribution-ollama` distribution consists of the following provider configurations. | API | Provider(s) | diff --git a/docs/source/getting_started/distributions/self_hosted_distro/remote-vllm.md b/docs/source/distributions/self_hosted_distro/remote-vllm.md similarity index 99% rename from docs/source/getting_started/distributions/self_hosted_distro/remote-vllm.md rename to docs/source/distributions/self_hosted_distro/remote-vllm.md index 748b98732..235cc1e0f 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/remote-vllm.md +++ b/docs/source/distributions/self_hosted_distro/remote-vllm.md @@ -1,5 +1,12 @@ # Remote vLLM Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` + The `llamastack/distribution-remote-vllm` distribution consists of the following provider configurations: | API | Provider(s) | diff --git a/docs/source/getting_started/distributions/self_hosted_distro/tgi.md b/docs/source/distributions/self_hosted_distro/tgi.md similarity index 98% rename from docs/source/getting_started/distributions/self_hosted_distro/tgi.md rename to docs/source/distributions/self_hosted_distro/tgi.md index 63631f937..3209b9100 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/tgi.md +++ b/docs/source/distributions/self_hosted_distro/tgi.md @@ -1,5 +1,12 @@ # TGI Distribution +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` + The `llamastack/distribution-tgi` distribution consists of the following provider configurations. | API | Provider(s) | diff --git a/docs/source/getting_started/distributions/self_hosted_distro/together.md b/docs/source/distributions/self_hosted_distro/together.md similarity index 96% rename from docs/source/getting_started/distributions/self_hosted_distro/together.md rename to docs/source/distributions/self_hosted_distro/together.md index 5d79fcf0c..303c62dcb 100644 --- a/docs/source/getting_started/distributions/self_hosted_distro/together.md +++ b/docs/source/distributions/self_hosted_distro/together.md @@ -1,4 +1,11 @@ -# Fireworks Distribution +# Together Distribution + +```{toctree} +:maxdepth: 2 +:hidden: + +self +``` The `llamastack/distribution-together` distribution consists of the following provider configurations. diff --git a/docs/source/getting_started/index.md b/docs/source/getting_started/index.md index 5fc2c5ed8..8e47c2787 100644 --- a/docs/source/getting_started/index.md +++ b/docs/source/getting_started/index.md @@ -1,194 +1,79 @@ -# Getting Started +# Getting Started with Llama Stack ```{toctree} :maxdepth: 2 :hidden: - -distributions/self_hosted_distro/index -distributions/remote_hosted_distro/index -distributions/ondevice_distro/index ``` -At the end of the guide, you will have learned how to: -- get a Llama Stack server up and running -- set up an agent (with tool-calling and vector stores) that works with the above server +In this guide, we'll walk through using ollama as the inference provider and build a simple python application that uses the Llama Stack Client SDK -To see more example apps built using Llama Stack, see [llama-stack-apps](https://github.com/meta-llama/llama-stack-apps/tree/main). +Llama stack consists of a distribution server and an accompanying client SDK. The distribution server can be configured for different providers for inference, memory, agents, evals etc. This configuration is defined in a yaml file called `run.yaml`. -## Step 1. Starting Up Llama Stack Server - -### Decide Your Build Type -There are two ways to start a Llama Stack: - -- **Docker**: we provide a number of pre-built Docker containers allowing you to get started instantly. If you are focused on application development, we recommend this option. -- **Conda**: the `llama` CLI provides a simple set of commands to build, configure and run a Llama Stack server containing the exact combination of providers you wish. We have provided various templates to make getting started easier. - -Both of these provide options to run model inference using our reference implementations, Ollama, TGI, vLLM or even remote providers like Fireworks, Together, Bedrock, etc. - -### Decide Your Inference Provider - -Running inference on the underlying Llama model is one of the most critical requirements. Depending on what hardware you have available, you have various options. Note that each option have different necessary prerequisites. - -- **Do you have access to a machine with powerful GPUs?** -If so, we suggest: - - [distribution-meta-reference-gpu](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/meta-reference-gpu.html) - - [distribution-tgi](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/tgi.html) - -- **Are you running on a "regular" desktop machine?** -If so, we suggest: - - [distribution-ollama](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/ollama.html) - -- **Do you have an API key for a remote inference provider like Fireworks, Together, etc.?** If so, we suggest: - - [distribution-together](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/remote_hosted_distro/together.html) - - [distribution-fireworks](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/remote_hosted_distro/fireworks.html) - -- **Do you want to run Llama Stack inference on your iOS / Android device** If so, we suggest: - - [iOS](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/ondevice_distro/ios_sdk.html) - - [Android](https://github.com/meta-llama/llama-stack-client-kotlin) (coming soon) - -Please see our pages in detail for the types of distributions we offer: - -1. [Self-Hosted Distribution](./distributions/self_hosted_distro/index.md): If you want to run Llama Stack inference on your local machine. -2. [Remote-Hosted Distribution](./distributions/remote_hosted_distro/index.md): If you want to connect to a remote hosted inference provider. -3. [On-device Distribution](./distributions/ondevice_distro/index.md): If you want to run Llama Stack inference on your iOS / Android device. - - -### Table of Contents - -Once you have decided on the inference provider and distribution to use, use the following guides to get started. - -##### 1.0 Prerequisite - -``` -$ git clone git@github.com:meta-llama/llama-stack.git +### Step 1. Start the ollama server +```bash +export LLAMA_STACK_PORT=5001 +export INFERENCE_MODEL="meta-llama/Llama-3.2-3B-Instruct" +# ollama names this model differently, and we must use the ollama name when loading the model +export OLLAMA_INFERENCE_MODEL="llama3.2:3b-instruct-fp16" +ollama run $OLLAMA_INFERENCE_MODEL --keepalive 60m ``` -::::{tab-set} - -:::{tab-item} meta-reference-gpu -##### System Requirements -Access to Single-Node GPU to start a local server. - -##### Downloading Models -Please make sure you have Llama model checkpoints downloaded in `~/.llama` before proceeding. See [installation guide](https://llama-stack.readthedocs.io/en/latest/cli_reference/download_models.html) here to download the models. - -``` -$ ls ~/.llama/checkpoints -Llama3.1-8B Llama3.2-11B-Vision-Instruct Llama3.2-1B-Instruct Llama3.2-90B-Vision-Instruct Llama-Guard-3-8B -Llama3.1-8B-Instruct Llama3.2-1B Llama3.2-3B-Instruct Llama-Guard-3-1B Prompt-Guard-86M -``` - -::: - -:::{tab-item} vLLM -##### System Requirements -Access to Single-Node GPU to start a vLLM server. -::: - -:::{tab-item} tgi -##### System Requirements -Access to Single-Node GPU to start a TGI server. -::: - -:::{tab-item} ollama -##### System Requirements -Access to Single-Node CPU/GPU able to run ollama. -::: - -:::{tab-item} together -##### System Requirements -Access to Single-Node CPU with Together hosted endpoint via API_KEY from [together.ai](https://api.together.xyz/signin). -::: - -:::{tab-item} fireworks -##### System Requirements -Access to Single-Node CPU with Fireworks hosted endpoint via API_KEY from [fireworks.ai](https://fireworks.ai/). -::: - -:::: - -##### 1.1. Start the distribution - -::::{tab-set} -:::{tab-item} meta-reference-gpu -- [Start Meta Reference GPU Distribution](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/meta-reference-gpu.html) -::: - -:::{tab-item} vLLM -- [Start vLLM Distribution](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/remote-vllm.html) -::: - -:::{tab-item} tgi -- [Start TGI Distribution](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/tgi.html) -::: - -:::{tab-item} ollama -- [Start Ollama Distribution](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/ollama.html) -::: - -:::{tab-item} together -- [Start Together Distribution](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/together.html) -::: - -:::{tab-item} fireworks -- [Start Fireworks Distribution](https://llama-stack.readthedocs.io/en/latest/getting_started/distributions/self_hosted_distro/fireworks.html) -::: - -:::: - -##### Troubleshooting -- If you encounter any issues, search through our [GitHub Issues](https://github.com/meta-llama/llama-stack/issues), or file an new issue. -- Use `--port ` flag to use a different port number. For docker run, update the `-p :` flag. - - -## Step 2. Run Llama Stack App - -### Chat Completion Test -Once the server is set up, we can test it with a client to verify it's working correctly. The following command will send a chat completion request to the server's `/inference/chat_completion` API: +### Step 2. Start the llama stack server ```bash -$ curl http://localhost:5000/alpha/inference/chat-completion \ --H "Content-Type: application/json" \ --d '{ - "model_id": "meta-llama/Llama-3.1-8B-Instruct", - "messages": [ +export LLAMA_STACK_PORT=5001 +docker run \ + -it \ + -p $LLAMA_STACK_PORT:$LLAMA_STACK_PORT \ + -v ~/.llama:/root/.llama \ + llamastack/distribution-ollama \ + --port $LLAMA_STACK_PORT \ + --env INFERENCE_MODEL=$INFERENCE_MODEL \ + --env OLLAMA_URL=http://host.docker.internal:11434 + +``` + +### Step 3. Install the client +```bash +pip install llama-stack-client +``` + +#### Check the connectivity to the server +```bash +llama-stack-client --endpoint http://localhost:5001 models list +┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓ +┃ identifier ┃ provider_id ┃ provider_resource_id ┃ metadata ┃ +┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩ +│ meta-llama/Llama-3.2-3B-Instruct │ ollama │ llama3.2:3b-instruct-fp16 │ {} │ +└──────────────────────────────────┴─────────────┴───────────────────────────┴──────────┘ +``` + +### Step 4. Sample app code +```python +from llama_stack_client import LlamaStackClient + +client = LlamaStackClient(base_url="http://localhost:5001") + +# List available models +models = client.models.list() +print(models) + +# Simple chat completion +response = client.inference.chat_completion( + model_id="meta-llama/Llama-3.2-3B-Instruct", + messages=[ {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "Write me a 2 sentence poem about the moon"} - ], - "sampling_params": {"temperature": 0.7, "seed": 42, "max_tokens": 512} -}' - -Output: -{'completion_message': {'role': 'assistant', - 'content': 'The moon glows softly in the midnight sky, \nA beacon of wonder, as it catches the eye.', - 'stop_reason': 'out_of_tokens', - 'tool_calls': []}, - 'logprobs': null} - + {"role": "user", "content": "Write a haiku about coding"} + ] +) +print(response.completion_message.content) ``` -### Run Agent App +## Next Steps -To run an agent app, check out examples demo scripts with client SDKs to talk with the Llama Stack server in our [llama-stack-apps](https://github.com/meta-llama/llama-stack-apps/tree/main/examples) repo. To run a simple agent app: +For more advanced topics, check out: -```bash -$ git clone git@github.com:meta-llama/llama-stack-apps.git -$ cd llama-stack-apps -$ pip install -r requirements.txt +- You can mix and match different providers for inference, memory, agents, evals etc. See [Building custom distributions](../distributions/index.md) +- [Developer Cookbook](developer_cookbook.md) -$ python -m examples.agents.client -``` - -You will see outputs of the form -- -``` -User> I am planning a trip to Switzerland, what are the top 3 places to visit? -inference> Switzerland is a beautiful country with a rich history, stunning landscapes, and vibrant culture. Here are three must-visit places to add to your itinerary: -... - -User> What is so special about #1? -inference> Jungfraujoch, also known as the "Top of Europe," is a unique and special place for several reasons: -... - -User> What other countries should I consider to club? -inference> Considering your interest in Switzerland, here are some neighboring countries that you may want to consider visiting: -``` +For example applications and more detailed tutorials, visit our [llama-stack-apps](https://github.com/meta-llama/llama-stack-apps/tree/main/examples) repository. diff --git a/docs/source/getting_started/new_index.md b/docs/source/getting_started/new_index.md deleted file mode 100644 index 5ad911679..000000000 --- a/docs/source/getting_started/new_index.md +++ /dev/null @@ -1,79 +0,0 @@ -# Getting Started with Llama Stack - -In this guide, we'll walk through using ollama as the inference provider and build a simple python application that uses the Llama Stack Client SDK - -Llama stack consists of a distribution server and an accompanying client SDK. The distribution server can be configured for different providers for inference, memory, agents, evals etc. This configuration is defined in a yaml file called `run.yaml`. - -### Start the ollama server -```bash -export LLAMA_STACK_PORT=5001 -export INFERENCE_MODEL="meta-llama/Llama-3.2-3B-Instruct" -# ollama names this model differently, and we must use the ollama name when loading the model -export OLLAMA_INFERENCE_MODEL="llama3.2:3b-instruct-fp16" -ollama run $OLLAMA_INFERENCE_MODEL --keepalive 60m -``` - -### Start the llama stack server -Create a run.yaml file as defined in the [run.yaml](https://github.com/meta-llama/llama-stack/blob/main/llama_stack/templates/ollama/run.yaml) - -```bash -export LLAMA_STACK_PORT=5001 -docker run \ - -it \ - -p $LLAMA_STACK_PORT:$LLAMA_STACK_PORT \ - -v ~/.llama:/root/.llama \ - -v ./run.yaml:/root/my-run.yaml \ - llamastack/distribution-ollama \ - --yaml-config /root/my-run.yaml \ - --port $LLAMA_STACK_PORT \ - --env INFERENCE_MODEL=$INFERENCE_MODEL \ - --env OLLAMA_URL=http://host.docker.internal:11434 - -``` - -### Install the client -```bash -pip install llama-stack-client -``` - -### Check the connectivity to the server -```bash -llama-stack-client --endpoint http://localhost:5001 models list -┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓ -┃ identifier ┃ provider_id ┃ provider_resource_id ┃ metadata ┃ -┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩ -│ meta-llama/Llama-3.2-3B-Instruct │ ollama │ llama3.2:3b-instruct-fp16 │ {} │ -└──────────────────────────────────┴─────────────┴───────────────────────────┴──────────┘ -``` - -### Sample app code -```python -from llama_stack_client import LlamaStackClient - -client = LlamaStackClient(base_url="http://localhost:5001") - -# List available models -models = client.models.list() -print(models) - -# Simple chat completion -response = client.inference.chat_completion( - model_id="meta-llama/Llama-3.2-3B-Instruct", - messages=[ - {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "Write a haiku about coding"} - ] -) -print(response.completion_message.content) -``` - -## Next Steps - -For more advanced topics, check out: - -- [Tool Calling Guide]() -- [Memory API Guide]() -- [Safety API Guide]() -- [Agents Guide]() - -For example applications and more detailed tutorials, visit our [llama-stack-apps](https://github.com/meta-llama/llama-stack-apps/tree/main/examples) repository. diff --git a/docs/source/index.md b/docs/source/index.md index a53952be7..e6c950b3e 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -86,6 +86,7 @@ You can find more example scripts with client SDKs to talk with the Llama Stack :maxdepth: 3 getting_started/index +distributions/index cli_reference/index cli_reference/download_models api_providers/index