Skip to content

Commit d63fba4

Browse files
Fix readm & update dependencies
1 parent 23c096f commit d63fba4

3 files changed

Lines changed: 118 additions & 54 deletions

File tree

Lines changed: 113 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,165 @@
1+
<div style="text-align: center;">
2+
13
# OpenAI Responses Agent
24

3-
Agent **without any agentic framework**: uses only the **OpenAI Python client** and **pure Python** (Responses API). No LlamaStack, LangChain, LlamaIndex, etc. – to show it can be done without frameworks. Uses `AIAgent` with chat, tools, and Action/Observation loop. Compatible with OpenAI API or any OpenAI-compatible endpoint (e.g. `BASE_URL` override). Python 3.12+.
5+
</div>
46

5-
# Use Agent Locally
7+
Agent **without any agentic framework**: uses only the **OpenAI Python client** and **pure Python** (Responses API). No LlamaStack, LangChain, LlamaIndex, etc. Uses `AIAgent` with chat, tools, and Action/Observation loop. Compatible with OpenAI API or any OpenAI-compatible endpoint (e.g. `BASE_URL` override). Python 3.12+.
68

7-
### Installation
9+
---
810

9-
```bash
10-
git clone <repository-url>
11-
cd Agentic-Starter-Kits
12-
```
13-
```bash
14-
python -m venv .venv
15-
source .venv/bin/activate # On Windows: .venv\Scripts\activate
16-
```
11+
### Preconditions
1712

