Skip to content

Commit fe7803e

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

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/routes/embeddings/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import consola from "consola"
22
import { Hono } from "hono"
33
import { FetchError } from "ofetch"
44

5+
import type { ChatCompletionsPayload } from "~/services/copilot/chat-completions/types.ts"
6+
57
import { embedding } from "~/services/copilot/embedding/service"
68

79
export const embeddingRoutes = new Hono()
810

911
embeddingRoutes.post("/", async (c) => {
1012
try {
11-
const embeddings = await embedding()
13+
const embeddings = await embedding(
14+
await c.req.json<ChatCompletionsPayload>(),
15+
)
1216
return c.json(embeddings)
1317
} catch (error) {
1418
if (error instanceof FetchError) {
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import type { ChatCompletionsPayload } from "~/services/copilot/chat-completions/types.ts"
12
import type { GetModelsResponse } from "~/services/copilot/get-models/types.ts"
23

34
import { copilot } from "../../api-instance"
45

5-
export const embedding = () =>
6+
export const embedding = (payload: ChatCompletionsPayload) =>
67
copilot<GetModelsResponse>("/embeddings", {
78
method: "POST",
9+
body: {
10+
...payload,
11+
},
812
})

0 commit comments

Comments
 (0)