Skip to content

Commit 50826e8

Browse files
zhaotaiTerry Zhao
andauthored
Terry/better schema (#16)
* better schema * regenerate * fix format * regenerate * regenerate with fix * fix * remove any * go * rm re * fix lin * upgrade ui * up * fix format --------- Co-authored-by: Terry Zhao <terryzhao@runllama.ai>
1 parent b3f0436 commit 50826e8

File tree

10 files changed

+17
-23
lines changed

10 files changed

+17
-23
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
test-proj/uv.lock
2+
.venv
23
uv.lock
34
expected-proj
5+
test-proj/.venv
46
test-proj/ui/node_modules
57
test-proj/ui/pnpm-lock.yaml
68
ui/pnpm-lock.yaml

src/{{ project_name_snake }}/export_types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def generate_typescript_interfaces(schema_dir: Path):
5151
run_command(
5252
f"npx -y json-schema-to-typescript@15.0.4 -i '{schema_dir / '*.json'}' -o {schema_dir} --additionalProperties=false"
5353
)
54-
run_command(f"npx -y prettier@3.5.1 --write {schema_dir}")
5554

5655

5756
def load_module_from_path(module_name: str, file_path: Path) -> ModuleType:

test-proj/src/test_proj/export_types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def generate_typescript_interfaces(schema_dir: Path):
5151
run_command(
5252
f"npx -y json-schema-to-typescript@15.0.4 -i '{schema_dir / '*.json'}' -o {schema_dir} --additionalProperties=false"
5353
)
54-
run_command(f"npx -y prettier@3.5.1 --write {schema_dir}")
5554

5655

5756
def load_module_from_path(module_name: str, file_path: Path) -> ModuleType:

test-proj/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dependencies": {
1717
"@babel/runtime": "^7.27.6",
1818
"@lezer/highlight": "^1.2.1",
19-
"@llamaindex/ui": "^0.5.0",
19+
"@llamaindex/ui": "^0.5.1",
2020
"@radix-ui/themes": "^3.2.1",
2121
"class-variance-authority": "^0.7.1",
2222
"clsx": "^2.1.1",

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MySchema } from "@/schemas/MySchema";
22
import { ExtractedData } from "llama-cloud-services/beta/agent";
3-
import { ApiClients, JSONObject } from "@llamaindex/ui";
3+
import { ApiClients } from "@llamaindex/ui";
44
import {
55
createCloudAgentClient,
66
createLlamaDeployClient,
@@ -25,9 +25,7 @@ cloudApiClient.setConfig({
2525
},
2626
});
2727

