Skip to content

Commit b9f8325

Browse files
committed
added retrieval-chain workflow
1 parent c24c5b0 commit b9f8325

File tree

10 files changed

+2157
-1515
lines changed

10 files changed

+2157
-1515
lines changed

.github/workflows/integration_test.yml

Whitespace-only changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Integration testing
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test-retrieval-chain:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Build Docker image
24+
run: |
25+
docker build -t retrieval-chain:test \
26+
--build-arg CLIENT_ID="${{ secrets.ALPHA_TEST_CLIENT_ID }}" \
27+
--build-arg CLIENT_SECRET="${{ secrets.ALPHA_TEST_CLIENT_SECRET }}" \
28+
--build-arg BASE_URL="${{ secrets.ALPHA_BASE_URL }}" \
29+
.
30+
working-directory: ./samples/company-research-agent
31+
# env:
32+
# ALPHA_BASE_URL: ${{ secrets.ALPHA_BASE_URL }}
33+
34+
- name: Test retrieval chain with default parameters
35+
run: |
36+
cd samples/retrieval-chain
37+
docker run --rm \
38+
-e CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
39+
-e CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
40+
-e BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
41+
retrieval-chain:test
42+
43+
- name: Test retrieval chain with custom parameters
44+
if: github.event_name == 'workflow_dispatch'
45+
run: |
46+
cd samples/retrieval-chain
47+
docker run --rm \
48+
-e CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
49+
-e CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
50+
-e BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
51+
retrieval-chain:test \
52+
/app/startup.sh --index_name "${{ github.event.inputs.index_name }}" --query "${{ github.event.inputs.query }}" --k ${{ github.event.inputs.k }}

.github/workflows/retrieval-chain.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Integration testing
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test-retrieval-chain:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
- name: Build Docker image
21+
run: |
22+
docker build -t retrieval-chain:test \
23+
--build-arg CLIENT_ID="${{ secrets.ALPHA_TEST_CLIENT_ID }}" \
24+
--build-arg CLIENT_SECRET="${{ secrets.ALPHA_TEST_CLIENT_SECRET }}" \
25+
--build-arg BASE_URL="${{ secrets.ALPHA_BASE_URL }}" \
26+
.
27+
working-directory: ./samples/company-research-agent
28+
# env:
29+
# ALPHA_BASE_URL: ${{ secrets.ALPHA_BASE_URL }}
30+
31+
- name: Test retrieval chain with default parameters
32+
run: |
33+
cd samples/retrieval-chain
34+
docker run --rm \
35+
-e CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
36+
-e CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
37+
-e BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
38+
retrieval-chain:test
39+
40+
- name: Test retrieval chain with custom parameters
41+
if: github.event_name == 'workflow_dispatch'
42+
run: |
43+
cd samples/retrieval-chain
44+
docker run --rm \
45+
-e CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
46+
-e CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
47+
-e BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
48+
retrieval-chain:test \
49+
/app/startup.sh --index_name "${{ github.event.inputs.index_name }}" --query "${{ github.event.inputs.query }}" --k ${{ github.event.inputs.k }}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Test Retrieval Chain
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
index_name:
7+
description: 'Index name to query'
8+
required: true
9+
default: 'ECCN'
10+
query:
11+
description: 'Query to search for'
12+
required: true
13+
default: 'What is the ECCN for a laptop?'
14+
k:
15+
description: 'Number of results to return'
16+
required: false
17+
default: '3'
18+
19+
jobs:
20+
run-retrieval-chain:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Build and run retrieval chain
28+
run: |
29+
cd samples/retrieval-chain
30+
31+
# Build the image
32+
docker build -t retrieval-chain \
33+
--build-arg CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
34+
--build-arg CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
35+
--build-arg BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
36+
.
37+
38+
# Run with parameters
39+
docker run --rm \
40+
-e CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
41+
-e CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
42+
-e BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
43+
retrieval-chain \
44+
/app/startup.sh --index_name "${{ github.event.inputs.index_name }}" --query "${{ github.event.inputs.query }}" --k ${{ github.event.inputs.k }}
45+
46+
- name: Show completion
47+
run: |
48+
echo "✅ Retrieval chain completed successfully!"
49+
echo "📊 Parameters used:"
50+
echo " - Index: ${{ github.event.inputs.index_name }}"
51+
echo " - Query: ${{ github.event.inputs.query }}"
52+
echo " - Results: ${{ github.event.inputs.k }}"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build and Deploy Company Research Agent
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
paths:
7+
- 'samples/company-research-agent/**'
8+
pull_request:
9+
branches: [ main ]
10+
paths:
11+
- 'samples/company-research-agent/**'
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}/company-research-agent
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Log in to Container Registry
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Extract metadata
36+
id: meta
37+
uses: docker/metadata-action@v5
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
tags: |
41+
type=ref,event=branch
42+
type=ref,event=pr
43+
type=sha,prefix=sha-
44+
45+
- name: Build and push Docker image
46+
uses: docker/build-push-action@v5
47+
with:
48+
context: ./samples/company-research-agent
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
52+
build-args: |
53+
CLIENT_ID=${{ secrets.UIPATH_CLIENT_ID }}
54+
CLIENT_SECRET=${{ secrets.UIPATH_CLIENT_SECRET }}
55+
BASE_URL=${{ secrets.UIPATH_BASE_URL }}
56+
ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }}
57+
TAVILY_API_KEY=${{ secrets.TAVILY_API_KEY }}
58+
59+
test:
60+
runs-on: ubuntu-latest
61+
needs: build
62+
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
66+
67+
- name: Run container tests
68+
run: |
69+
docker run --rm \
70+
-e CLIENT_ID=${{ secrets.UIPATH_CLIENT_ID }} \
71+
-e CLIENT_SECRET=${{ secrets.UIPATH_CLIENT_SECRET }} \
72+
-e BASE_URL=${{ secrets.UIPATH_BASE_URL }} \
73+
-e ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }} \
74+
-e TAVILY_API_KEY=${{ secrets.TAVILY_API_KEY }} \
75+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
76+
/bin/bash -c "echo 'Container health check passed'"
77+
78+
deploy:
79+
runs-on: ubuntu-latest
80+
needs: [build, test]
81+
if: github.ref == 'refs/heads/main'
82+
83+
steps:
84+
- name: Deploy to production
85+
run: |
86+
echo "Deploying to production..."
87+
# Add your deployment commands here
88+
# For example, deploy to Azure Container Instances, AWS ECS, or Kubernetes
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
13+
# Validate required environment variables
14+
RUN if [ -z "$CLIENT_ID" ]; then echo "CLIENT_ID build arg is required" && exit 1; fi
15+
RUN if [ -z "$CLIENT_SECRET" ]; then echo "CLIENT_SECRET build arg is required" && exit 1; fi
16+
RUN if [ -z "$BASE_URL" ]; then echo "BASE_URL build arg is required" && exit 1; fi
17+
18+
# Set environment variables for runtime
19+
ENV CLIENT_ID=$CLIENT_ID
20+
ENV CLIENT_SECRET=$CLIENT_SECRET
21+
ENV BASE_URL=$BASE_URL
22+
ENV TAVILY_API_KEY=${TAVILY_API_KEY:-""}
23+
24+
25+
# Authenticate with UiPath during build
26+
RUN uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"
27+
28+
RUN uv run uipath run agent '{"company_name":"uipath"}'

