File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed
services/copilot/embedding Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,15 @@ import consola from "consola"
22import { Hono } from "hono"
33import { FetchError } from "ofetch"
44
5- import type { ChatCompletionsPayload } from "~/services/copilot/chat-completions /types.ts "
5+ import type { EmbeddingRequest } from "~/services/copilot/embedding /types"
66
77import { embedding } from "~/services/copilot/embedding/service"
88
99export const embeddingRoutes = new Hono ( )
1010
1111embeddingRoutes . post ( "/" , async ( c ) => {
1212 try {
13- const embeddings = await embedding (
14- await c . req . json < ChatCompletionsPayload > ( ) ,
15- )
13+ const embeddings = await embedding ( await c . req . json < EmbeddingRequest > ( ) )
1614 return c . json ( embeddings )
1715 } catch ( error ) {
1816 if ( error instanceof FetchError ) {
Original file line number Diff line number Diff line change 1- import type { ChatCompletionsPayload } from "~/services/copilot/chat-completions/types.ts"
2- import type { GetModelsResponse } from "~/services/copilot/get-models/types.ts"
1+ import type { EmbeddingRequest , EmbeddingResponse } from "./types"
32
43import { copilot } from "../../api-instance"
54
6- export const embedding = ( payload : ChatCompletionsPayload ) =>
7- copilot < GetModelsResponse > ( "/embeddings" , {
5+ export const embedding = ( payload : EmbeddingRequest ) =>
6+ copilot < EmbeddingResponse > ( "/embeddings" , {
87 method : "POST" ,
98 body : {
109 ...payload ,
Original file line number Diff line number Diff line change 1+ export interface EmbeddingRequest {
2+ input : string | Array < string >
3+ model : string
4+ }
5+
6+ export interface Embedding {
7+ object : string
8+ embedding : Array < number >
9+ index : number
10+ }
11+
12+ export interface EmbeddingResponse {
13+ object : string
14+ data : Array < Embedding >
15+ model : string
16+ usage : {
17+ prompt_tokens : number
18+ total_tokens : number
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments