This commit is contained in:
Ariel Weinberger
2025-07-17 00:13:48 -05:00
parent 8918bcb4c4
commit 65d5bf9c28
3 changed files with 27 additions and 47 deletions
-1
View File
@@ -10,7 +10,6 @@ ENV PATH="$PNPM_HOME:$PATH"
RUN npm i -g corepack@latest
RUN corepack enable
RUN corepack prepare pnpm@10.0.0 --activate
RUN pnpm install -g bun
ADD ./package.json /app/package.json
ADD ./pnpm-lock.yaml /app/pnpm-lock.yaml
+1 -4
View File
@@ -50,8 +50,7 @@ export const handleChatRequest = async (c: Context) => {
projectId,
token // TODO: use the token from the request
});
const convos = await imagineClient.listConversations(artifactId);
const imagineConvo = convos.conversations[0];
const imagineConvo = await imagineClient.getConversation(artifactId, conversationId);
const convertedMessages = convertToModelMessages(messages);
const latestMessage = convertedMessages[convertedMessages.length - 1];
@@ -75,8 +74,6 @@ export const handleChatRequest = async (c: Context) => {
await exec(`pnpx degit appwrite/templates-for-frameworks/base-vite-template .`, {
cwd: workspaceDir
});
console.log('Installing dependencies...');
await exec(`bun install`, { cwd: workspaceDir });
}
} else {
console.log('Not a new conversation, skipping workspace clone');
@@ -80,11 +80,6 @@ const planStep = createStep({
const id = createIdGenerator({ size: 10 })();
// writer.write({
// type: "reasoning-start",
// id,
// });
const thinkingId = createIdGenerator({ size: 10 })();
writer.write({
@@ -99,11 +94,10 @@ const planStep = createStep({
const startTime = Date.now();
const stream = await architectAgent.stream(
[
cacheSystemMessage({
role: "system",
content: `
const messages = [
cacheSystemMessage({
role: "system",
content: `
Here is the current file layout and dependencies in the project:
${currentCodeContext.content}
@@ -133,26 +127,30 @@ Examples of when a UI developer IS NOT needed:
- Adding an endpoint
- Pure logic changes
- Moving files around, renaming files, etc.
`,
}),
...restMessages.map((m: any) => ({
role: m.role,
content: m.content,
})),
{
role: "user",
content: `
`,
}),
...restMessages.map((m: any) => ({
role: m.role,
content: m.content,
})),
{
role: "user",
content: `
Here is the product manager's request:
<request>
${userPrompt}
</request>
`,
},
],
`,
},
];
console.log("messages", messages);
const stream = await architectAgent.stream(
messages,
{
runtimeContext,
maxSteps: 20,
maxOutputTokens: 1000,
experimental_output: outputSchema,
toolChoice: "none",
@@ -172,12 +170,6 @@ ${userPrompt}
const delta = partialObject.plan.slice(previousPlan.length);
previousPlan = partialObject.plan;
// writer.write({
// type: "reasoning-delta",
// id,
// delta,
// });
writer.write({
type: "data-thinking",
id: thinkingId,
@@ -189,6 +181,8 @@ ${userPrompt}
});
}
console.log("resp", await stream.response)
console.log("[planStep] postStream", latestPartialObject);
if (!latestPartialObject) {
@@ -207,16 +201,6 @@ ${userPrompt}
}
});
// writer.write({
// type: "reasoning-end",
// id,
// providerMetadata: {
// imagine: {
// durationInMs: timeTaken,
// }
// } as any,
// });
const { plan, shouldInvolveUIDeveloper } = latestPartialObject;
return {
plan,
@@ -334,8 +318,8 @@ const implementStep = createStep({
console.log(`Generating commit message`);
const { object } = await generateObject({
model: openai("gpt-4.1-mini"),
// model: anthropic("claude-3-7-sonnet-20250219"),
// model: openai("gpt-4.1-mini"),
model: anthropic("claude-3-7-sonnet-20250219"),
schema: z.object({
commitMessage: z.string(),
}),
@@ -472,7 +456,7 @@ Example of invalid requests:
writer.write({
type: "text-end",
id,
});
});
const toolsUsed = await stream.toolCalls;
const hasUsedProceedTool = toolsUsed.some(