Andrew commited on
Commit
f407536
·
1 Parent(s): c4408b8

(feat) Forward auth token through reasoning flows

Browse files
src/lib/server/textGeneration/generate.ts CHANGED
@@ -23,6 +23,7 @@ export async function* generate(
23
  isContinue,
24
  promptedAt,
25
  forceMultimodal,
 
26
  }: GenerateContext,
27
  preprompt?: string
28
  ): AsyncIterable<MessageUpdate> {
@@ -100,9 +101,9 @@ export async function* generate(
100
  messages: [
101
  {
102
  from: "user",
103
- content: `Question: ${
104
- messages[messages.length - 1].content
105
- }\n\nReasoning: ${reasoningBuffer}`,
106
  },
107
  ],
108
  preprompt: `Your task is to summarize concisely all your reasoning steps and then give the final answer. Keep it short, one short paragraph at most. If the reasoning steps explicitly include a code solution, make sure to include it in your answer.
@@ -114,6 +115,7 @@ Do not use prefixes such as Response: or Answer: when answering to the user.`,
114
  max_tokens: 1024,
115
  },
116
  modelId: model.id,
 
117
  });
118
  finalAnswer = summary;
119
  yield {
@@ -224,9 +226,11 @@ Do not use prefixes such as Response: or Answer: when answering to the user.`,
224
  ) {
225
  lastReasoningUpdate = new Date();
226
  try {
227
- generateSummaryOfReasoning(reasoningBuffer, model.id).then((summary) => {
228
- status = summary;
229
- });
 
 
230
  } catch (e) {
231
  logger.error(e);
232
  }
 
23
  isContinue,
24
  promptedAt,
25
  forceMultimodal,
26
+ authToken,
27
  }: GenerateContext,
28
  preprompt?: string
29
  ): AsyncIterable<MessageUpdate> {
 
101
  messages: [
102
  {
103
  from: "user",
104
+ content: `Question: ${messages[messages.length - 1].content}
105
+
106
+ Reasoning: ${reasoningBuffer}`,
107
  },
108
  ],
109
  preprompt: `Your task is to summarize concisely all your reasoning steps and then give the final answer. Keep it short, one short paragraph at most. If the reasoning steps explicitly include a code solution, make sure to include it in your answer.
 
115
  max_tokens: 1024,
116
  },
117
  modelId: model.id,
118
+ apiKey: authToken,
119
  });
120
  finalAnswer = summary;
121
  yield {
 
226
  ) {
227
  lastReasoningUpdate = new Date();
228
  try {
229
+ generateSummaryOfReasoning(reasoningBuffer, model.id, { apiKey: authToken }).then(
230
+ (summary) => {
231
+ status = summary;
232
+ }
233
+ );
234
  } catch (e) {
235
  logger.error(e);
236
  }