Skip to content

Commit 6340a30

Browse files
committed
aaaaaa
1 parent e6fc7fd commit 6340a30

9 files changed

Lines changed: 3219 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Integration testing
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
integration-tests:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
strategy:
17+
matrix:
18+
include:
19+
- build-dir: quickstart-agent
20+
context: ./testcases/quickstart-agent
21+
agent-input: '{"topic": "cats"}'
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Build Docker image (${{ matrix.build-dir }})
31+
run: |
32+
docker build -f Dockerfile \
33+
-t ${{ matrix.build-dir }}:test \
34+
--build-arg CLIENT_ID="${{ secrets.ALPHA_TEST_CLIENT_ID }}" \
35+
--build-arg CLIENT_SECRET="${{ secrets.ALPHA_TEST_CLIENT_SECRET }}" \
36+
--build-arg BASE_URL="${{ secrets.ALPHA_BASE_URL }}" \
37+
--build-arg SKIP_HUMAN_APPROVAL=true \
38+
--build-arg USE_REGULAR_INTERRUPT=true \
39+
--build-arg AGENT_INPUT='${{ matrix.agent-input }}' \
40+
${{ matrix.context }}

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm
2+
3+
WORKDIR /app
4+
5+
COPY . .
6+
7+
RUN uv sync
8+
9+
ARG CLIENT_ID
10+
ARG CLIENT_SECRET
11+
ARG BASE_URL
12+
ARG AGENT_INPUT
13+
ARG SKIP_HUMAN_APPROVAL=false
14+
ARG USE_REGULAR_INTERRUPT=false
15+
16+
# Validate required environment variables
17+
RUN if [ -z "$CLIENT_ID" ]; then echo "CLIENT_ID build arg is required" && exit 1; fi
18+
RUN if [ -z "$CLIENT_SECRET" ]; then echo "CLIENT_SECRET build arg is required" && exit 1; fi
19+
RUN if [ -z "$BASE_URL" ]; then echo "BASE_URL build arg is required" && exit 1; fi
20+
RUN if [ -z "$AGENT_INPUT" ]; then echo "AGENT_INPUT build arg is required" && exit 1; fi
21+
22+
# Set environment variables for runtime
23+
ENV CLIENT_ID=$CLIENT_ID
24+
ENV CLIENT_SECRET=$CLIENT_SECRET
25+
ENV BASE_URL=$BASE_URL
26+
ENV TAVILY_API_KEY=${TAVILY_API_KEY:-""}
27+
ENV UIPATH_TENANT_ID=${UIPATH_TENANT_ID:-""}
28+
29+
# for the ticket_classification
30+
ENV SKIP_HUMAN_APPROVAL=$SKIP_HUMAN_APPROVAL
31+
ENV USE_REGULAR_INTERRUPT=$USE_REGULAR_INTERRUPT
32+
33+
# Authenticate with UiPath during build
34+
RUN uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"
35+
36+
37+
RUN uv run uipath run agent "$AGENT_INPUT"
38+
39+
RUN if [ "$USE_REGULAR_INTERRUPT" = "true" ] && echo "$AGENT_INPUT" | grep -q '"ticket_id"'; then \
40+
echo "Running resume for ticket classification with regular interrupt..."; \
41+
uv run uipath run agent '{"Answer": true}' --resume; \
42+
else \
43+
echo "Skipping resume - either not ticket classification or USE_REGULAR_INTERRUPT=false"; \
44+
fi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
UIPATH_URL=xxx
2+
UIPATH_TENANT_ID=xxx
3+
UIPATH_ORGANIZATION_ID=xxx
4+
UIPATH_ACCESS_TOKEN=xxx
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
flowchart TD
2+
step__done["_done"]:::stepStyle
3+
step_critique_joke["critique_joke"]:::stepStyle
4+
step_generate_joke["generate_joke"]:::stepStyle
5+
event_JokeEvent([<p>JokeEvent</p>]):::defaultEventStyle
6+
event_CritiqueEvent([<p>CritiqueEvent</p>]):::stopEventStyle
7+
event_TopicEvent([<p>TopicEvent</p>]):::defaultEventStyle
8+
event_CritiqueEvent --> step__done
9+
step_critique_joke --> event_CritiqueEvent
10+
event_JokeEvent --> step_critique_joke
11+
step_generate_joke --> event_JokeEvent
12+
event_TopicEvent --> step_generate_joke
13+
classDef stepStyle fill:#f2f0ff,line-height:1.2
14+
classDef externalStyle fill:#f2f0ff,line-height:1.2
15+
classDef defaultEventStyle fill-opacity:0
16+
classDef stopEventStyle fill:#bfb6fc
17+
classDef inputRequiredStyle fill:#f2f0ff,line-height:1.2
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": ["."],
3+
"workflows": {
4+
"agent": "main.py:agent"
5+
},
6+
"env": ".env"
7+
}

testcases/quickstart-agent/main.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from llama_index.core.workflow import (
2+
Event,
3+
StartEvent,
4+
StopEvent,
5+
Workflow,
6+
step,
7+
)
8+
9+
from uipath_llamaindex.llms import UiPathOpenAI
10+
11+
class TopicEvent(StartEvent):
12+
topic: str
13+
14+
15+
class JokeEvent(Event):
16+
joke: str
17+
18+
19+
class CritiqueEvent(StopEvent):
20+
joke: str
21+
critique: str
22+
23+
24+
class JokeFlow(Workflow):
25+
llm = UiPathOpenAI(model="gpt-4o-mini-2024-07-18")
26+
27+
@step
28+
async def generate_joke(self, ev: TopicEvent) -> JokeEvent:
29+
topic = ev.topic
30+
31+
prompt = f"Write your best joke about {topic}."
32+
response = await self.llm.acomplete(prompt)
33+
return JokeEvent(joke=str(response))
34+
35+
@step
36+
async def critique_joke(self, ev: JokeEvent) -> CritiqueEvent:
37+
joke = ev.joke
38+
39+
prompt = f"Give a thorough analysis and critique of the following joke: {joke}"
40+
response = await self.llm.acomplete(prompt)
41+
return CritiqueEvent(joke=joke, critique=str(response))
42+
43+
44+
agent = JokeFlow(timeout=60, verbose=False)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[project]
2+
name = "llama-quickstart-agent"
3+
version = "0.0.6"
4+
description = "UiPath LlamaIndex Quickstart Agent"
5+
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
6+
readme = { file = "README.md", content-type = "text/markdown" }
7+
requires-python = ">=3.10"
8+
dependencies = [
9+
"uipath-llamaindex>=0.0.29",
10+
"llama-index-llms-openai>=0.2.2",
11+
"uipath>=2.0.82",
12+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"entryPoints": [
3+
{
4+
"filePath": "agent",
5+
"uniqueId": "a1ac234f-75bc-4f3a-9bae-514f53cd86db",
6+
"type": "agent",
7+
"input": {
8+
"type": "object",
9+
"properties": {
10+
"topic": {
11+
"title": "Topic",
12+
"type": "string"
13+
}
14+
},
15+
"required": [
16+
"topic"
17+
]
18+
},
19+
"output": {
20+
"type": "object",
21+
"properties": {
22+
"joke": {
23+
"title": "Joke",
24+
"type": "string"
25+
},
26+
"critique": {
27+
"title": "Critique",
28+
"type": "string"
29+
}
30+
},
31+
"required": [
32+
"joke",
33+
"critique"
34+
]
35+
}
36+
}
37+
],
38+
"bindings": {
39+
"version": "2.0",
40+
"resources": []
41+
}
42+
}

0 commit comments

Comments
 (0)