Skip to content

Commit

Permalink
Merge pull request #375 from miurla/use-ai-sdk-4
Browse files Browse the repository at this point in the history
Update AI SDK dependencies
  • Loading branch information
miurla authored Nov 25, 2024
2 parents 0a0498e + 046b414 commit f55da43
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
Binary file modified bun.lockb
Binary file not shown.
23 changes: 12 additions & 11 deletions lib/agents/inquire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export async function inquire(
uiStream.update(<Copilot inquiry={objectStream.value} />)

let finalInquiry: PartialInquiry = {}
await streamObject({

const result = await streamObject({
model: getModel(model),
system: `As a professional web researcher, your role is to deepen your understanding of the user's input by conducting further inquiries when necessary.
After receiving an initial response from the user, carefully assess whether additional questions are absolutely essential to provide a comprehensive and accurate answer. Only proceed with further inquiries if the available information is insufficient or ambiguous.
Expand Down Expand Up @@ -55,17 +56,17 @@ export async function inquire(
messages,
schema: inquirySchema
})
.then(async result => {
for await (const obj of result.partialObjectStream) {
if (obj) {
objectStream.update(obj)
finalInquiry = obj
}

try {
for await (const obj of result.partialObjectStream) {
if (obj) {
objectStream.update(obj)
finalInquiry = obj
}
})
.finally(() => {
objectStream.done()
})
}
} finally {
objectStream.done()
}

return finalInquiry
}
20 changes: 8 additions & 12 deletions lib/agents/query-suggestor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function querySuggestor(
}) as CoreMessage[]

let finalRelatedQueries: PartialRelated = {}
await streamObject({
const result = await streamObject({
model: getModel(model),
system: `As a professional web researcher, your task is to generate a set of three queries that explore the subject matter more deeply, building upon the initial query and the information uncovered in its search results.
Expand All @@ -31,17 +31,13 @@ export async function querySuggestor(
messages: lastMessages,
schema: relatedSchema
})
.then(async result => {
for await (const obj of result.partialObjectStream) {
if (obj.items) {
objectStream.update(obj)
finalRelatedQueries = obj
}
}
})
.finally(() => {
objectStream.done()
})

for await (const obj of result.partialObjectStream) {
if (obj.items) {
objectStream.update(obj)
finalRelatedQueries = obj
}
}

return finalRelatedQueries
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"lint": "next lint"
},
"dependencies": {
"@ai-sdk/anthropic": "^0.0.51",
"@ai-sdk/azure": "^0.0.41",
"@ai-sdk/google": "^0.0.51",
"@ai-sdk/openai": "^0.0.63",
"@ai-sdk/anthropic": "^1.0.2",
"@ai-sdk/azure": "^1.0.5",
"@ai-sdk/google": "^1.0.3",
"@ai-sdk/openai": "^1.0.4",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
Expand All @@ -29,7 +29,7 @@
"@radix-ui/react-tooltip": "^1.0.7",
"@tailwindcss/typography": "^0.5.12",
"@upstash/redis": "^1.34.0",
"ai": "^3.4.7",
"ai": "^4.0.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"embla-carousel-react": "^8.0.0",
Expand All @@ -40,7 +40,7 @@
"next": "^14.2.3",
"next-themes": "^0.3.0",
"node-html-parser": "^6.1.13",
"ollama-ai-provider": "^0.15.1",
"ollama-ai-provider": "^1.0.0",
"react-dom": "^18",
"react-icons": "^5.0.1",
"react-markdown": "^8.0.7",
Expand Down

0 comments on commit f55da43

Please sign in to comment.