Pepguy commited on
Commit
e07a0e5
·
verified ·
1 Parent(s): 9a89ea4

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +39 -3
app.js CHANGED
@@ -68,12 +68,15 @@ app.post('/api/generate', async (req, res) => {
68
  } else {
69
  // Handles Claude Sonnet, Claude Haiku, and Llama Maverick
70
  const bedrockModelId = getBedrockModelId(model);
71
- const command = new ConverseCommand({
 
72
  modelId: bedrockModelId,
73
  system: [{ text: system_prompt || CLAUDE_SYSTEM_PROMPT }],
74
  messages: [{ role: "user", content: [{ text: prompt }] }],
75
 
76
- inferenceConfig: model.includes("claude") ? { maxTokens: 48000, temperature: 1 }: {maxTokens: 3800, temperature: 1 } ,
 
 
77
 
78
  performanceConfig: model.includes("maverick") ? {latency: "standard"} : undefined,
79
 
@@ -82,7 +85,40 @@ app.post('/api/generate', async (req, res) => {
82
  output_config: { effort: "high" }
83
  } : undefined // Llama does not support Claude's specific thinking fields
84
  });
85
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  const response = await bedrockClient.send(command);
87
  const text = response.output.message.content.find(b => b.text)?.text;
88
  const tokenUsage = response.usage ? (response.usage.inputTokens + response.usage.outputTokens) : 0;
 
68
  } else {
69
  // Handles Claude Sonnet, Claude Haiku, and Llama Maverick
70
  const bedrockModelId = getBedrockModelId(model);
71
+
72
+ /* const command = new ConverseCommand({
73
  modelId: bedrockModelId,
74
  system: [{ text: system_prompt || CLAUDE_SYSTEM_PROMPT }],
75
  messages: [{ role: "user", content: [{ text: prompt }] }],
76
 
77
+ inferenceConfig: model.includes("claude") ? { maxTokens: 48000, temperature: 1 }:
78
+ (model.includes("haiku")? {maxTokens: 30000, temperature: 1 }
79
+ : {maxTokens: 3800, temperature: 1 }),
80
 
81
  performanceConfig: model.includes("maverick") ? {latency: "standard"} : undefined,
82
 
 
85
  output_config: { effort: "high" }
86
  } : undefined // Llama does not support Claude's specific thinking fields
87
  });
88
+
89
+ */
90
+
91
+ const command = new ConverseCommand({
92
+ modelId: bedrockModelId,
93
+ system: [{ text: system_prompt || CLAUDE_SYSTEM_PROMPT }],
94
+ messages: [{ role: "user", content: [{ text: prompt }] }],
95
+
96
+ // Ensure maxTokens is large enough for reasoning + response
97
+ inferenceConfig: {
98
+ maxTokens: model.includes("haiku") ? 32000 : 4000,
99
+ temperature: 1
100
+ },
101
+
102
+ performanceConfig: model.includes("maverick") ? { latency: "standard" } : undefined,
103
+
104
+ additionalModelRequestFields: (function() {
105
+ if (model.includes("haiku")) {
106
+ return {
107
+ reasoning_config: {
108
+ type: "enabled",
109
+ budget_tokens: 2048 // As seen in your screenshot
110
+ }
111
+ };
112
+ } else if (model.includes("claude")) {
113
+ return {
114
+ thinking: { type: "adaptive" },
115
+ output_config: { effort: "high" }
116
+ };
117
+ }
118
+ return undefined;
119
+ })()
120
+ });
121
+
122
  const response = await bedrockClient.send(command);
123
  const text = response.output.message.content.find(b => b.text)?.text;
124
  const tokenUsage = response.usage ? (response.usage.inputTokens + response.usage.outputTokens) : 0;