PostgreSQL 带向量数据库的安装

背景

做 AI 相关项目需要用到向量数据库,本来想直接使用 PostgreSQL ,结果发现默认的安装是没有安装向量数据库的,打算重新安装一个带向量支持的。

实现步骤如下:

Create Volume

创建一个相关的卷用于保存数据

1
docker volume create --driver local --opt device=C:\10.VM\data\pg02 --opt type=none --opt o=bind pg02

拉取相关 Docker 镜像

下面这个镜像是包含向量数据库的:

1
docker pull ankane/pgvector:latest

启动 docker

1
docker run --name pgvector --privileged -e POSTGRES_PASSWORD=pGp@ssw0rd -p 15678:5432 -v pg02:/var/lib/postgresql/data -d ankane/pgvector:latest
More...

从零搭建基于 AI GitHub 分析平台 (12) 批量生成总结并存储数据库

调整数据库,添加相关表

修改 prisma/schema.prisma:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
model Project {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
githubURL String
deleteAt DateTime?
usersProject UsersProject[]
commits Commit[]
}

model Commit {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

projectId String
project Project @relation(fields: [projectId], references: [id])

commitMessage String
commitHash String
commitAuthorName String
commitAuthorAvatar String
commitDate DateTime
// ai summary
summary String
}
More...

从零搭建基于 AI GitHub 分析平台 (11) 基于commit diff 生成 commit 的总结

效果:

执行语句 bun run src/lib/gpt.ts :

1
2
3
4
5
6
7
8
- Set `randomOption` default value to `1` in the examination page.
- Add `zod` schema validation and new hooks for exam records and questions.
- Replace `useStartWCDialog` with `useExamDialog` for handling exam dialogs.
- Add logic to handle wrong question collections and create new exam records.
- Include `questionNum` in the API response for questions of a repository.
- Replace `thumbUrl` with `isWrongCollection` in the repositories API response.
- Reorganize imports and adjust button layout in the new exam dialog component.
- Filter repositories to hide items with `isWrongCollection` set to `1`.

我拿了一个比较复杂的代码提交,总结的比较到位。

More...

从零搭建基于 AI GitHub 分析平台 (7) Create Project API

设置 Authenticated Route

修改 src/server/api/trpc.ts:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const isAuthenticated = t.middleware(async ({ next, ctx }) => {
const user = await auth();
if(!user){
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You must be logged in to perform this action",
});
};

return next({
ctx : {
...ctx,
user
}
});
});

export const authenticatedProcedure = publicProcedure.use(isAuthenticated);
More...

请我喝杯咖啡吧~

支付宝
微信