MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / getOAIRequestCompletion

Function getOAIRequestCompletion

lib/queryLLM.ts:146–170  ·  view source on GitHub ↗
(
  prompt: string,
  params: ChatGPTParams = {},
  model: string,
)

Source from the content-addressed store, hash-verified

144
145// TODO: Rewrite this function to allow other LLMs, not just OpenAI so we can use Phind normally
146function getOAIRequestCompletion(
147 prompt: string,
148 params: ChatGPTParams = {},
149 model: string,
150): {
151 url: string;
152 options: { method: string; headers: HeadersInit; body: string };
153} {
154 const options = {
155 method: "POST",
156 headers: {
157 "Content-Type": "application/json",
158 Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
159 },
160 // Use our default params, rather than OpenAI's when these aren't specified
161 body: JSON.stringify({
162 model,
163 prompt,
164 ...defaultParams,
165 ...params,
166 }),
167 };
168
169 return { url: `https://api.openai.com/v1/completions`, options };
170}
171
172function isOSModel(model: string): boolean {
173 return Boolean(

Callers 2

getLLMResponseFunction · 0.85
streamLLMResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected