new ShapeDescriptor( 'Maximum output words', 'The maximum number of words/tokens that can be generated in the completion.', EShapeType::Number ), 'model' => new ShapeDescriptor( 'Model', 'The model used to generate the completion', EShapeType::Enum ), ]; } public function getOptionalInputShapeEnumValues(): array { return [ 'model' => [ new ShapeEnumValue('Model 1', 'model_1'), new ShapeEnumValue('Model 2', 'model_2'), new ShapeEnumValue('Model 3', 'model_3'), ], ]; } public function getOptionalInputShapeDefaults(): array { return [ 'max_tokens' => 1234, 'model' => 'model_2', ]; } public function getOptionalOutputShape(): array { return []; } public function getOutputShapeEnumValues(): array { return []; } public function getOptionalOutputShapeEnumValues(): array { return []; } public function process(?string $userId, array $input, callable $reportProgress): array { if ($this->appConfig->getAppValueBool('fail-' . $this->getId())) { throw new ProcessingException('Failing as set by AppConfig'); } if (isset($input['model']) && is_string($input['model'])) { $model = $input['model']; } else { $model = 'unknown model'; } if (!isset($input['input']) || !is_string($input['input'])) { throw new RuntimeException('Invalid prompt'); } $prompt = $input['input']; $maxTokens = null; if (isset($input['max_tokens']) && is_int($input['max_tokens'])) { $maxTokens = $input['max_tokens']; } return [ 'output' => 'This is a fake summary: ',// . "\n\n- Prompt: " . $prompt . "\n- Model: " . $model . "\n- Maximum number of words: " . $maxTokens, ]; } }