Skip to content

Commit 4256101

Browse files
author
Terry Zhao
authored
Merge pull request #9 from run-llama/terry/progress
integrate workflow tasks
2 parents 87c2da8 + 16f7ddf commit 4256101

File tree

19 files changed

+147
-326
lines changed

19 files changed

+147
-326
lines changed

test-proj/.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2-
_commit: 3a6a0ad
2+
_commit: e8edd1d
33
_src_path: .
44
project_name: test-proj
55
project_title: Test Proj

test-proj/ui/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
"dependencies": {
1717
"@babel/runtime": "^7.27.6",
1818
"@lezer/highlight": "^1.2.1",
19-
"@llamaindex/chat-ui": "^0.5.16",
2019
"@llamaindex/cloud": "^4.0.28",
21-
"@llamaindex/ui": "^0.3.2",
20+
"@llamaindex/ui": "^0.4.0",
2221
"@radix-ui/themes": "^3.2.1",
23-
"@swc/helpers": "^0.5.17",
2422
"class-variance-authority": "^0.7.1",
2523
"clsx": "^2.1.1",
2624
"lucide-react": "^0.514.0",

test-proj/ui/src/App.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import {
66
BreadcrumbItem,
77
BreadcrumbList,
88
BreadcrumbSeparator,
9+
ApiProvider,
910
} from "@llamaindex/ui";
1011
import { Link } from "react-router-dom";
1112
import { Toaster } from "@llamaindex/ui";
1213
import { useToolbar, ToolbarProvider } from "@/lib/ToolbarContext";
13-
import "@/lib/client";
14+
import { clients } from "@/lib/client";
15+
import { AGENT_NAME } from "@/lib/config";
1416

1517
// Import pages
1618
import HomePage from "./pages/HomePage";
@@ -19,18 +21,20 @@ import ItemPage from "./pages/ItemPage";
1921
export default function App() {
2022
return (
2123
<Theme>
22-
<ToolbarProvider>
23-
<div className="grid grid-rows-[auto_1fr] h-screen">
24-
<Toolbar />
25-
<main className="overflow-auto">
26-
<Routes>
27-
<Route path="/" element={<HomePage />} />
28-
<Route path="/item/:itemId" element={<ItemPage />} />
29-
</Routes>
30-
</main>
31-
</div>
32-
<Toaster />
33-
</ToolbarProvider>
24+
<ApiProvider clients={clients} deployment={AGENT_NAME}>
25+
<ToolbarProvider>
26+
<div className="grid grid-rows-[auto_1fr] h-screen">
27+
<Toolbar />
28+
<main className="overflow-auto">
29+
<Routes>
30+
<Route path="/" element={<HomePage />} />
31+
<Route path="/item/:itemId" element={<ItemPage />} />
32+
</Routes>
33+
</main>
34+
</div>
35+
<Toaster />
36+
</ToolbarProvider>
37+
</ApiProvider>
3438
</Theme>
3539
);
3640
}

test-proj/ui/src/components/workflow-trigger.tsx

Lines changed: 0 additions & 115 deletions
This file was deleted.

test-proj/ui/src/lib/client.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
1-
import { client as platformClient } from "@llamaindex/cloud/api";
1+
import { MySchema } from "@/schemas/MySchema";
2+
import { ExtractedData } from "@llamaindex/cloud/beta/agent";
3+
import { ApiClients } from "@llamaindex/ui";
4+
import {
5+
createCloudAgentClient,
6+
createLlamaDeployClient,
7+
createLlamaDeployConfig,
8+
cloudApiClient,
9+
} from "@llamaindex/ui";
10+
import { EXTRACTED_DATA_COLLECTION } from "./config";
211

312
const platformToken = import.meta.env.VITE_LLAMA_CLOUD_API_KEY;
413
const apiBaseUrl = import.meta.env.VITE_LLAMA_CLOUD_BASE_URL;
514

615
// Configure the platform client
7-
platformClient.setConfig({
16+
cloudApiClient.setConfig({
817
baseUrl: apiBaseUrl,
918
headers: {
1019
...(platformToken && { authorization: `Bearer ${platformToken}` }),
1120
},
1221
});
1322

14-
export { platformClient };
23+
const agentClient = createCloudAgentClient<ExtractedData<MySchema>>({
24+
baseUrl: apiBaseUrl,
25+
apiKey: platformToken,
26+
windowUrl: typeof window !== "undefined" ? window.location.href : undefined,
27+
collection: EXTRACTED_DATA_COLLECTION,
28+
});
29+
30+
const clients: ApiClients = {
31+
llamaDeployClient: createLlamaDeployClient(createLlamaDeployConfig()),
32+
cloudApiClient: cloudApiClient,
33+
agentDataClient: agentClient,
34+
};
35+
36+
export { clients, agentClient };

test-proj/ui/src/lib/data.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

test-proj/ui/src/pages/HomePage.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@
1717
justify-content: flex-end;
1818
margin-bottom: 1rem;
1919
}
20+
21+
.progressBar {
22+
margin-bottom: 1rem;
23+
}

test-proj/ui/src/pages/HomePage.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { ItemGrid, ItemCount } from "@llamaindex/ui";
1+
import {
2+
ItemGrid,
3+
ItemCount,
4+
WorkflowTrigger,
5+
WorkflowProgressBar,
6+
} from "@llamaindex/ui";
27
import type { TypedAgentData } from "@llamaindex/cloud/beta/agent";
38
import styles from "./HomePage.module.css";
49
import { useNavigate } from "react-router-dom";
5-
import TriggerFileWorkflow from "@/components/workflow-trigger";
6-
import { data } from "@/lib/data";
10+
import { agentClient } from "@/lib/client";
11+
12+
const deployment = import.meta.env.VITE_LLAMA_DEPLOY_DEPLOYMENT_NAME;
713

814
export default function HomePage() {
915
const lastMonth = new Date(
@@ -20,28 +26,37 @@ export default function HomePage() {
2026
<ItemCount
2127
title="Total Documents"
2228
filter={{ created_at: { gt: lastMonth } }}
23-
client={data}
29+
client={agentClient}
2430
/>
2531
<ItemCount
2632
title="Reviewed"
2733
filter={{
2834
created_at: { gt: lastMonth },
2935
status: { eq: "approved" },
3036
}}
31-
client={data}
37+
client={agentClient}
3238
/>
3339
<ItemCount
3440
title="Needs Review"
3541
filter={{
3642
created_at: { gt: lastMonth },
3743
status: { eq: "pending_review" },
3844
}}
39-
client={data}
45+
client={agentClient}
4046
/>
4147
</div>
4248
<div className={styles.commandBar}>
43-
<TriggerFileWorkflow />
49+
<WorkflowTrigger
50+
deployment={deployment}
51+
workflow="process-file"
52+
customWorkflowInput={(files) => {
53+
return {
54+
file_id: files[0].fileId,
55+
};
56+
}}
57+
/>
4458
</div>
59+
<WorkflowProgressBar className={styles.progressBar} />
4560
<ItemGrid
4661
onRowClick={goToItem}
4762
builtInColumns={{
@@ -51,7 +66,7 @@ export default function HomePage() {
5166
itemsToReview: true,
5267
actions: true,
5368
}}
54-
client={data}
69+
client={agentClient}
5570
/>
5671
</main>
5772
</div>

test-proj/ui/src/pages/ItemPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import MyJsonSchema from "../schemas/MySchema.json" with { type: "json" };
1212
import { useToolbar } from "@/lib/ToolbarContext";
1313
import { useNavigate } from "react-router-dom";
1414
import { modifyJsonSchema } from "@llamaindex/ui/lib";
15-
import { data as dataClient } from "@/lib/data";
15+
import { agentClient } from "@/lib/client";
1616
import { APP_TITLE } from "@/lib/config";
1717

1818
export default function ItemPage() {
@@ -25,7 +25,7 @@ export default function ItemPage() {
2525
jsonSchema: modifyJsonSchema(MyJsonSchema as any, {}),
2626
itemId: itemId as string,
2727
isMock: false,
28-
client: dataClient,
28+
client: agentClient,
2929
});
3030

3131
const navigate = useNavigate();

ui/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
"dependencies": {
1717
"@babel/runtime": "^7.27.6",
1818
"@lezer/highlight": "^1.2.1",
19-
"@llamaindex/chat-ui": "^0.5.16",
2019
"@llamaindex/cloud": "^4.0.28",
21-
"@llamaindex/ui": "^0.3.2",
20+
"@llamaindex/ui": "file:/Users/terryzhao/work/llama-ui/packages/ui",
2221
"@radix-ui/themes": "^3.2.1",
23-
"@swc/helpers": "^0.5.17",
2422
"class-variance-authority": "^0.7.1",
2523
"clsx": "^2.1.1",
2624
"lucide-react": "^0.514.0",

0 commit comments

Comments
 (0)