Skip to content

Conversation

@leseb
Copy link
Collaborator

@leseb leseb commented Mar 17, 2025

What does this PR do?

Providers that live outside of the llama-stack codebase are now
supported.
A new property external_providers_dir has been added to the main
config and can be configured as follow:

external_providers_dir: /etc/llama-stack/providers.d/

Where the expected structure is:

providers.d/
  inference/
    custom_ollama.yaml
    vllm.yaml
  vector_io/
    qdrant.yaml

Where custom_ollama.yaml is:

adapter:
  adapter_type: custom_ollama
  pip_packages: ["ollama", "aiohttp"]
  config_class: llama_stack_ollama_provider.config.OllamaImplConfig
  module: llama_stack_ollama_provider
api_dependencies: []
optional_api_dependencies: []

Obviously the package must be installed on the system, here is the
llama_stack_ollama_provider example:

$ uv pip show llama-stack-ollama-provider
Using Python 3.10.16 environment at: /Users/leseb/Documents/AI/llama-stack/.venv
Name: llama-stack-ollama-provider
Version: 0.1.0
Location: /Users/leseb/Documents/AI/llama-stack/.venv/lib/python3.10/site-packages
Editable project location: /private/var/folders/mq/rnm5w_7s2d3fxmtkx02knvhm0000gn/T/tmp.ZBHU5Ezxg4/ollama/llama-stack-ollama-provider
Requires:
Required-by:

Closes: #658

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 17, 2025
@leseb
Copy link
Collaborator Author

leseb commented Mar 17, 2025

TODO: add doc instruction on how to write an external provider and configure a llama-stack instance of it.

@booxter
Copy link
Contributor

booxter commented Mar 17, 2025

Would it make sense to use some manager for entrypoints like stevedore that would refer to python package names instead of file paths?

@leseb
Copy link
Collaborator Author

leseb commented Mar 17, 2025

stevedore

Never heard of it, I'll do some more exploration. Thanks!

@leseb
Copy link
Collaborator Author

leseb commented Mar 18, 2025

Closing for now, discussed offline with @ashwinb and we prefer to have an RFC first, which will supersede #658. Thanks!

@leseb leseb closed this Mar 18, 2025
@ashwinb ashwinb reopened this Mar 19, 2025
@ashwinb
Copy link
Contributor

ashwinb commented Mar 19, 2025

cc @raghotham let's consider this and allow folks to "bring your own providers to the Stack"

Copy link
Contributor

@ashwinb ashwinb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comment about where the extension point should be executed.

@booxter
Copy link
Contributor

booxter commented Mar 20, 2025

This seems like a good direction. I wonder if the YAML format for provider specs should be adopted for in-tree providers too, to avoid two separate code paths to define these. (python vs yaml)

@leseb leseb requested a review from ashwinb March 21, 2025 16:32
@leseb leseb force-pushed the feat-658 branch 3 times, most recently from b5ae496 to 75c0e2a Compare March 21, 2025 17:18
Copy link
Contributor

@booxter booxter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine. One thing that could be improved is de-duplicating the code for test provider. Basically, instead of copy pasting the implementation to another directory, we could prepare a tmpdir with the necessary files (most of them copied verbatim from the "real" ollama provider subtree). Otherwise, we'll have to patch the test provider every time we patch the "real" provider.)

@leseb
Copy link
Collaborator Author

leseb commented Mar 27, 2025

It's fine. One thing that could be improved is de-duplicating the code for test provider. Basically, instead of copy pasting the implementation to another directory, we could prepare a tmpdir with the necessary files (most of them copied verbatim from the "real" ollama provider subtree). Otherwise, we'll have to patch the test provider every time we patch the "real" provider.)

Yes, I was trying to avoid that with symlinks first (but the package install would fail). Agree that the duplication is not ideal I can give this another try but would like to move fw with this too :)

@leseb leseb force-pushed the feat-658 branch 3 times, most recently from 44a437e to 2c21686 Compare March 28, 2025 09:53
@leseb
Copy link
Collaborator Author

leseb commented Mar 28, 2025

It's fine. One thing that could be improved is de-duplicating the code for test provider. Basically, instead of copy pasting the implementation to another directory, we could prepare a tmpdir with the necessary files (most of them copied verbatim from the "real" ollama provider subtree). Otherwise, we'll have to patch the test provider every time we patch the "real" provider.)

Yes, I was trying to avoid that with symlinks first (but the package install would fail). Agree that the duplication is not ideal I can give this another try but would like to move fw with this too :)

@booxter no more dups!

@leseb leseb force-pushed the feat-658 branch 4 times, most recently from bd31424 to 761ccf7 Compare March 28, 2025 12:47
@leseb leseb force-pushed the feat-658 branch 2 times, most recently from 47b8777 to 9b55a61 Compare March 31, 2025 20:39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want the dependencies of the config class to be minimal, it should not pick up dependencies of the implementation so lots of automation can work with typed configs without needing dependency bloat. At the very least, we can say this in the documentation here for now. Later, it might be a good idea to enforce it via a test.

Copy link
Contributor

@ashwinb ashwinb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing! thank you so much and many apologies for being AWOL. 🙏

@leseb
Copy link
Collaborator Author

leseb commented Apr 9, 2025

amazing! thank you so much and many apologies for being AWOL. 🙏

I’ve noted your latest review comments, assuming they’re non-blocking, I’ll go ahead and merge this. I’ll follow up with a separate PR to address the minor nits. Thanks again!

Providers that live outside of the llama-stack codebase are now
supported.
A new property `external_providers_dir` has been added to the main
config and can be configured as follow:

```
external_providers_dir: /etc/llama-stack/providers.d/
```

Where the expected structure is:

```
providers.d/
  inference/
    custom_ollama.yaml
    vllm.yaml
  vector_io/
    qdrant.yaml
```

Where `custom_ollama.yaml` is:

```
adapter:
  adapter_type: custom_ollama
  pip_packages: ["ollama", "aiohttp"]
  config_class: llama_stack_ollama_provider.config.OllamaImplConfig
  module: llama_stack_ollama_provider
api_dependencies: []
optional_api_dependencies: []
```

Obviously the package must be installed on the system, here is the
`llama_stack_ollama_provider` example:

```
$ uv pip show llama-stack-ollama-provider
Using Python 3.10.16 environment at: /Users/leseb/Documents/AI/llama-stack/.venv
Name: llama-stack-ollama-provider
Version: 0.1.0
Location: /Users/leseb/Documents/AI/llama-stack/.venv/lib/python3.10/site-packages
Editable project location: /private/var/folders/mq/rnm5w_7s2d3fxmtkx02knvhm0000gn/T/tmp.ZBHU5Ezxg4/ollama/llama-stack-ollama-provider
Requires:
Required-by:
```

Signed-off-by: Sébastien Han <[email protected]>
@leseb
Copy link
Collaborator Author

leseb commented Apr 9, 2025

Just gave it a final spin after a rebase, and it's all green! Merging now :)

@leseb leseb merged commit 3897670 into llamastack:main Apr 9, 2025
23 checks passed
@leseb leseb deleted the feat-658 branch April 9, 2025 08:30
@leseb leseb mentioned this pull request Apr 9, 2025
@rhuss rhuss mentioned this pull request Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for providers outside of this codebase

5 participants