Skip to content

Commit 80570db

Browse files
committed
refactor: Use config and tokens for Copilot API requests
1 parent cd17f19 commit 80570db

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
import { stream } from "fetch-event-stream"
2+
13
import type { ChatCompletionsPayload } from "./types"
2-
import type { ChatCompletionsChunk } from "./types-streaming"
34

4-
import { copilot } from "../../api-instance"
5+
import { COPILOT_CONFIG } from "../../../config/api"
6+
import { TOKENS } from "../../../config/tokens"
57

6-
export const chatCompletionsStream = (payload: ChatCompletionsPayload) =>
7-
copilot<ChatCompletionsChunk>("/chat/completions", {
8+
export const chatCompletionsStream = async (payload: ChatCompletionsPayload) =>
9+
stream(`${COPILOT_CONFIG.baseURL}/chat/completions`, {
810
method: "POST",
9-
body: payload,
11+
headers: {
12+
...COPILOT_CONFIG.headers,
13+
authorization: `Bearer ${TOKENS.COPILOT_TOKEN}`,
14+
},
15+
body: JSON.stringify(payload),
1016
})

0 commit comments

Comments
 (0)