18-
If you want to install Ollama: [Ollama site](https://ollama.com/) or [Brew](https://formulae.brew.sh/formula/ollama#default).
13+
- Copy/paste the `.env` file and set values for your environment
14+
- Choose **local** or **RH OpenShift Cluster** and fill the needed values
15+
- Run `./init.sh` to load values from `.env` into the environment
1916

20-
**Install agent dependencies** (OpenAI client):
17+
Copy `.env` file:
2118

2219
```bash
23-
cd agents/base/openai_responses_agent
24-
uv pip install -e .
25-
# or: poetry install
20+
cp template.env agents/base/openai_responses_agent/.env
2621
```
2722

28-
### Setup Instructions
23+
#### Local
24+
25+
Edit the `.env` file with your local configuration:
26+
27+
```
28+
BASE_URL=http://localhost:8321
29+
MODEL_ID=ollama/llama3.2:3b
30+
API_KEY=not-needed
31+
CONTAINER_IMAGE=not-needed
32+
```
2933

30-
**Option A – OpenAI API**
34+
> **Local setup (Ollama):** Port and model name can differ depending on your setup (e.g. Llama Stack on port 8321 vs Ollama on 11434, or a different model ID). Check your running services and `run_llama_server.yaml` (if using Llama Stack) and set `BASE_URL` and `MODEL_ID` accordingly.
3135
32-
Create `.env` in the agent directory (or use repo `template.env`):
36+
Or for **OpenAI API** directly:
3337

34-
```env
38+
```
3539
BASE_URL=https://api.openai.com/v1
3640
MODEL_ID=gpt-4o-mini
3741
API_KEY=sk-...
42+
CONTAINER_IMAGE=not-needed
3843
```
3944

40-
**Option B – Local OpenAI-compatible endpoint (e.g. Ollama)**
45+
#### OpenShift Cluster
4146

42-
1. Pull model and run Ollama (or another OpenAI-compatible server).
43-
2. In `.env` set e.g. `BASE_URL=http://localhost:11434/v1`, `MODEL_ID=llama3.2`, `API_KEY=not-needed` (if not required).
47+
Edit the `.env` file and fill in all required values:
4448

45-
**Configure Environment Variables**
49+
```
50+
API_KEY=your-api-key-here
51+
BASE_URL=https://your-llama-stack-distribution.com/v1
52+
MODEL_ID=llama-3.1-8b-instruct
53+
CONTAINER_IMAGE=quay.io/your-username/openai-responses-agent:latest
54+
```
55+
56+
**Notes:**
57+
58+
- `API_KEY` – contact your cluster administrator
59+
- `BASE_URL` – should end with `/v1`
60+
- `MODEL_ID` – contact your cluster administrator
61+
- `CONTAINER_IMAGE` – full image path where the agent container will be pushed and pulled from. The image is built locally, pushed to this registry, and then deployed to OpenShift.
62+
63+
Format: `<registry>/<namespace>/<image-name>:<tag>`
64+
65+
Examples:
4666

47-
Copy the template (from repo root: `template.env`) or create `.env` in the agent directory:
67+
- Quay.io: `quay.io/your-username/openai-responses-agent:latest`
68+
- Docker Hub: `docker.io/your-username/openai-responses-agent:latest`
69+
- GHCR: `ghcr.io/your-org/openai-responses-agent:latest`
70+
71+
Go to agent dir:
4872

4973
```bash
50-
cp ../../../template.env .env
74+
cd agents/base/openai_responses_agent
5175
```
5276

53-
Edit `.env` with `BASE_URL`, `MODEL_ID`, and `API_KEY` as above.
77+
Make scripts executable:
78+
79+
```bash
80+
chmod +x init.sh
81+
```
5482

55-
**Run the example**
83+
Load values from `.env` into environment variables:
5684

5785
```bash
58-
cd examples
59-
python execute_ai_service_locally.py
86+
./init.sh
6087
```
6188

62-
**⚡ Or with [uv](https://docs.astral.sh/uv/)** (from repo root):
89+
---
90+
91+
## Local usage (Ollama + LlamaStack Server)
92+
93+
Create package with agent and install it in venv:
6394

64-
1. Create venv and activate:
6595
```bash
66-
uv venv --python 3.12
67-
source .venv/bin/activate
96+
uv pip install -e .
97+
uv pip install ollama
6898
```
6999

70-
2. Copy shared utils into the agent package:
100+
Install Ollama from the [Ollama site](https://ollama.com/) or via Brew:
101+
71102
```bash
72-
cp utils.py agents/base/openai_responses_agent/src/openai_responses_agent_base/
103+
# brew install ollama
104+
# or
105+
curl -fsSL https://ollama.com/install.sh | sh
73106
```
74107

75-
3. Install agent (editable) and its requirements:
108+
Pull required models:
109+
76110
```bash
77-
uv pip install -e agents/base/openai_responses_agent/. -r agents/base/openai_responses_agent/requirements.txt
111+
ollama pull llama3.2:3b
112+
ollama pull embeddinggemma:latest
78113
```
79114

80-
4. Run the example:
115+
Start Ollama service:
116+
81117
```bash
82-
uv run agents/base/openai_responses_agent/examples/execute_ai_service_locally.py
118+
ollama serve
83119
```
84120

85-
# Deployment on Red Hat OpenShift Cluster
121+
> **Keep this terminal open!**
122+
> Ollama needs to keep running.
86123
87-
### Step 1: Initialize the Agent
124+
Start LlamaStack server:
88125

89126
```bash
90-
cd agents/base/openai_responses_agent
91-
chmod +x init.sh deploy.sh
92-
./init.sh
127+
llama stack run ../../../run_llama_server.yaml
128+
```
129+
130+
> **Keep this terminal open** – the server needs to keep running.
131+
> You should see output indicating the server started on `http://localhost:8321`.
132+
133+
Run the example:
134+
135+
```bash
136+
uv run agents/base/openai_responses_agent/examples/execute_ai_service_locally.py
93137
```
94138

95-
This loads `.env`, validates variables, and copies `utils.py` into the agent package.
139+
---
140+
141+
## Deployment on Red Hat OpenShift Cluster
96142

97-
### Step 2: Build Image and Deploy
143+
Make deploy script executable:
144+
145+
```bash
146+
chmod +x deploy.sh
147+
```
148+
149+
Build image and deploy agent:
98150

99151
```bash
100152
./deploy.sh
101153
```
102154

103-
This creates the API key secret, builds and pushes the image, and deploys the agent (Deployment, Service, Route).
155+
This will:
104156

105-
### Step 3: Test the Agent
157+
- Create Kubernetes secret for API key
158+
- Build and push the Docker image
159+
- Deploy the agent to OpenShift
160+
- Create Service and Route
106161

107-
Get the route host:
162+
Get the route URL:
108163

109164
```bash
110165
oc get route openai-responses-agent -o jsonpath='{.spec.host}'
@@ -115,9 +170,14 @@ Send a test request:
115170
```bash
116171
curl -X POST https://<YOUR_ROUTE_URL>/chat \
117172
-H "Content-Type: application/json" \
118-
-d '{"message": "How much does a Lenovo Laptop costs and what are the reviews?"}'
173+
-d '{"message": "How much does a Lenovo Laptop cost and what are the reviews?"}'
119174
```
120175

121-
## References
176+
---
177+
178+
## Agent-Specific Documentation
122179

123-
- [OpenAI Python client](https://github.com/openai/openai-python) and [Responses API](https://platform.openai.com/docs/api-reference/responses/create)
180+
- [OpenAI Python client](https://github.com/openai/openai-python)
181+
- [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses/create)
182+
- [Ollama](https://ollama.com/)
183+
- [Ollama (Homebrew)](https://formulae.brew.sh/formula/ollama#default)

agents/base/openai_responses_agent/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ packages = [
1212
python = ">=3.12"
1313
python-dotenv = "^1.0.0"
1414
openai = ">=1.0.0"
15+
llama-stack = ">=0.5.0"
16+
setuptools = "69.5.1"
17+
milvus-lite = "2.5.1"
18+
pymilvus = "2.6.9"
1519

1620
[tool.poetry.group.dev]
1721
optional = true

run_llama_server.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ providers:
99
- provider_id: milvus
1010
provider_type: inline::milvus
1111
config:
12-
db_path: ${MILVUS_DB_PATH:-./milvus_data/milvus_lite.db}
12+
db_path: ./milvus_data/milvus_lite.db
1313
persistence:
1414
namespace: vector_io::milvus
1515
backend: kv_default

0 commit comments

Comments
 (0)