Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions genai-function-calling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ performs the same process. The user asks a question that is beyond the training
date of the LLM. The application uses the framework to implement an agent
pattern to automatically call functions when it needs new information.

Here's how the question "What is the latest version of Elasticsearch 8?" ends up
Here's how the question "What is the latest version of Elasticsearch 9?" ends up
being answered.

```mermaid
Expand All @@ -36,23 +36,23 @@ sequenceDiagram
participant LLM

Note over Agent: Framework sends its tools along with the prompt
Agent ->> LLM: user: "What is the latest version of Elasticsearch 8?"
Agent ->> LLM: user: "What is the latest version of Elasticsearch 9?"
activate LLM
Note over LLM: LLM determines it needs to use a tool to complete the task

LLM ->> Agent: assistant: {"function": {"name": "get_latest_elasticsearch_version", "arguments": "{\"majorVersion\": 8}"}}
LLM ->> Agent: assistant: {"function": {"name": "get_latest_elasticsearch_version", "arguments": "{\"majorVersion\": 9}"}}
deactivate LLM
activate Agent
Note over Agent: invokes get_latest_elasticsearch_version(majorVersion=8)
Note over Agent: invokes get_latest_elasticsearch_version(majorVersion=9)

Agent ->> LLM: [user, assistant, tool: "8.19.3"]
Agent ->> LLM: [user, assistant, tool: "9.1.5"]
Note over Agent: LLM is stateless, the tool result is sent back with prior messages
deactivate Agent
activate LLM

LLM ->> Agent: content: "The latest version of Elasticsearch 8 is 8.19.3"
LLM ->> Agent: content: "The latest version of Elasticsearch 9 is 9.1.5"
deactivate LLM
Note over Agent: "The latest version of Elasticsearch 8 is 8.19.3"
Note over Agent: "The latest version of Elasticsearch 9 is 9.1.5"
```

The GenAI framework not only abstracts the above loop, but also LLM plugability
Expand Down Expand Up @@ -173,21 +173,21 @@ sequenceDiagram

create participant LLM

Agent->>LLM: user: "What is the latest version of Elasticsearch 8?"
Agent->>LLM: user: "What is the latest version of Elasticsearch 9?"
activate LLM
LLM->>Agent: assistant: {"function": {"name": "get_latest_elasticsearch_version", "arguments": "{\"majorVersion\": 8}"}}
LLM->>Agent: assistant: {"function": {"name": "get_latest_elasticsearch_version", "arguments": "{\"majorVersion\": 9}"}}
deactivate LLM
activate Agent

rect rgb(191, 223, 255)
Agent->>+MCP: tools/call: {get_latest_elasticsearch_version, {majorVersion: 8}}
MCP-->>-Agent: response: {output: "8.19.3"}
Agent->>+MCP: tools/call: {get_latest_elasticsearch_version, {majorVersion: 9}}
MCP-->>-Agent: response: {output: "9.1.5"}
end

Agent->>LLM: [user, assistant, tool: "8.19.3"]
Agent->>LLM: [user, assistant, tool: "9.1.5"]
deactivate Agent
activate LLM
LLM->>Agent: content: "The latest version of Elasticsearch 8 is 8.19.3"
LLM->>Agent: content: "The latest version of Elasticsearch 9 is 9.1.5"
deactivate LLM
```

Expand Down
6 changes: 0 additions & 6 deletions genai-function-calling/openai-agents/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# Use glibc-based image with pre-compiled wheels for psutil
FROM python:3.13-slim

# TODO: temporary until elastic-opentelemetry release with https://github.com/elastic/elastic-otel-python-instrumentations/pull/90
RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN --mount=type=cache,target=/root/.cache/pip python -m pip install --upgrade pip

COPY requirements.txt /tmp
Expand Down
2 changes: 1 addition & 1 deletion genai-function-calling/openai-agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ dotenv -f .env run -- pytest
## Notes

The LLM should generate something like "The latest stable version of
Elasticsearch is 8.19.3", unless it hallucinates. Just run it again, if you
Elasticsearch is 9.1.5", unless it hallucinates. Just run it again, if you
see something else.

OpenAI Agents SDK's OpenTelemetry instrumentation is via
Expand Down
Loading