samples/company-research-agent/graph.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import os
12
from langchain_anthropic import ChatAnthropic
23
from langchain_community.tools.tavily_search import TavilySearchResults
4+
from langchain_community.tools import DuckDuckGoSearchResults
35
from langgraph.graph import END, START, MessagesState, StateGraph
46
from langgraph.prebuilt import create_react_agent
57
from pydantic import BaseModel
8+
from uipath_langchain.chat import UiPathAzureChatOpenAI
69

710
# Set up the Tavily search tool
8-
tavily_tool = TavilySearchResults(max_results=5)
11+
if os.getenv("TAVILY_API_KEY"):
12+
tool = TavilySearchResults(max_results=5)
13+
else:
14+
tool = DuckDuckGoSearchResults()
915

1016
# Define system prompt
1117
system_prompt = """You are an advanced AI assistant specializing in corporate research and outreach strategy development. Your primary functions are:
@@ -29,10 +35,10 @@
2935
3036
DO NOT do any math as specified in your instructions.
3137
"""
38+
llm = UiPathAzureChatOpenAI(model="gpt-4o-2024-08-06")
39+
# llm = ChatAnthropic(model="claude-3-5-sonnet-latest")
3240

33-
llm = ChatAnthropic(model="claude-3-5-sonnet-latest")
34-
35-
research_agent = create_react_agent(llm, tools=[tavily_tool], prompt=system_prompt)
41+
research_agent = create_react_agent(llm, tools=[tool], prompt=system_prompt)
3642

3743

3844
class GraphState(BaseModel):

samples/company-research-agent/pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ name = "company-research-agent"
33
version = "0.0.1"
44
description = "Company research agent with Tavily web search"
55
authors = [{ name = "John Doe", email = "[email protected]" }]
6+
67
requires-python = ">=3.10"
78
dependencies = [
89
"langgraph>=0.2.55",
910
"langchain-anthropic>=0.3.8",
1011
"tavily-python>=0.5.0",
11-
"uipath-langchain==0.0.113"
12+
"uipath>=2.0.79",
13+
"uipath-langchain==0.0.116",
14+
"duckduckgo-search>=8.1.1",
15+
"langchain-community>=0.3.21",
16+
"debugpy>=1.8.15",
1217
]
1318

1419
[project.optional-dependencies]
@@ -41,3 +46,9 @@ lint.ignore = [
4146

4247
[tool.ruff.lint.per-file-ignores]
4348
"tests/*" = ["D", "UP"]
49+
50+
[[tool.uv.index]]
51+
name = "testpypi"
52+
url = "https://test.pypi.org/simple/"
53+
publish-url = "https://test.pypi.org/legacy/"
54+
explicit = true

0 commit comments

Comments
 (0)