Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make LlamaStackLibraryClient work correctly #581

Merged
merged 4 commits into from
Dec 7, 2024
Merged

Conversation

ashwinb
Copy link
Contributor

@ashwinb ashwinb commented Dec 7, 2024

This PR does a few things:

  • it moves "direct client" to llama-stack repo instead of being in the llama-stack-client-python repo
  • renames it to LlamaStackLibraryClient
  • actually makes synchronous generators work
  • makes streaming and non-streaming work properly

In many ways, this PR makes things finally "work"

Test Plan

See a library_client_test.py I added. This isn't really quite a test yet but it demonstrates that this mode now works. Here's the invocation and the response:

INFERENCE_MODEL=meta-llama/Llama-3.2-3B-Instruct python llama_stack/distribution/tests/library_client_test.py ollama

image

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 7, 2024
T = TypeVar("T")


def stream_across_asyncio_run_boundary(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a most crucial part of this PR. without this you cannot make the "non-async" generators (which is a necessary mode for our client-sdk) work properly. you must be able to do for chunk in inference.chat_completion() since that's what synchronous generators are about. to bridge a sync generator to the async generators we have in our server-side code we need to intermediate via a thread pool.

@ashwinb ashwinb merged commit 14f973a into main Dec 7, 2024
2 checks passed
@ashwinb ashwinb deleted the direct_refactor branch December 7, 2024 22:59


def main(config_path: str):
client = LlamaStackAsLibraryClient(config_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

https://llama-stack.readthedocs.io/en/latest/distributions/importing_as_library.html

does this reference to LlamaStackDirectClient also needs to be updated?

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.

4 participants