Skip to content
Closed
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
Empty file.
49 changes: 49 additions & 0 deletions .github/workflows/retrieval-chain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Integration testing

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

jobs:
test-retrieval-chain:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Integration testing' step
Uses Step
uses 'docker/setup-buildx-action' with ref 'v3', not a pinned commit hash

- name: Build Docker image
run: |
docker build -t retrieval-chain:test \
--build-arg CLIENT_ID="${{ secrets.ALPHA_TEST_CLIENT_ID }}" \
--build-arg CLIENT_SECRET="${{ secrets.ALPHA_TEST_CLIENT_SECRET }}" \
--build-arg BASE_URL="${{ secrets.ALPHA_BASE_URL }}" \
.
working-directory: ./samples/company-research-agent
# env:
# ALPHA_BASE_URL: ${{ secrets.ALPHA_BASE_URL }}

- name: Test retrieval chain with default parameters
run: |
cd samples/retrieval-chain
docker run --rm \
-e CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
-e CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
-e BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
retrieval-chain:test

- name: Test retrieval chain with custom parameters
if: github.event_name == 'workflow_dispatch'
run: |
cd samples/retrieval-chain
docker run --rm \
-e CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
-e CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
-e BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
retrieval-chain:test \
/app/startup.sh --index_name "${{ github.event.inputs.index_name }}" --query "${{ github.event.inputs.query }}" --k ${{ github.event.inputs.k }}
52 changes: 52 additions & 0 deletions .github/workflows/test-retrieval-chain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test Retrieval Chain

on:
workflow_dispatch:
inputs:
index_name:
description: 'Index name to query'
required: true
default: 'ECCN'
query:
description: 'Query to search for'
required: true
default: 'What is the ECCN for a laptop?'
k:
description: 'Number of results to return'
required: false
default: '3'

jobs:
run-retrieval-chain:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build and run retrieval chain
run: |
cd samples/retrieval-chain

# Build the image
docker build -t retrieval-chain \
--build-arg CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
--build-arg CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
--build-arg BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
.

# Run with parameters
docker run --rm \
-e CLIENT_ID="${{ secrets.UIPATH_CLIENT_ID }}" \
-e CLIENT_SECRET="${{ secrets.UIPATH_CLIENT_SECRET }}" \
-e BASE_URL="${{ secrets.UIPATH_BASE_URL }}" \
retrieval-chain \
/app/startup.sh --index_name "${{ github.event.inputs.index_name }}" --query "${{ github.event.inputs.query }}" --k ${{ github.event.inputs.k }}

- name: Show completion
run: |
echo "✅ Retrieval chain completed successfully!"
echo "📊 Parameters used:"
echo " - Index: ${{ github.event.inputs.index_name }}"
echo " - Query: ${{ github.event.inputs.query }}"
echo " - Results: ${{ github.event.inputs.k }}"
Comment on lines +21 to +52

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 6 months ago

To fix the issue, we will add a permissions block at the root of the workflow file. This block will specify the minimal permissions required for the workflow to function correctly. Based on the workflow's operations, it only needs read access to the repository contents. Therefore, we will set contents: read in the permissions block.

The permissions block will be added directly under the name field in the workflow file to apply to all jobs in the workflow.


Suggested changeset 1
.github/workflows/test-retrieval-chain.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/test-retrieval-chain.yml b/.github/workflows/test-retrieval-chain.yml
--- a/.github/workflows/test-retrieval-chain.yml
+++ b/.github/workflows/test-retrieval-chain.yml
@@ -1,2 +1,4 @@
 name: Test Retrieval Chain
+permissions:
+  contents: read
 
EOF
@@ -1,2 +1,4 @@
name: Test Retrieval Chain
permissions:
contents: read

Copilot is powered by AI and may make mistakes. Always verify output.
88 changes: 88 additions & 0 deletions samples/company-research-agent/.github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build and Deploy Company Research Agent

