({
spinner,
pipe,
pipesDir,
account
}: {
spinner: Spinner;
pipe: string;
pipesDir: string;
account: Account;
})
| 179 | } |
| 180 | |
| 181 | async function deployPipe({ |
| 182 | spinner, |
| 183 | pipe, |
| 184 | pipesDir, |
| 185 | account |
| 186 | }: { |
| 187 | spinner: Spinner; |
| 188 | pipe: string; |
| 189 | pipesDir: string; |
| 190 | account: Account; |
| 191 | }): Promise<void> { |
| 192 | const filePath = path.join(pipesDir, pipe); |
| 193 | spinner.start(`Processing pipe: ${pipe}`); |
| 194 | try { |
| 195 | const pipeContent = await fs.readFile(filePath, 'utf-8'); |
| 196 | const pipeObject = JSON.parse(pipeContent) as Pipe; |
| 197 | |
| 198 | if (!pipeObject) { |
| 199 | handleInvalidConfig({ spinner, name: pipe, type: 'pipe' }); |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | spinner.stop(`Processed pipe: ${pipe}`); |
| 204 | spinner.start(`Deploying pipe: ${pipeObject.name}`); |
| 205 | |
| 206 | if (pipeObject.model.includes(OLLAMA)) { |
| 207 | spinner.stop( |
| 208 | `Local Ollama model found: ${pipeObject.model}. It can not be deployed.` |
| 209 | ); |
| 210 | spinner.start( |
| 211 | `Replacing Ollama model with OpenAI gpt-4o-mini model for deployment.` |
| 212 | ); |
| 213 | pipeObject.model = 'openai:gpt-4o-mini'; |
| 214 | } |
| 215 | |
| 216 | try { |
| 217 | // Wait for 500 ms to avoid rate limiting |
| 218 | await new Promise(resolve => setTimeout(resolve, 500)); |
| 219 | const newPipe = await upsertPipe({ |
| 220 | pipe: pipeObject, |
| 221 | account |
| 222 | }); |
| 223 | spinner.stop(`Successfully deployed pipe: ${newPipe.name}`); |
| 224 | } catch (error) { |
| 225 | handleDeploymentError({ |
| 226 | spinner, |
| 227 | name: pipeObject.name, |
| 228 | error, |
| 229 | type: 'pipe' |
| 230 | }); |
| 231 | } |
| 232 | } catch (error) { |
| 233 | handleFileProcessingError({ spinner, name: pipe, error }); |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | function getApiUrls(pipeName: string) { |
| 238 | return { |
no test coverage detected