Skip to content

Commit 5297082

Browse files
authored
[docs] Make RAG example self-contained (#962)
Before the patch, the example could not be executed verbatim without copy-pasting client function from the inference example. I think it's better to have examples self-contained, especially in a getting started guide. Signed-off-by: Ihar Hrachyshka <[email protected]> # What does this PR do? See above. ## Test Plan Confirmed example can now be executed verbatim. ## Sources Please link relevant resources if necessary. ## Before submitting - [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [x] Ran pre-commit to handle lint / formatting issues. - [ ] Read the [contributor guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md), Pull Request section? - [ ] Updated relevant documentation. - [ ] Wrote necessary unit or integration tests. Signed-off-by: Ihar Hrachyshka <[email protected]>
1 parent 474c4bd commit 5297082

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/source/getting_started/index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,23 @@ from llama_stack_client.lib.agents.event_logger import EventLogger
163163
from llama_stack_client.types.agent_create_params import AgentConfig
164164
from llama_stack_client.types import Document
165165

166+
167+
def create_http_client():
168+
from llama_stack_client import LlamaStackClient
169+
170+
return LlamaStackClient(
171+
base_url=f"http://localhost:{os.environ['LLAMA_STACK_PORT']}"
172+
)
173+
174+
175+
def create_library_client(template="ollama"):
176+
from llama_stack import LlamaStackAsLibraryClient
177+
178+
client = LlamaStackAsLibraryClient(template)
179+
client.initialize()
180+
return client
181+
182+
166183
client = (
167184
create_library_client()
168185
) # or create_http_client() depending on the environment you picked

0 commit comments

Comments
 (0)