on:
push:
branches: [ main, develop ]
paths:
- 'samples/company-research-agent/**'
pull_request:
branches: [ main ]
paths:
- 'samples/company-research-agent/**'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/company-research-agent

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix=sha-

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./samples/company-research-agent
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
CLIENT_ID=${{ secrets.UIPATH_CLIENT_ID }}
CLIENT_SECRET=${{ secrets.UIPATH_CLIENT_SECRET }}
BASE_URL=${{ secrets.UIPATH_BASE_URL }}
ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }}
TAVILY_API_KEY=${{ secrets.TAVILY_API_KEY }}

test:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run container tests
run: |
docker run --rm \
-e CLIENT_ID=${{ secrets.UIPATH_CLIENT_ID }} \
-e CLIENT_SECRET=${{ secrets.UIPATH_CLIENT_SECRET }} \
-e BASE_URL=${{ secrets.UIPATH_BASE_URL }} \
-e ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }} \
-e TAVILY_API_KEY=${{ secrets.TAVILY_API_KEY }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
/bin/bash -c "echo 'Container health check passed'"

deploy:
runs-on: ubuntu-latest
needs: [build, test]
if: github.ref == 'refs/heads/main'

steps:
- name: Deploy to production
run: |
echo "Deploying to production..."
# Add your deployment commands here
# For example, deploy to Azure Container Instances, AWS ECS, or Kubernetes
28 changes: 28 additions & 0 deletions samples/company-research-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ghcr.io/astral-sh/uv:python3.12-bookworm

WORKDIR /app

COPY . .

RUN uv sync

ARG CLIENT_ID
ARG CLIENT_SECRET
ARG BASE_URL

# Validate required environment variables
RUN if [ -z "$CLIENT_ID" ]; then echo "CLIENT_ID build arg is required" && exit 1; fi
RUN if [ -z "$CLIENT_SECRET" ]; then echo "CLIENT_SECRET build arg is required" && exit 1; fi
RUN if [ -z "$BASE_URL" ]; then echo "BASE_URL build arg is required" && exit 1; fi

# Set environment variables for runtime
ENV CLIENT_ID=$CLIENT_ID
ENV CLIENT_SECRET=$CLIENT_SECRET
ENV BASE_URL=$BASE_URL
ENV TAVILY_API_KEY=${TAVILY_API_KEY:-""}


# Authenticate with UiPath during build
RUN uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"

RUN uv run uipath run agent '{"company_name":"uipath"}'
14 changes: 10 additions & 4 deletions samples/company-research-agent/graph.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import os
from langchain_anthropic import ChatAnthropic
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain_community.tools import DuckDuckGoSearchResults
from langgraph.graph import END, START, MessagesState, StateGraph
from langgraph.prebuilt import create_react_agent
from pydantic import BaseModel
from uipath_langchain.chat import UiPathAzureChatOpenAI

# Set up the Tavily search tool
tavily_tool = TavilySearchResults(max_results=5)
if os.getenv("TAVILY_API_KEY"):
tool = TavilySearchResults(max_results=5)
else:
tool = DuckDuckGoSearchResults()

# Define system prompt
system_prompt = """You are an advanced AI assistant specializing in corporate research and outreach strategy development. Your primary functions are:
Expand All @@ -29,10 +35,10 @@

DO NOT do any math as specified in your instructions.
"""
llm = UiPathAzureChatOpenAI(model="gpt-4o-2024-08-06")
# llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

llm = ChatAnthropic(model="claude-3-5-sonnet-latest")

research_agent = create_react_agent(llm, tools=[tavily_tool], prompt=system_prompt)
research_agent = create_react_agent(llm, tools=[tool], prompt=system_prompt)


class GraphState(BaseModel):
Expand Down
13 changes: 12 additions & 1 deletion samples/company-research-agent/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ name = "company-research-agent"
version = "0.0.1"
description = "Company research agent with Tavily web search"
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]

requires-python = ">=3.10"
dependencies = [
"langgraph>=0.2.55",
"langchain-anthropic>=0.3.8",
"tavily-python>=0.5.0",
"uipath-langchain==0.0.113"
"uipath>=2.0.79",
"uipath-langchain==0.0.116",
"duckduckgo-search>=8.1.1",
"langchain-community>=0.3.21",
"debugpy>=1.8.15",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -41,3 +46,9 @@ lint.ignore = [

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["D", "UP"]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true
Loading
Loading