(prompt: string)
| 799 | } |
| 800 | |
| 801 | async completePrompt(prompt: string): Promise<string> { |
| 802 | try { |
| 803 | const modelConfig = this.getModel() |
| 804 | |
| 805 | // For completePrompt, thinking is typically not used, but we should still check |
| 806 | // if thinking was somehow enabled in the model config |
| 807 | const thinkingEnabled = |
| 808 | shouldUseReasoningBudget({ model: modelConfig.info, settings: this.options }) && |
| 809 | modelConfig.reasoning && |
| 810 | modelConfig.reasoningBudget |
| 811 | |
| 812 | const inferenceConfig: BedrockInferenceConfig = { |
| 813 | maxTokens: modelConfig.maxTokens || (modelConfig.info.maxTokens as number), |
| 814 | // Claude 4.7+ (including 4.8) removed sampling parameters entirely — |
| 815 | // sending temperature causes a 400 error. Guard the non-stream path the |
| 816 | // same way createMessage does so completePrompt also works for these models. |
| 817 | ...(this.isAdaptiveThinkingModel(modelConfig.id) |
| 818 | ? {} |
| 819 | : { temperature: modelConfig.temperature ?? (this.options.modelTemperature as number) }), |
| 820 | } |
| 821 | |
| 822 | // For completePrompt, use a unique conversation ID based on the prompt |
| 823 | const conversationId = `prompt_${prompt.substring(0, 20)}` |
| 824 | |
| 825 | const payload = { |
| 826 | modelId: modelConfig.id, |
| 827 | messages: this.convertToBedrockConverseMessages( |
| 828 | [ |
| 829 | { |
| 830 | role: "user", |
| 831 | content: prompt, |
| 832 | }, |
| 833 | ], |
| 834 | undefined, |
| 835 | false, |
| 836 | modelConfig.info, |
| 837 | conversationId, |
| 838 | ).messages, |
| 839 | inferenceConfig, |
| 840 | } |
| 841 | |
| 842 | const command = new ConverseCommand(payload) |
| 843 | const response = await this.client.send(command) |
| 844 | |
| 845 | if ( |
| 846 | response?.output?.message?.content && |
| 847 | response.output.message.content.length > 0 && |
| 848 | response.output.message.content[0].text && |
| 849 | response.output.message.content[0].text.trim().length > 0 |
| 850 | ) { |
| 851 | try { |
| 852 | return response.output.message.content[0].text |
| 853 | } catch (parseError) { |
| 854 | logger.error("Failed to parse Bedrock response", { |
| 855 | ctx: "bedrock", |
| 856 | error: parseError instanceof Error ? parseError : String(parseError), |
| 857 | }) |
| 858 | } |
nothing calls this directly
no test coverage detected