fix: Update rag examples to use fresh faiss index every time (#998)

# What does this PR do?
In several examples we use the same faiss index , which means running it
multiple times fills up the index with duplicates which eventually
degrades the model performance on RAG as multiple copies of the same
irrelevant chunks might be picked up several times.

Fix is to ensure we create a new index each time. 

Resolves issue in this discussion -
https://github.com/meta-llama/llama-stack/discussions/995

## Test Plan
Re-ran the getting started guide multiple times to see the same output

Co-authored-by: Hardik Shah <hjshah@fb.com>
This commit is contained in:
Hardik Shah 2025-02-06 16:12:29 -08:00 committed by GitHub
parent 06e5af1435
commit 28a0fe57cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 7 deletions

View file

@ -297,7 +297,7 @@ def test_override_system_message_behavior(llama_stack_client, agent_config):
You are an expert in composing functions. You are given a question and a set of possible functions.
Based on the question, you may or may not need to make one or more function/tool calls to achieve the purpose.
If none of the function can be used, don't return [], instead answer the question directly without using functions. If the given question lacks the parameters required by the function,
also point it out.
also point it out.
{{ function_description }}
"""
@ -414,7 +414,7 @@ def test_rag_and_code_agent(llama_stack_client, agent_config):
)
for i, url in enumerate(urls)
]
vector_db_id = "test-vector-db"
vector_db_id = f"test-vector-db-{uuid4()}"
llama_stack_client.vector_dbs.register(
vector_db_id=vector_db_id,
embedding_model="all-MiniLM-L6-v2",