Skip to content

Commit efb5189

Browse files
authored
Merge pull request #8 from HirotoShioi/fix-medicine
Fix medicine
2 parents ee17344 + 5b8bf71 commit efb5189

32 files changed

+4332
-4824
lines changed

.github/workflows/ci.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Frontend CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "apps/frontend/**"
8+
pull_request:
9+
branches: [main]
10+
paths:
11+
- "apps/frontend/**"
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "18"
24+
25+
- name: Install pnpm
26+
uses: pnpm/action-setup@v2
27+
with:
28+
version: 8
29+
30+
- name: Get pnpm store directory
31+
shell: bash
32+
run: |
33+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
34+
35+
- name: Setup pnpm cache
36+
uses: actions/cache@v4
37+
with:
38+
path: ${{ env.STORE_PATH }}
39+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
40+
restore-keys: |
41+
${{ runner.os }}-pnpm-store-
42+
43+
- name: Install dependencies
44+
working-directory: ./apps/frontend
45+
run: pnpm install
46+
47+
- name: Run linting
48+
working-directory: ./apps/frontend
49+
run: pnpm lint
50+
51+
- name: Build
52+
working-directory: ./apps/frontend
53+
run: pnpm build

apps/backend/package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
"cf-typegen": "wrangler types"
1111
},
1212
"devDependencies": {
13-
"@cloudflare/vitest-pool-workers": "^0.5.10",
14-
"@cloudflare/workers-types": "^4.20240925.0",
15-
"vitest": "2.1.1",
16-
"wrangler": "^3.78.10"
13+
"@cloudflare/vitest-pool-workers": "^0.5.40",
14+
"@cloudflare/workers-types": "^4.20241218.0",
15+
"vitest": "2.1.8",
16+
"wrangler": "^3.99.0"
1717
},
1818
"dependencies": {
19-
"@hono-rate-limiter/cloudflare": "^0.2.1",
20-
"@hono/zod-validator": "^0.2.2",
19+
"@hono-rate-limiter/cloudflare": "^0.2.2",
20+
"@hono/zod-validator": "^0.4.2",
2121
"aws-jwt-verify": "^4.0.1",
2222
"fuzzball": "^2.1.3",
23-
"hono": "^4.6.2",
24-
"hono-rate-limiter": "^0.4.0",
23+
"hono": "^4.6.14",
24+
"hono-rate-limiter": "^0.4.2",
2525
"html-entities": "^2.5.2",
26-
"openai": "^4.64.0",
27-
"zod": "^3.23.8"
26+
"openai": "^4.77.0",
27+
"zod": "^3.24.1"
2828
}
2929
}

apps/frontend/package.json

