MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / chat

Function chat

src/ifcchat/api_openai.js:6–20  ·  view source on GitHub ↗
({ apiKey, baseURL, model, messages, tools })

Source from the content-addressed store, hash-verified

4}
5
6export async function chat({ apiKey, baseURL, model, messages, tools }) {
7 const res = await fetch(getChatCompletionsUrl(baseURL), {
8 method: "POST",
9 headers: {
10 "Content-Type": "application/json",
11 "Authorization": `Bearer ${apiKey}`,
12 },
13 body: JSON.stringify({ model, messages, tools }),
14 });
15 if (!res.ok) {
16 const text = await res.text();
17 throw new Error(`OpenAI error ${res.status}: ${text}`);
18 }
19 return await res.json();
20}

Callers 1

chatWithMinuteDelayFunction · 0.70

Calls 2

fetchFunction · 0.85
getChatCompletionsUrlFunction · 0.70

Tested by

no test coverage detected