Skip to content

Commit ab8319b

Browse files
committed
llama-stack-client-vector_stores-agent.py
1 parent c5c74ce commit ab8319b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/python3
2+
3+
from llama_stack_client import Agent, AgentEventLogger, LlamaStackClient
4+
import requests
5+
from io import BytesIO
6+
7+
c = LlamaStackClient(base_url="http://localhost:8321")
8+
9+
vs = c.vector_stores.create(name="my_vector_db")
10+
11+
buf = BytesIO(str("abc is green").encode('utf-8'))
12+
buf.name = "abc"
13+
14+
file = c.files.create(file=("a.txt", buf), purpose="assistants")
15+
c.vector_stores.files.create(vector_store_id=vs.id, file_id=file.id)
16+
17+
agent = Agent(
18+
c,
19+
model="vertexai/google/gemini-2.5-flash",
20+
instructions="You are a helpful assistant",
21+
tools=[
22+
{ "type": "file_search", "vector_store_ids": [vs.id], }
23+
],
24+
)
25+
26+
res = agent.create_turn(
27+
messages=[{"role": "user", "content":
28+
"What is the color of abc?"
29+
}],
30+
session_id=agent.create_session("my_session"),
31+
stream=True,
32+
)
33+
34+
for log in AgentEventLogger().log(res):
35+
print(log, end="")

0 commit comments

Comments
 (0)