Skip to content

Instantly share code, notes, and snippets.

@thoraxe
Last active February 24, 2025 16:59
Show Gist options
  • Save thoraxe/0fd79b8db128ae8887b4d5c9eede21eb to your computer and use it in GitHub Desktop.
Save thoraxe/0fd79b8db128ae8887b4d5c9eede21eb to your computer and use it in GitHub Desktop.
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
import asyncio
import os
import subprocess
import fire
from llama_stack_client import LlamaStackClient
from llama_stack_client.lib.agents.client_tool import client_tool
from llama_stack_client.lib.agents.agent import Agent
from llama_stack_client.lib.agents.event_logger import EventLogger
from llama_stack_client.types.agent_create_params import AgentConfig
pre_path = "/home/thoraxe/bin/"
@client_tool
async def get_object_namespace_list(kind: str, namespace: str) -> str:
"""Get the list of all objects in a namespace
:param kind: the type of object
:param namespace: the name of the namespace
:returns: a plaintext list of the kind object in the namespace
"""
output = subprocess.run(
[pre_path + "oc", "get", kind, "-n", namespace, "-o", "name"],
capture_output=True,
timeout=2,
)
return output.stdout
async def run_main(host: str, port: int, user_query: str, disable_safety: bool = False):
client = LlamaStackClient(
base_url=f"http://{host}:{port}",
)
available_shields = [shield.identifier for shield in client.shields.list()]
if not available_shields:
print("No available shields. Disable safety.")
else:
print(f"Available shields found: {available_shields}")
client_tools = [get_object_namespace_list]
agent_config = AgentConfig(
model="meta-llama/Llama-3.2-1B-Instruct",
instructions="""You are a helpful assistant with access to the following
function calls. Your task is to produce a list of function calls
necessary to generate response to the user utterance. Use the following
function calls as required.""",
toolgroups=[],
client_tools=[
client_tool.get_tool_definition() for client_tool in client_tools
],
tool_choice="auto",
tool_prompt_format="python_list",
enable_session_persistence=False,
)
agent = Agent(client, agent_config, client_tools)
session_id = agent.create_session("test-session")
print(f"Created session_id={session_id} for Agent({agent.agent_id})")
response = agent.create_turn(
messages=[
{
"role": "user",
"content": user_query,
}
],
session_id=session_id,
)
for log in EventLogger().log(response):
log.print()
def main(host: str, port: int, user_query: str):
asyncio.run(run_main(host, port, user_query))
if __name__ == "__main__":
fire.Fire(main)
python client.py --host=localhost --port=5000 --user_query="what pods are in the openshift-lightspeed namespace?"
No available shields. Disable safety.
Created session_id=1b6db698-b738-4953-a4b1-667bb85e5764 for Agent(06197239-d29d-4d86-b624-19331f706492)
inference> tool_call>
/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/llama_stack_client/lib/agents/agent.py:89: RuntimeWarning: coroutine 'get_object_namespace_list' was never awaited
result_message = tool.run(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
tool_execution> Tool:get_object_namespace_list Args:{'kind': 'pod', 'namespace': 'openshift-lightspeed'}
tool_execution> Tool:get_object_namespace_list Response:Error when running tool: Object of type coroutine is not JSON serializable
inference> tool_call>
tool_execution> Tool:get_object_namespace_list Args:{'kind': 'pod', 'namespace': 'openshift-lightspeed'}
tool_execution> Tool:get_object_namespace_list Response:Error when running tool: Object of type coroutine is not JSON serializable
inference> pologies for the confusion. The function I have access to only allows me to retrieve the list of objects in a namespace, not the specific details of those objects. To get the list of pods in the "openshift-lightspeed" namespace, I would need to call the function like this:
```python
get_object_namespace_list(kind="pod", namespace="openshift-lightspeed")
```
However, I'm unable to execute this function directly. You would need to run this command in your local environment where the function is defined.
Traceback (most recent call last):
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/ols-llamastack/client.py", line 87, in <module>
fire.Fire(main)
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/fire/core.py", line 135, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/fire/core.py", line 468, in _Fire
component, remaining_args = _CallAndUpdateTrace(
^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/ols-llamastack/client.py", line 83, in main
asyncio.run(run_main(host, port, user_query))
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/ols-llamastack/client.py", line 79, in run_main
for log in EventLogger().log(response):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/llama_stack_client/lib/agents/event_logger.py", line 161, in log
for chunk in event_generator:
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/llama_stack_client/lib/agents/agent.py", line 179, in _create_turn_streaming
tool_calls = self._get_tool_calls(chunk)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/llama_stack_client/lib/agents/agent.py", line 68, in _get_tool_calls
if chunk.event.payload.event_type != "turn_complete":
^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'payload'
INFO: ::1:56100 - "GET /v1/shields HTTP/1.1" 200 OK
16:58:21.815 [START] /v1/shields
16:58:21.819 [END] /v1/shields [StatusCode.OK] (4.61ms)
16:58:21.822 [START] /v1/agents
INFO: ::1:56100 - "POST /v1/agents HTTP/1.1" 200 OK
16:58:21.830 [END] /v1/agents [StatusCode.OK] (7.67ms)
16:58:21.832 [START] /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session
INFO: ::1:56100 - "POST /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session HTTP/1.1" 200 OK
16:58:21.837 [END] /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session [StatusCode.OK] (4.81ms)
INFO: ::1:56100 - "POST /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn HTTP/1.1" 200 OK
16:58:21.844 [START] /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn
16:58:21.848 [START] create_and_execute_turn
16:58:21.875 [START] inference
INFO 2025-02-24 11:58:22,089 httpx:1038: HTTP Request: POST http://localhost:4000/chat/completions "HTTP/1.1 200 OK"
16:58:23.409 [END] inference [StatusCode.OK] (1533.65ms)
16:58:22.089 [INFO] HTTP Request: POST http://localhost:4000/chat/completions "HTTP/1.1 200 OK"
INFO 2025-02-24 11:58:23,418 llama_stack.providers.inline.agents.meta_reference.agent_instance:745: role='assistant' content='' stop_reason=<StopReason.end_of_turn: 'end_of_turn'> tool_calls=[ToolCall(call_id='chatcmpl-tool-104a63755eda4cb181e5fd893d190a78', tool_name='get_object_namespace_list', arguments={'namespace': 'openshift-lightspeed', 'kind': 'pod'})]
INFO 2025-02-24 11:58:23,439 llama_stack.providers.inline.agents.meta_reference.agent_instance:207: Assistant:
16:58:23.451 [END] create_and_execute_turn [StatusCode.OK] (1602.56ms)
16:58:23.418 [INFO] role='assistant' content='' stop_reason=<StopReason.end_of_turn: 'end_of_turn'> tool_calls=[ToolCall(call_id='chatcmpl-tool-104a63755eda4cb181e5fd893d190a78', tool_name='get_object_namespace_list', arguments={'namespace': 'openshift-lightspeed', 'kind': 'pod'})]
16:58:23.439 [INFO] Assistant:
16:58:23.452 [END] /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn [StatusCode.OK] (1607.09ms)
16:58:23.496 [START] /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn
INFO: ::1:56100 - "POST /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn HTTP/1.1" 200 OK
16:58:23.501 [START] create_and_execute_turn
16:58:23.529 [START] inference
INFO 2025-02-24 11:58:23,698 httpx:1038: HTTP Request: POST http://localhost:4000/chat/completions "HTTP/1.1 200 OK"
16:58:25.017 [END] inference [StatusCode.OK] (1488.47ms)
16:58:23.698 [INFO] HTTP Request: POST http://localhost:4000/chat/completions "HTTP/1.1 200 OK"
INFO 2025-02-24 11:58:25,027 llama_stack.providers.inline.agents.meta_reference.agent_instance:745: role='assistant' content='' stop_reason=<StopReason.end_of_turn: 'end_of_turn'> tool_calls=[ToolCall(call_id='chatcmpl-tool-b70eeb4d772d471abd8bf2d2565e1efb', tool_name='get_object_namespace_list', arguments={'kind': 'pod', 'namespace': 'openshift-lightspeed'})]
INFO 2025-02-24 11:58:25,047 llama_stack.providers.inline.agents.meta_reference.agent_instance:207: Assistant:
16:58:25.060 [END] create_and_execute_turn [StatusCode.OK] (1558.92ms)
16:58:25.027 [INFO] role='assistant' content='' stop_reason=<StopReason.end_of_turn: 'end_of_turn'> tool_calls=[ToolCall(call_id='chatcmpl-tool-b70eeb4d772d471abd8bf2d2565e1efb', tool_name='get_object_namespace_list', arguments={'kind': 'pod', 'namespace': 'openshift-lightspeed'})]
16:58:25.048 [INFO] Assistant:
16:58:25.062 [END] /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn [StatusCode.OK] (1565.32ms)
16:58:25.066 [START] /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn
INFO: ::1:56100 - "POST /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn HTTP/1.1" 200 OK
16:58:25.076 [START] create_and_execute_turn
16:58:25.103 [START] inference
ERROR 2025-02-24 11:58:25,139 opentelemetry.sdk.trace.export:362: Exception while exporting Span batch.
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 198, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
raise err
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 493, in _make_request
conn.request(
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 445, in request
self.endheaders()
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 1281, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 1041, in _send_output
self.send(msg)
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 979, in send
self.connect()
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 276, in connect
self.sock = self._new_conn()
^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 213, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f7104380210>: Failed to establish a new connection: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 841, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.252', port=6006): Max retries exceeded with url: /v1/traces (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7104380210>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/sdk/trace/export/__init__.py", line 360, in _export_batch
self.span_exporter.export(self.spans_list[:idx]) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 189, in export
return self._export_serialized_spans(serialized_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 159, in _export_serialized_spans
resp = self._export(serialized_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 133, in _export
return self._session.post(
^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.252', port=6006): Max retries exceeded with url: /v1/traces (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7104380210>: Failed to establish a new connection: [Errno 111] Connection refused'))
INFO 2025-02-24 11:58:25,297 httpx:1038: HTTP Request: POST http://localhost:4000/chat/completions "HTTP/1.1 200 OK"
16:58:29.656 [END] inference [StatusCode.OK] (4552.77ms)
16:58:25.146 [ERROR] Exception while exporting Span batch.
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 198, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
raise err
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 493, in _make_request
conn.request(
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 445, in request
self.endheaders()
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 1281, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 1041, in _send_output
self.send(msg)
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 979, in send
self.connect()
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 276, in connect
self.sock = self._new_conn()
^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 213, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f7104380210>: Failed to establish a new connection: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 841, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.252', port=6006): Max retries exceeded with url: /v1/traces (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7104380210>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/sdk/trace/export/__init__.py", line 360, in _export_batch
self.span_exporter.export(self.spans_list[:idx]) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 189, in export
return self._export_serialized_spans(serialized_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 159, in _export_serialized_spans
resp = self._export(serialized_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 133, in _export
return self._session.post(
^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.252', port=6006): Max retries exceeded with url: /v1/traces (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7104380210>: Failed to establish a new connection: [Errno 111] Connection refused'))
16:58:25.298 [INFO] HTTP Request: POST http://localhost:4000/chat/completions "HTTP/1.1 200 OK"
INFO 2025-02-24 11:58:29,664 llama_stack.providers.inline.agents.meta_reference.agent_instance:745: role='assistant' content='' stop_reason=<StopReason.end_of_turn: 'end_of_turn'> tool_calls=[ToolCall(call_id='', tool_name='', arguments={})]
16:58:29.688 [START] tool_execution
16:58:29.689 [END] tool_execution [StatusCode.OK] (0.89ms)
Traceback (most recent call last):
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/llama-stack/llama_stack/distribution/server/server.py", line 208, in sse_generator
async for item in event_gen:
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/llama-stack/llama_stack/providers/inline/agents/meta_reference/agents.py", line 165, in _create_agent_turn_streaming
async for event in agent.create_and_execute_turn(request):
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/llama-stack/llama_stack/providers/inline/agents/meta_reference/agent_instance.py", line 197, in create_and_execute_turn
async for chunk in self.run(
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/llama-stack/llama_stack/providers/inline/agents/meta_reference/agent_instance.py", line 389, in run
async for res in self._run(
16:58:29.690 [END] create_and_execute_turn [StatusCode.OK] (4613.52ms)
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/llama-stack/llama_stack/providers/inline/agents/meta_reference/agent_instance.py", line 800, in _run
tool_result = await execute_tool_call_maybe(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/Red_Hat/openshift/llamaindex-experiments/llama-stack/llama_stack/providers/inline/agents/meta_reference/agent_instance.py", line 1078, in execute_tool_call_maybe
raise ValueError(f"Tool {name} not found in any tool group")
ValueError: Tool not found in any tool group
16:58:29.664 [INFO] role='assistant' content='' stop_reason=<StopReason.end_of_turn: 'end_of_turn'> tool_calls=[ToolCall(call_id='', tool_name='', arguments={})]
16:58:29.693 [END] /v1/agents/8e246b7e-7eeb-45e2-8973-0e6d5d661464/session/ad9ef350-5045-4c5c-8347-5ae1db785385/turn [StatusCode.OK] (4626.35ms)
ERROR 2025-02-24 11:58:30,134 opentelemetry.sdk.trace.export:362: Exception while exporting Span batch.
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 198, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
raise err
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 493, in _make_request
conn.request(
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 445, in request
self.endheaders()
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 1281, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 1041, in _send_output
self.send(msg)
File "/home/thoraxe/.pyenv/versions/3.11.5/lib/python3.11/http/client.py", line 979, in send
self.connect()
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 276, in connect
self.sock = self._new_conn()
^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connection.py", line 213, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f7104bd7450>: Failed to establish a new connection: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/connectionpool.py", line 841, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.252', port=6006): Max retries exceeded with url: /v1/traces (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7104bd7450>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/sdk/trace/export/__init__.py", line 360, in _export_batch
self.span_exporter.export(self.spans_list[:idx]) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 189, in export
return self._export_serialized_spans(serialized_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 159, in _export_serialized_spans
resp = self._export(serialized_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py", line 133, in _export
return self._session.post(
^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/thoraxe/.pyenv/versions/3.11.5/envs/ols-llamastack/lib/python3.11/site-packages/requests/adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.252', port=6006): Max retries exceeded with url: /v1/traces (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7104bd7450>: Failed to establish a new connection: [Errno 111] Connection refused'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment