Skip to content

Commit 78a1984

Browse files
authored
feat: update agent layer (#89)
* feat: init lib/agents * feat: init new agent flow with tooling * feat: save tools in db message, show source-list in ui for parts source * fix: tools formating, update nextjs canary * feat: update saveFinalAssistantMessage * feat: add new tools, research v2 * feat: update generateReport, summarizeSources * feat: add get-source, update public page * feat: remove old agents api * feat: various update
1 parent 44eba38 commit 78a1984

35 files changed

+1786
-1886
lines changed

app/agents/[agentSlug]/[chatId]/article.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getSources } from "@/app/components/chat/get-sources"
12
import { SourcesList } from "@/app/components/chat/sources-list"
23
import type { Tables } from "@/app/types/database.types"
34
import { Message, MessageContent } from "@/components/prompt-kit/message"
@@ -12,23 +13,20 @@ type MessageType = Tables<"messages">
1213

1314
type ArticleProps = {
1415
date: string
15-
category: string
1616
title: string
1717
subtitle: string
18-
cta: {
19-
text: string
20-
href: string
21-
}
2218
messages: MessageType[]
19+
agentSlug: string
20+
agentName: string
2321
}
2422

2523
export default function Article({
2624
date,
27-
category,
2825
title,
2926
subtitle,
30-
cta,
3127
messages,
28+
agentSlug,
29+
agentName,
3230
}: ArticleProps) {
3331
return (
3432
<>
@@ -47,7 +45,7 @@ export default function Article({
4745
</time>
4846
<span className="mx-2">·</span>
4947
<span className="text-muted-foreground hover:text-foreground transition-colors">
50-
<Link href={`/agents/${category}`}>{category}</Link>
48+
<Link href={`/agents/${agentSlug}`}>{agentName}</Link>
5149
</span>
5250
</div>
5351

@@ -73,9 +71,7 @@ export default function Article({
7371
<div className="mt-20 w-full">
7472
{messages.map((message) => {
7573
const parts = message?.parts as MessageAISDK["parts"]
76-
const sources = parts
77-
?.filter((part) => part?.type === "source")
78-
.map((part) => part?.source)
74+
const sources = getSources(parts)
7975

8076
return (
8177
<div key={message.id}>
@@ -96,10 +92,12 @@ export default function Article({
9692
"prose-h1:scroll-m-20 prose-h1:text-2xl prose-h1:font-semibold prose-h2:mt-8 prose-h2:scroll-m-20 prose-h2:text-xl prose-h2:mb-3 prose-h2:font-medium prose-h3:scroll-m-20 prose-h3:text-base prose-h3:font-medium prose-h4:scroll-m-20 prose-h5:scroll-m-20 prose-h6:scroll-m-20 prose-strong:font-medium prose-table:block prose-table:overflow-y-auto"
9793
)}
9894
>
99-
{message.content}
95+
{message.content!}
10096
</MessageContent>
10197
</Message>
102-
{sources && <SourcesList sources={sources} />}
98+
{sources && sources.length > 0 && (
99+
<SourcesList sources={sources} />
100+
)}
103101
</div>
104102
)
105103
})}

app/agents/[agentSlug]/[chatId]/page.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,10 @@ export default async function AgentChat({
8989
<Article
9090
messages={messagesData}
9191
date={chatData.created_at || ""}
92-
category={agentData.name}
92+
agentSlug={agentSlug}
93+
agentName={agentData.name}
9394
title={chatData.title || ""}
9495
subtitle={`A conversation with ${agentData.name}, an AI agent built in Zola`}
95-
cta={{
96-
text: "Read more",
97-
href: "/agents",
98-
}}
9996
/>
10097
)
10198
}

app/api/agents/core/agentRunner.ts

Lines changed: 0 additions & 102 deletions
This file was deleted.

app/api/agents/core/prompts.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)