From 9e7bfbbac0b6c7e988607c7e688c9b15e718709c Mon Sep 17 00:00:00 2001 From: Terry Zhao Date: Thu, 18 Sep 2025 15:13:04 -0700 Subject: [PATCH] Terry/qa template (#2) * fix * fix * change readme * update readme * chore: pass empty filter to hatch run * chore: pin click 8.1.7 for hatch * chore: remove hatch filter now that click is pinned * fix: ensure dotenv import precedes client import --- .github/workflows/check-regeneration.yml | 3 +-- README.md | 2 -- pyproject.toml.jinja | 1 + src/{{ project_name_snake }}/qa_workflows.py | 16 +++++++++------- test-proj/.copier-answers.yml | 5 ++--- test-proj/README.md | 2 -- test-proj/pyproject.toml | 1 + test-proj/src/test_proj/qa_workflows.py | 16 +++++++++------- test-proj/ui/src/libs/config.ts | 1 + test-proj/ui/src/pages/Home.tsx | 12 ++---------- ui/src/libs/config.ts | 3 +++ ui/src/libs/config.ts.jinja | 1 + ui/src/pages/Home.tsx | 12 ++---------- 13 files changed, 32 insertions(+), 43 deletions(-) create mode 100644 ui/src/libs/config.ts diff --git a/.github/workflows/check-regeneration.yml b/.github/workflows/check-regeneration.yml index cb15cea..5651e8e 100644 --- a/.github/workflows/check-regeneration.yml +++ b/.github/workflows/check-regeneration.yml @@ -62,8 +62,7 @@ jobs: - name: Activate pnpm version working-directory: test-proj/ui run: corepack prepare --activate - - name: Run UI checks run: pnpm run all-check - working-directory: test-proj/ui \ No newline at end of file + working-directory: test-proj/ui diff --git a/README.md b/README.md index 92d1b72..8163f52 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ This application uses LlamaDeploy. For more information see [the docs](https://d 1. install `uv` if you haven't `brew install uv` 2. run `uvx llamactl serve` -3. Visit http://localhost:4501/docs and see workflow APIs - # Organization diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index 08d2618..0e4b1af 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -20,6 +20,7 @@ build-backend = "hatchling.build" [dependency-groups] dev = [ + "click==8.1.7", "hatch>=1.14.1", "pytest>=8.4.2", "ruff>=0.13.0", diff --git a/src/{{ project_name_snake }}/qa_workflows.py b/src/{{ project_name_snake }}/qa_workflows.py index 5363255..a6a5878 100644 --- a/src/{{ project_name_snake }}/qa_workflows.py +++ b/src/{{ project_name_snake }}/qa_workflows.py @@ -1,10 +1,16 @@ import logging import os +import tempfile import httpx +from dotenv import load_dotenv from llama_cloud.types import RetrievalMode -import tempfile +from llama_index.core import Settings from llama_index.core.chat_engine.types import BaseChatEngine, ChatMode +from llama_index.core.memory import ChatMemoryBuffer +from llama_index.embeddings.openai import OpenAIEmbedding +from llama_index.llms.openai import OpenAI +from llama_cloud_services import LlamaCloudIndex from workflows import Workflow, step, Context from workflows.events import ( StartEvent, @@ -15,12 +21,6 @@ from workflows.events import ( ) from workflows.retry_policy import ConstantDelayRetryPolicy -from llama_cloud_services import LlamaCloudIndex -from llama_index.core import Settings -from llama_index.llms.openai import OpenAI -from llama_index.embeddings.openai import OpenAIEmbedding -from llama_index.core.memory import ChatMemoryBuffer - from .clients import ( LLAMA_CLOUD_API_KEY, LLAMA_CLOUD_BASE_URL, @@ -30,6 +30,8 @@ from .clients import ( LLAMA_CLOUD_PROJECT_ID, ) +load_dotenv() + logger = logging.getLogger(__name__) diff --git a/test-proj/.copier-answers.yml b/test-proj/.copier-answers.yml index 8463373..f34abb6 100644 --- a/test-proj/.copier-answers.yml +++ b/test-proj/.copier-answers.yml @@ -1,6 +1,5 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: '2405947' +_commit: c9f43f6 _src_path: . -llama_org_id: asdf -llama_project_id: asdf project_name: test-proj +project_title: Test Proj diff --git a/test-proj/README.md b/test-proj/README.md index 92d1b72..8163f52 100644 --- a/test-proj/README.md +++ b/test-proj/README.md @@ -9,8 +9,6 @@ This application uses LlamaDeploy. For more information see [the docs](https://d 1. install `uv` if you haven't `brew install uv` 2. run `uvx llamactl serve` -3. Visit http://localhost:4501/docs and see workflow APIs - # Organization diff --git a/test-proj/pyproject.toml b/test-proj/pyproject.toml index 7206b7e..f7706af 100644 --- a/test-proj/pyproject.toml +++ b/test-proj/pyproject.toml @@ -20,6 +20,7 @@ build-backend = "hatchling.build" [dependency-groups] dev = [ + "click==8.1.7", "hatch>=1.14.1", "pytest>=8.4.2", "ruff>=0.13.0", diff --git a/test-proj/src/test_proj/qa_workflows.py b/test-proj/src/test_proj/qa_workflows.py index 5363255..a6a5878 100644 --- a/test-proj/src/test_proj/qa_workflows.py +++ b/test-proj/src/test_proj/qa_workflows.py @@ -1,10 +1,16 @@ import logging import os +import tempfile import httpx +from dotenv import load_dotenv from llama_cloud.types import RetrievalMode -import tempfile +from llama_index.core import Settings from llama_index.core.chat_engine.types import BaseChatEngine, ChatMode +from llama_index.core.memory import ChatMemoryBuffer +from llama_index.embeddings.openai import OpenAIEmbedding +from llama_index.llms.openai import OpenAI +from llama_cloud_services import LlamaCloudIndex from workflows import Workflow, step, Context from workflows.events import ( StartEvent, @@ -15,12 +21,6 @@ from workflows.events import ( ) from workflows.retry_policy import ConstantDelayRetryPolicy -from llama_cloud_services import LlamaCloudIndex -from llama_index.core import Settings -from llama_index.llms.openai import OpenAI -from llama_index.embeddings.openai import OpenAIEmbedding -from llama_index.core.memory import ChatMemoryBuffer - from .clients import ( LLAMA_CLOUD_API_KEY, LLAMA_CLOUD_BASE_URL, @@ -30,6 +30,8 @@ from .clients import ( LLAMA_CLOUD_PROJECT_ID, ) +load_dotenv() + logger = logging.getLogger(__name__) diff --git a/test-proj/ui/src/libs/config.ts b/test-proj/ui/src/libs/config.ts index fec32d8..83db88a 100644 --- a/test-proj/ui/src/libs/config.ts +++ b/test-proj/ui/src/libs/config.ts @@ -1,2 +1,3 @@ export const APP_TITLE = "Test Proj"; export const AGENT_NAME = import.meta.env.VITE_LLAMA_DEPLOY_DEPLOYMENT_NAME; +export const INDEX_NAME = "document_qa_index"; diff --git a/test-proj/ui/src/pages/Home.tsx b/test-proj/ui/src/pages/Home.tsx index 89208a0..c8d54b8 100644 --- a/test-proj/ui/src/pages/Home.tsx +++ b/test-proj/ui/src/pages/Home.tsx @@ -1,6 +1,6 @@ import ChatBot from "../components/ChatBot"; import { WorkflowTrigger } from "@llamaindex/ui"; -import { APP_TITLE } from "../libs/config"; +import { APP_TITLE, INDEX_NAME } from "../libs/config"; export default function Home() { return ( @@ -20,18 +20,10 @@ export default function Home() {
{ return { file_id: files[0].fileId, - index_name: fieldValues.index_name, + index_name: INDEX_NAME, }; }} /> diff --git a/ui/src/libs/config.ts b/ui/src/libs/config.ts new file mode 100644 index 0000000..b5fa29e --- /dev/null +++ b/ui/src/libs/config.ts @@ -0,0 +1,3 @@ +export const APP_TITLE = "Test Project"; +export const AGENT_NAME = import.meta.env.VITE_LLAMA_DEPLOY_DEPLOYMENT_NAME; +export const INDEX_NAME = "document_qa_index"; \ No newline at end of file diff --git a/ui/src/libs/config.ts.jinja b/ui/src/libs/config.ts.jinja index acd8c84..f82681d 100644 --- a/ui/src/libs/config.ts.jinja +++ b/ui/src/libs/config.ts.jinja @@ -1,2 +1,3 @@ export const APP_TITLE = "{{ project_title }}"; export const AGENT_NAME = import.meta.env.VITE_LLAMA_DEPLOY_DEPLOYMENT_NAME; +export const INDEX_NAME = "document_qa_index"; diff --git a/ui/src/pages/Home.tsx b/ui/src/pages/Home.tsx index 89208a0..c8d54b8 100644 --- a/ui/src/pages/Home.tsx +++ b/ui/src/pages/Home.tsx @@ -1,6 +1,6 @@ import ChatBot from "../components/ChatBot"; import { WorkflowTrigger } from "@llamaindex/ui"; -import { APP_TITLE } from "../libs/config"; +import { APP_TITLE, INDEX_NAME } from "../libs/config"; export default function Home() { return ( @@ -20,18 +20,10 @@ export default function Home() {
{ return { file_id: files[0].fileId, - index_name: fieldValues.index_name, + index_name: INDEX_NAME, }; }} />