Skip to content

Commit 74847ad

Browse files
committed
embedding of copilot
1 parent facedc3 commit 74847ad

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/routes/embeddings/route.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import consola from "consola"
2+
import { Hono } from "hono"
3+
import { FetchError } from "ofetch"
4+
5+
import { embedding } from "~/services/copilot/embedding/service"
6+
7+
export const embeddingRoutes = new Hono()
8+
9+
embeddingRoutes.post("/", async (c) => {
10+
try {
11+
const embeddings = await embedding()
12+
return c.json(embeddings)
13+
} catch (error) {
14+
if (error instanceof FetchError) {
15+
consola.error(`Request failed: ${error.message}`, error.response?._data)
16+
}
17+
throw error
18+
}
19+
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { GetModelsResponse } from "~/services/copilot/get-models/types.ts"
2+
3+
import { copilot } from "../../api-instance"
4+
5+
export const embedding = () =>
6+
copilot<GetModelsResponse>("/embeddings", {
7+
method: "POST",
8+
})

0 commit comments

Comments
 (0)