Pepguy commited on
Commit
bc7946a
·
verified ·
1 Parent(s): 718dd82

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +4 -22
app.js CHANGED
@@ -110,14 +110,14 @@ app.post('/api/generate', async (req, res) => {
110
  additionalModelRequestFields: (function() {
111
  if (model.includes("haiku")) {
112
  return {
113
- reasoning_config: {
114
  type: "enabled",
115
  budget_tokens: 2048
116
- }
117
  };
118
  } else if (model.includes("claude")) {
119
  return {
120
- thinking: { type: "adaptive" },
121
  output_config: { effort: "high" }
122
  };
123
  }
@@ -127,25 +127,7 @@ app.post('/api/generate', async (req, res) => {
127
 
128
  const response = await bedrockClient.send(command);
129
 
130
- // ONLY CHANGE THIS everything else in /api/generate stays identical
131
-
132
- // BEFORE — stops at first block, returns undefined if thinking block comes first
133
- let text = response.output.message.content.find(b => b.text)?.text;
134
-
135
- // AFTER — scans all blocks, concatenates every text block found, ignores reasoning blocks
136
- const contentBlocks = response.output?.message?.content || [];
137
- text = contentBlocks
138
- .filter(b => b.text)
139
- .map(b => b.text)
140
- .join("") || null;
141
-
142
- if (!text) {
143
- console.error(`[${model.toUpperCase()}] No text block returned. Block types:`,
144
- JSON.stringify(contentBlocks.map(b => Object.keys(b))));
145
- return res.status(500).json({ success: false, error: "Model returned no text content" });
146
- }
147
-
148
- // const text = response.output.message.content.find(b => b.text)?.text;
149
  const tokenUsage = response.usage ? (response.usage.inputTokens + response.usage.outputTokens) : 0;
150
 
151
  res.json({ success: true, data: text, usage: { totalTokenCount: tokenUsage } });
 
110
  additionalModelRequestFields: (function() {
111
  if (model.includes("haiku")) {
112
  return {
113
+ /* reasoning_config: {
114
  type: "enabled",
115
  budget_tokens: 2048
116
+ } */
117
  };
118
  } else if (model.includes("claude")) {
119
  return {
120
+ // thinking: { type: "adaptive" },
121
  output_config: { effort: "high" }
122
  };
123
  }
 
127
 
128
  const response = await bedrockClient.send(command);
129
 
130
+ const text = response.output.message.content.find(b => b.text)?.text;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  const tokenUsage = response.usage ? (response.usage.inputTokens + response.usage.outputTokens) : 0;
132
 
133
  res.json({ success: true, data: text, usage: { totalTokenCount: tokenUsage } });