Skip to content

Commit ea367ba

Browse files
committed
Switch to postgres
1 parent 34bdf31 commit ea367ba

37 files changed

+1047
-1919
lines changed

apps/web-evals/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.next
2+
tsconfig.tsbuildinfo

apps/web-evals/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scripts": {
55
"lint": "next lint",
66
"check-types": "tsc -b",
7-
"dev": "dotenvx run -f ../../.env -- next dev --turbopack",
7+
"dev": "next dev --turbopack",
88
"format": "prettier --write src",
99
"build": "next build",
1010
"start": "next start"
@@ -32,7 +32,7 @@
3232
"cmdk": "^1.1.0",
3333
"fuzzysort": "^3.1.0",
3434
"lucide-react": "^0.511.0",
35-
"next": "15.3.3",
35+
"next": "^15.2.5",
3636
"next-themes": "^0.4.6",
3737
"p-map": "^7.0.3",
3838
"ps-tree": "^1.2.0",
Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,17 @@
11
import { z } from "zod"
22
import { useQuery } from "@tanstack/react-query"
33

4-
import type { ModelInfo } from "@roo-code/types"
5-
64
export const openRouterModelSchema = z.object({
75
id: z.string(),
86
name: z.string(),
9-
description: z.string(),
10-
created: z.number(),
11-
context_length: z.number(),
12-
pricing: z.object({
13-
prompt: z.string().optional(),
14-
completion: z.string().optional(),
15-
}),
16-
top_provider: z
17-
.object({
18-
max_completion_tokens: z.number().nullish(),
19-
})
20-
.optional(),
21-
architecture: z
22-
.object({
23-
modality: z.string(),
24-
})
25-
.optional(),
267
})
278

28-
export type OpenRouterModel = z.infer<typeof openRouterModelSchema> & { modelInfo: ModelInfo }
9+
export type OpenRouterModel = z.infer<typeof openRouterModelSchema>
2910

3011
export const getOpenRouterModels = async (): Promise<OpenRouterModel[]> => {
3112
const response = await fetch("https://openrouter.ai/api/v1/models")
3213

3314
if (!response.ok) {
34-
console.error("Failed to fetch OpenRouter models")
3515
return []
3616
}
3717

@@ -42,19 +22,11 @@ export const getOpenRouterModels = async (): Promise<OpenRouterModel[]> => {
4222
return []
4323
}
4424

45-
return result.data.data
46-
.sort((a, b) => a.name.localeCompare(b.name))
47-
.map((rawModel) => ({
48-
...rawModel,
49-
modelInfo: {
50-
contextWindow: rawModel.context_length,
51-
supportsPromptCache: false,
52-
},
53-
}))
25+
return result.data.data.sort((a, b) => a.name.localeCompare(b.name))
5426
}
5527

5628
export const useOpenRouterModels = () =>
57-
useQuery<OpenRouterModel[]>({
29+
useQuery({
5830
queryKey: ["getOpenRouterModels"],
5931
queryFn: getOpenRouterModels,
6032
})

apps/web-evals/tsconfig.tsbuildinfo

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -u
5+
6+
if [ -n "$POSTGRES_DATABASES" ]; then
7+
for db in $(echo $POSTGRES_DATABASES | tr ',' ' '); do
8+
echo "Creating $db..."
9+
psql -U postgres -v ON_ERROR_STOP=1 -c "CREATE DATABASE $db;"
10+
done
11+
fi

packages/evals/.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DATABASE_URL=postgres://postgres:password@localhost:5432/evals_development

packages/evals/.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DATABASE_URL=postgres://postgres:password@localhost:5432/evals_test

packages/evals/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# .env
2+
!.env.development
3+
!.env.test
4+
5+
# docker
6+
.docker/*
7+
!.docker/scripts

packages/evals/docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
postgres:
3+
container_name: postgres-evals
4+
image: postgres:15.4
5+
ports:
6+
- 5432:5432
7+
volumes:
8+
- ./.docker/postgres:/var/lib/postgresql/data
9+
- ./.docker/scripts/postgres:/docker-entrypoint-initdb.d
10+
environment:
11+
- POSTGRES_USER=postgres
12+
- POSTGRES_PASSWORD=password
13+
- POSTGRES_DATABASES=evals_development,evals_test

packages/evals/drizzle.config.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { defineConfig } from "drizzle-kit"
22

3-
const dialect = process.env.BENCHMARKS_DB_PATH ? "sqlite" : "turso"
4-
5-
const dbCredentials = process.env.BENCHMARKS_DB_PATH
6-
? { url: process.env.BENCHMARKS_DB_PATH }
7-
: { url: process.env.TURSO_CONNECTION_URL!, authToken: process.env.TURSO_AUTH_TOKEN! }
8-
93
export default defineConfig({
10-
out: "./drizzle",
4+
out: "./src/db/migrations",
115
schema: "./src/db/schema.ts",
12-
dialect,
13-
dbCredentials,
6+
dialect: "postgresql",
7+
dbCredentials: { url: process.env.DATABASE_URL! },
8+
verbose: true,
9+
strict: true,
1410
})

0 commit comments

Comments
 (0)