+62-63
Original file line numberDiff line numberDiff line change
@@ -14,92 +14,91 @@
1414
"deploy": "pnpm run build && wrangler pages deploy ./dist"
1515
},
1616
"dependencies": {
17-
"@ai-sdk/openai": "^0.0.62",
18-
"@ai-sdk/react": "^0.0.60",
19-
"@aws-amplify/ui-react": "^6.5.2",
20-
"@cloudflare/workers-types": "^4.20240925.0",
21-
"@electric-sql/pglite": "^0.2.10",
22-
"@electric-sql/pglite-react": "^0.2.10",
23-
"@hookform/resolvers": "^3.9.0",
24-
"@langchain/community": "^0.3.4",
25-
"@langchain/core": "^0.3.7",
26-
"@langchain/langgraph": "^0.2.11",
27-
"@langchain/openai": "^0.3.5",
28-
"@radix-ui/react-alert-dialog": "^1.1.2",
29-
"@radix-ui/react-avatar": "^1.1.1",
30-
"@radix-ui/react-checkbox": "^1.1.2",
31-
"@radix-ui/react-dialog": "^1.1.2",
32-
"@radix-ui/react-dropdown-menu": "^2.1.2",
33-
"@radix-ui/react-label": "^2.1.0",
34-
"@radix-ui/react-popover": "^1.1.2",
35-
"@radix-ui/react-scroll-area": "^1.2.0",
36-
"@radix-ui/react-select": "^2.1.2",
37-
"@radix-ui/react-slot": "^1.1.0",
38-
"@radix-ui/react-toast": "^1.2.2",
39-
"@radix-ui/react-tooltip": "^1.1.3",
40-
"@tanstack/react-query": "^5.59.0",
41-
"@tanstack/react-query-devtools": "^5.59.0",
42-
"@types/react-router-dom": "^5.3.3",
43-
"ai": "^3.4.9",
44-
"aws-amplify": "^6.6.3",
45-
"class-variance-authority": "^0.7.0",
17+
"@ai-sdk/openai": "^1.0.0",
18+
"@ai-sdk/react": "^1.0.0",
19+
"@aws-amplify/ui-react": "^6.7.2",
20+
"@cloudflare/workers-types": "^4.20241218.0",
21+
"@electric-sql/pglite": "^0.2.15",
22+
"@electric-sql/pglite-react": "^0.2.15",
23+
"@hookform/resolvers": "^3.9.1",
24+
"@langchain/community": "^0.3.19",
25+
"@langchain/core": "^0.3.26",
26+
"@langchain/langgraph": "^0.2.34",
27+
"@langchain/openai": "^0.3.16",
28+
"@radix-ui/react-alert-dialog": "^1.1.4",
29+
"@radix-ui/react-avatar": "^1.1.2",
30+
"@radix-ui/react-checkbox": "^1.1.3",
31+
"@radix-ui/react-dialog": "^1.1.4",
32+
"@radix-ui/react-dropdown-menu": "^2.1.4",
33+
"@radix-ui/react-label": "^2.1.1",
34+
"@radix-ui/react-popover": "^1.1.4",
35+
"@radix-ui/react-scroll-area": "^1.2.2",
36+
"@radix-ui/react-select": "^2.1.4",
37+
"@radix-ui/react-slot": "^1.1.1",
38+
"@radix-ui/react-toast": "^1.2.4",
39+
"@radix-ui/react-tooltip": "^1.1.6",
40+
"@tanstack/react-query": "^5.62.8",
41+
"@tanstack/react-query-devtools": "^5.62.8",
42+
"@types/react-router": "^5.1.0",
43+
"ai": "^4.0.0",
44+
"aws-amplify": "^6.11.0",
45+
"class-variance-authority": "^0.7.1",
4646
"clsx": "^2.1.1",
4747
"common-tags": "^1.8.2",
4848
"date-fns": "^3.6.0",
49-
"drizzle-orm": "^0.33.0",
50-
"drizzle-zod": "^0.5.1",
51-
"framer-motion": "^11.11.1",
52-
"i18next": "^23.15.1",
53-
"i18next-browser-languagedetector": "^8.0.0",
54-
"i18next-http-backend": "^2.6.2",
55-
"langchain": "^0.3.2",
49+
"drizzle-orm": "^0.38.2",
50+
"drizzle-zod": "^0.6.0",
51+
"i18next": "^23.16.8",
52+
"i18next-browser-languagedetector": "^8.0.2",
53+
"i18next-http-backend": "^2.7.1",
54+
"langchain": "^0.3.7",
5655
"lucide-react": "^0.417.0",
57-
"nanoid": "^5.0.7",
56+
"nanoid": "^5.0.9",
5857
"react": "^18.3.1",
5958
"react-day-picker": "8.10.1",
6059
"react-dom": "^18.3.1",
61-
"react-dropzone": "^14.2.9",
62-
"react-hook-form": "^7.53.0",
63-
"react-i18next": "^15.0.2",
60+
"react-dropzone": "^14.3.5",
61+
"react-hook-form": "^7.54.2",
62+
"react-i18next": "^15.2.0",
6463
"react-markdown": "^9.0.1",
65-
"react-router-dom": "^6.26.2",
64+
"react-router": "^7.1.0",
6665
"rehype-raw": "^7.0.0",
6766
"remark-gfm": "^4.0.0",
68-
"tailwind-merge": "^2.5.3",
67+
"tailwind-merge": "^2.5.5",
6968
"tailwindcss-animate": "^1.0.7",
7069
"tesseract.js": "^5.1.1",
7170
"unpdf": "^0.11.0",
72-
"zod": "^3.23.8",
71+
"zod": "^3.24.1",
7372
"zustand": "^4.5.5"
7473
},
7574
"devDependencies": {
76-
"@chromatic-com/storybook": "^1.9.0",
77-
"@storybook/addon-essentials": "^8.3.5",
78-
"@storybook/addon-interactions": "^8.3.5",
79-
"@storybook/addon-links": "^8.3.5",
80-
"@storybook/addon-onboarding": "^8.3.5",
81-
"@storybook/blocks": "^8.3.5",
82-
"@storybook/react": "^8.3.5",
83-
"@storybook/react-vite": "^8.3.5",
84-
"@storybook/test": "^8.3.5",
85-
"@tanstack/eslint-plugin-query": "^5.59.1",
75+
"@chromatic-com/storybook": "^3.2.3",
76+
"@storybook/addon-essentials": "^8.4.7",
77+
"@storybook/addon-interactions": "^8.4.7",
78+
"@storybook/addon-links": "^8.4.7",
79+
"@storybook/addon-onboarding": "^8.4.7",
80+
"@storybook/blocks": "^8.4.7",
81+
"@storybook/react": "^8.4.7",
82+
"@storybook/react-vite": "^8.4.7",
83+
"@storybook/test": "^8.4.7",
84+
"@tanstack/eslint-plugin-query": "^5.62.1",
8685
"@types/common-tags": "^1.8.4",
87-
"@types/react": "^18.3.11",
88-
"@types/react-dom": "^18.3.0",
86+
"@types/react": "^18.3.18",
87+
"@types/react-dom": "^18.3.5",
8988
"@typescript-eslint/eslint-plugin": "^7.18.0",
9089
"@typescript-eslint/parser": "^7.18.0",
91-
"@vitejs/plugin-react": "^4.3.2",
90+
"@vitejs/plugin-react": "^4.3.4",
9291
"autoprefixer": "^10.4.20",
9392
"drizzle-kit": "^0.24.2",
9493
"eslint": "^8.57.1",
9594
"eslint-plugin-react-hooks": "^4.6.2",
96-
"eslint-plugin-react-refresh": "^0.4.12",
95+
"eslint-plugin-react-refresh": "^0.4.16",
9796
"eslint-plugin-storybook": "^0.8.0",
98-
"postcss": "^8.4.47",
99-
"storybook": "^8.3.5",
100-
"tailwindcss": "^3.4.13",
101-
"vite": "^5.4.8",
102-
"vitest": "^2.1.2",
103-
"wrangler": "^3.80.0"
97+
"postcss": "^8.4.49",
98+
"storybook": "^8.4.7",
99+
"tailwindcss": "^3.4.17",
100+
"vite": "^6.0.5",
101+
"vitest": "^2.1.8",
102+
"wrangler": "^3.99.0"
104103
}
105104
}

