Skip to content

Commit

Permalink
more clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
spolu committed Nov 13, 2023
1 parent d14989c commit 650770f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions front/lib/api/assistant/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,13 @@ export async function* runGeneration(
return;
}

const model = c.model;

const contextSize = getSupportedModelConfig(c.model).contextSize;

const MIN_GENERATION_TOKENS = 2048;

if (contextSize < MIN_GENERATION_TOKENS) {
throw new Error(
`Model contextSize unexpectedly small for model: ${model.providerId} ${model.modelId}`
`Model contextSize unexpectedly small for model: ${c.model.providerId} ${c.model.modelId}`
);
}

Expand All @@ -345,7 +343,7 @@ export async function* runGeneration(
// Turn the conversation into a digest that can be presented to the model.
const modelConversationRes = await renderConversationForModel({
conversation,
model,
model: c.model,
prompt,
allowedTokenCount: contextSize - MIN_GENERATION_TOKENS,
});
Expand All @@ -358,7 +356,7 @@ export async function* runGeneration(
messageId: agentMessage.sId,
error: {
code: "internal_server_error",
message: `Failed tokenization for ${model.providerId} ${model.modelId}: ${modelConversationRes.error.message}`,
message: `Failed tokenization for ${c.model.providerId} ${c.model.modelId}: ${modelConversationRes.error.message}`,
},
};
return;
Expand All @@ -367,8 +365,8 @@ export async function* runGeneration(
const config = cloneBaseConfig(
DustProdActionRegistry["assistant-v2-generator"].config
);
config.MODEL.provider_id = model.providerId;
config.MODEL.model_id = model.modelId;
config.MODEL.provider_id = c.model.providerId;
config.MODEL.model_id = c.model.modelId;
config.MODEL.temperature = c.temperature;

// This is the console.log you want to uncomment to generate inputs for the generator app.
Expand All @@ -383,7 +381,7 @@ export async function* runGeneration(
{
workspaceId: conversation.owner.sId,
conversationId: conversation.sId,
model: model,
model: c.model,
temperature: c.temperature,
},
"[ASSISTANT_TRACE] Generation exection"
Expand Down

0 comments on commit 650770f

Please sign in to comment.