28-
const agentClient = createCloudAgentClient<
29-
ExtractedData<MySchema & JSONObject>
30-
>({
28+
const agentClient = createCloudAgentClient<ExtractedData<MySchema>>({
3129
baseUrl: apiBaseUrl,
3230
apiKey: platformToken,
3331
windowUrl: typeof window !== "undefined" ? window.location.href : undefined,

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
AcceptReject,
44
ExtractedDataDisplay,
55
FilePreview,
6-
JSONObject,
76
useItemData,
87
type Highlight,
98
} from "@llamaindex/ui";
@@ -23,7 +22,7 @@ export default function ItemPage() {
2322
const [highlight, setHighlight] = useState<Highlight | undefined>(undefined);
2423

2524
// Use the hook to fetch item data
26-
const itemHookData = useItemData<MySchema & JSONObject>({
25+
const itemHookData = useItemData<MySchema>({
2726
// order/remove fields as needed here
2827
jsonSchema: modifyJsonSchema(MyJsonSchema as any, {}),
2928
itemId: itemId as string,
@@ -55,7 +54,7 @@ export default function ItemPage() {
5554
useEffect(() => {
5655
setButtons(() => [
5756
<div className="ml-auto flex items-center">
58-
<AcceptReject
57+
<AcceptReject<MySchema>
5958
itemData={itemHookData}
6059
onComplete={() => navigate("/")}
6160
/>
@@ -116,11 +115,11 @@ export default function ItemPage() {
116115
<div className="flex-1 bg-white h-full overflow-y-auto">
117116
<div className="p-4 space-y-4">
118117
{/* Extracted Data */}
119-
<ExtractedDataDisplay<MySchema & JSONObject>
118+
<ExtractedDataDisplay<MySchema>
120119
extractedData={itemData.data}
121120
title="Extracted Data"
122121
onChange={(updatedData) => {
123-
updateData(updatedData as any);
122+
updateData(updatedData);
124123
}}
125124
onClickField={(args) => {
126125
// TODO: set multiple highlights

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
"dependencies": {
1717
"@babel/runtime": "^7.27.6",
1818
"@lezer/highlight": "^1.2.1",
19-
"@llamaindex/cloud": "^4.0.28",
2019
"@llamaindex/ui": "file:/Users/terryzhao/work/llama-ui/packages/ui",
2120
"@radix-ui/themes": "^3.2.1",
2221
"class-variance-authority": "^0.7.1",
2322
"clsx": "^2.1.1",
23+
"llama-cloud-services": "^0.3.3",
2424
"lucide-react": "^0.514.0",
2525
"react": "^18.3.0",
2626
"react-dom": "^18.3.0",

ui/package.json.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dependencies": {
1717
"@babel/runtime": "^7.27.6",
1818
"@lezer/highlight": "^1.2.1",
19-
"@llamaindex/ui": "^0.5.0",
19+
"@llamaindex/ui": "^0.5.1",
2020
"@radix-ui/themes": "^3.2.1",
2121
"class-variance-authority": "^0.7.1",
2222
"clsx": "^2.1.1",

ui/src/lib/client.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MySchema } from "@/schemas/MySchema";
22
import { ExtractedData } from "llama-cloud-services/beta/agent";
3-
import { ApiClients, JSONObject } from "@llamaindex/ui";
3+
import { ApiClients } from "@llamaindex/ui";
44
import {
55
createCloudAgentClient,
66
createLlamaDeployClient,
@@ -25,9 +25,7 @@ cloudApiClient.setConfig({
2525
},
2626
});
2727

28-
const agentClient = createCloudAgentClient<
29-
ExtractedData<MySchema & JSONObject>
30-
>({
28+
const agentClient = createCloudAgentClient<ExtractedData<MySchema>>({
3129
baseUrl: apiBaseUrl,
3230
apiKey: platformToken,
3331
windowUrl: typeof window !== "undefined" ? window.location.href : undefined,

ui/src/pages/ItemPage.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
AcceptReject,
44
ExtractedDataDisplay,
55
FilePreview,
6-
JSONObject,
76
useItemData,
87
type Highlight,
98
} from "@llamaindex/ui";
@@ -23,7 +22,7 @@ export default function ItemPage() {
2322
const [highlight, setHighlight] = useState<Highlight | undefined>(undefined);
2423

2524
// Use the hook to fetch item data
26-
const itemHookData = useItemData<MySchema & JSONObject>({
25+
const itemHookData = useItemData<MySchema>({
2726
// order/remove fields as needed here
2827
jsonSchema: modifyJsonSchema(MyJsonSchema as any, {}),
2928
itemId: itemId as string,
@@ -55,7 +54,7 @@ export default function ItemPage() {
5554
useEffect(() => {
5655
setButtons(() => [
5756
<div className="ml-auto flex items-center">
58-
<AcceptReject
57+
<AcceptReject<MySchema>
5958
itemData={itemHookData}
6059
onComplete={() => navigate("/")}
6160
/>
@@ -116,11 +115,11 @@ export default function ItemPage() {
116115
<div className="flex-1 bg-white h-full overflow-y-auto">
117116
<div className="p-4 space-y-4">
118117
{/* Extracted Data */}
119-
<ExtractedDataDisplay<MySchema & JSONObject>
118+
<ExtractedDataDisplay<MySchema>
120119
extractedData={itemData.data}
121120
title="Extracted Data"
122121
onChange={(updatedData) => {
123-
updateData(updatedData as any);
122+
updateData(updatedData);
124123
}}
125124
onClickField={(args) => {
126125
// TODO: set multiple highlights

0 commit comments

Comments
 (0)