apps/frontend/public/locales/en/translation.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
"embeddingResources": "Embedding resources",
8080
"processing": "Processing...",
8181
"generatingDocument": "Generating document",
82-
"searchingWeb": "Searching web"
82+
"searchingWeb": "Searching web",
83+
"searchingMedicine": "Searching medicine information"
8384
},
8485
"resourceUploader": {
8586
"dropFiles": "Drop files here",

apps/frontend/public/locales/ja/translation.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
"embeddingResources": "リソースを追加中...",
9090
"processing": "処理中...",
9191
"generatingDocument": "ドキュメントを生成中",
92-
"searchingWeb": "Webを検索中"
92+
"searchingWeb": "Webを検索中",
93+
"searchingMedicine": "薬品情報を検索中"
9394
},
9495
"callback": {
9596
"redirecting": "リダイレクト中..."

apps/frontend/src/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
createBrowserRouter,
33
redirect,
44
RouterProvider,
5-
} from "react-router-dom";
5+
} from "react-router";
66
import ErrorPage from "@/pages/error-page";
77
import Root from "@/routes/root";
88
import Providers from "@/providers/providers";

apps/frontend/src/components/dropdown.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useAuthenticator } from "@aws-amplify/ui-react";
88
import { signOut } from "aws-amplify/auth";
99
import { Menu } from "lucide-react";
1010
import { useTranslation } from "react-i18next";
11-
import { Link } from "react-router-dom";
11+
import { Link } from "react-router";
1212

1313
export function HeaderMenuItem({
1414
href,

apps/frontend/src/components/header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
3-
import { Link } from "react-router-dom";
3+
import { Link } from "react-router";
44
import Dropdown from "./dropdown";
55
import { Logo } from "./logo";
66

apps/frontend/src/components/logo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Link, useNavigate } from "react-router-dom";
1+
import { Link, useNavigate } from "react-router";
22
import {
33
Sheet,
44
SheetContent,

apps/frontend/src/components/usage-tooltip.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
AlertDialogTitle,
1515
AlertDialogTrigger,
1616
} from "./ui/alert-dialog";
17-
import { useNavigate } from "react-router-dom";
17+
import { useNavigate } from "react-router";
1818
import { useTranslation } from "react-i18next";
1919

2020
export type UsageTooltipProps = {

apps/frontend/src/hooks/use-chat.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function handleChat(req: Request) {
6868
apiKey: session.tokens.idToken.toString(),
6969
baseURL: import.meta.env.VITE_API_URL,
7070
}).chat(userPreferences.llmModel);
71-
const result = await streamText({
71+
const result = streamText({
7272
model: model,
7373
system: codeBlock`Today's date: ${new Date().toLocaleDateString()}
7474
${settings.systemMessage}`,
@@ -181,10 +181,17 @@ function searchMedicineTool() {
181181
This tool enables you to search for medicine information. It'll return a list of medicines that match the query.
182182
`,
183183
parameters: z.object({
184-
query: z.string().describe("The query to search for."),
184+
medicineNames: z
185+
.array(
186+
z.string().describe("The name of the medicine to search for.")
187+
)
188+
.describe("List of medicine names to search for."),
185189
}),
186-
execute: async ({ query }) => {
187-
return searchMedicine(query);
190+
execute: async ({ medicineNames }) => {
191+
const medicines = await Promise.all(
192+
medicineNames.map((name) => searchMedicine(name))
193+
);
194+
return medicines.flat();
188195
},
189196
});
190197
}

apps/frontend/src/lib/ai/util.ts

-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ function toLangChainMessage(message: Message): BaseMessage[] {
2727
}
2828
return message.toolInvocations.map(toToolMessage);
2929
}
30-
case "tool": {
31-
if (!message.toolInvocations) {
32-
return [];
33-
}
34-
return message.toolInvocations.map(toToolMessage);
35-
}
3630
case "data": {
3731
return [new HumanMessage(message.content)];
3832
}

apps/frontend/src/lib/api.ts

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ async function searchWeb(
6161
}
6262

6363
type Medicine = {
64+
query: string;
6465
medicineName: string;
6566
genericName: string;
6667
url: string;
@@ -87,6 +88,7 @@ async function searchMedicine(query: string): Promise<Medicine[]> {
8788
url: string;
8889
}[];
8990
return json.map((medicine) => ({
91+
query,
9092
medicineName: medicine.medicine_name,
9193
genericName: medicine.generic_name,
9294
url: medicine.url,

0 commit comments

Comments
 (0)