fix(rag-example): add provider_id to avoid llama_stack_client 400 error (#1114)

# What does this PR do?
Add provider_id to avoid errors using the rag example with
llama_stack_client

`llama_stack_client.BadRequestError: Error code: 400 - {'detail':
'Invalid value: No provider specified and multiple providers available.
Please specify a provider_id.'}`

[//]: # (If resolving an issue, uncomment and update the line below)
[//]: # (Closes #[issue-number])

## Test Plan
[Describe the tests you ran to verify your changes with result
summaries. *Provide clear instructions so the plan can be easily
re-executed.*]

[//]: # (## Documentation)

---------

Co-authored-by: Xi Yan <yanxi970830@gmail.com>
This commit is contained in:
Alessandro Sangiorgi 2025-02-19 17:37:25 -06:00 committed by GitHub
parent 034ece0011
commit 9e03df983e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -214,10 +214,16 @@ documents = [
for i, url in enumerate(urls) for i, url in enumerate(urls)
] ]
vector_providers = [
provider for provider in client.providers.list() if provider.api == "vector_io"
]
provider_id = vector_providers[0].provider_id # Use the first available vector provider
# Register a vector database # Register a vector database
vector_db_id = f"test-vector-db-{uuid.uuid4().hex}" vector_db_id = f"test-vector-db-{uuid.uuid4().hex}"
client.vector_dbs.register( client.vector_dbs.register(
vector_db_id=vector_db_id, vector_db_id=vector_db_id,
provider_id=provider_id,
embedding_model="all-MiniLM-L6-v2", embedding_model="all-MiniLM-L6-v2",
embedding_dimension=384, embedding_dimension=384,
) )