(
prompt: string,
params: ChatGPTParams = {},
model: string,
)
| 144 | |
| 145 | // TODO: Rewrite this function to allow other LLMs, not just OpenAI so we can use Phind normally |
| 146 | function 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 | |
| 172 | function isOSModel(model: string): boolean { |
| 173 | return Boolean( |
no outgoing calls
no test coverage detected