Skip to content

Commit

Permalink
feat: Update Vercel AI SDK to v4 (#294)
Browse files Browse the repository at this point in the history
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: ben <ben@prologe.io>
  • Loading branch information
1 parent 0e0fa43 commit 4736a68
Show file tree
Hide file tree
Showing 10 changed files with 1,401 additions and 602 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Choose between the setups below:
cd packages/web && pnpm build:self-host && pnpm start
```

And make sure you have your `OPENAI_API_KEY` variable set up in your `.env.local` file inside the `packages/web` directory.
And make sure you have your `OPENAI_API_KEY` variable set up in your `.env.local` file inside the `packages/web` directory. If you want to use Amazon Bedrock models, you'll also need to configure AWS credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`).

For Windows (PowerShell):

Expand Down
4 changes: 4 additions & 0 deletions packages/audio-server/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
uploads/

# Build artifacts
.turbo
*.tsbuildinfo
6 changes: 5 additions & 1 deletion packages/plugin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ dist/
# Development output
main.js
styles.css
data.json
data.json

# Build artifacts
.turbo
*.tsbuildinfo
30 changes: 0 additions & 30 deletions packages/plugin/.turbo/turbo-test.log

This file was deleted.

6 changes: 3 additions & 3 deletions packages/plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"obsidian": "^1.7.2"
},
"dependencies": {
"@ai-sdk/openai": "^0.0.40",
"@ai-sdk/react": "^0.0.70",
"@ai-sdk/openai": "^1.0.6",
"@ai-sdk/react": "^1.0.6",
"@emotion/styled": "^11.13.0",
"@tiptap/core": "^2.5.7",
"@tiptap/extension-mention": "^2.5.8",
"@tiptap/pm": "^2.5.7",
"@tiptap/react": "^2.5.7",
"@tiptap/starter-kit": "^2.5.7",
"ai": "^3.4.32",
"ai": "^4.0.0",
"axios": "^1.6.2",
"chokidar": "^3.6.0",
"clsx": "^2.1.1",
Expand Down
73 changes: 61 additions & 12 deletions packages/web/lib/models.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,68 @@
import { anthropic } from "@ai-sdk/anthropic";
import { openai } from "@ai-sdk/openai";
import { google } from "@ai-sdk/google";
import { createAnthropic } from "@ai-sdk/anthropic";
import { createOpenAI } from "@ai-sdk/openai";
import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock";

const DEFAULT_MODEL = "gpt-4o";

const models = {
"gpt-4o": openai("gpt-4o"),
"gpt-4o-2024-08-06": openai("gpt-4o-2024-08-06"),
"gpt-4o-mini": openai("gpt-4o-mini"),
"claude-3-5-sonnet-20240620": anthropic("claude-3-5-sonnet-20240620"),
"claude-3-5-sonnet-20241022": anthropic("claude-3-5-sonnet-20241022"),
"claude-3-5-haiku-20241022": anthropic("claude-3-5-haiku-20241022"),
"gemini-2.0-flash-exp": google("gemini-2.0-flash-exp", {
useSearchGrounding: true,
}),
"gpt-4o": createOpenAI({
apiKey: process.env.OPENAI_API_KEY
})("gpt-4o"),
"gpt-4o-2024-08-06": createOpenAI({
apiKey: process.env.OPENAI_API_KEY
})("gpt-4o-2024-08-06"),
"gpt-4o-mini": createOpenAI({
apiKey: process.env.OPENAI_API_KEY
})("gpt-4o-mini"),
"claude-3-5-sonnet-20240620": createAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY
})("claude-3-5-sonnet-20240620"),
"claude-3-5-sonnet-20241022": createAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY
})("claude-3-5-sonnet-20241022"),
"claude-3-5-haiku-20241022": createAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY
})("claude-3-5-haiku-20241022"),
"gemini-2.0-flash-exp": createGoogleGenerativeAI({
apiKey: process.env.GOOGLE_API_KEY
})("gemini-2.0-flash-exp"),
// bedrock
...(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY ? {
// Llama Models
"llama-3-3-70b": createAmazonBedrock({
region: process.env.AWS_REGION || "us-west-2",
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
})("meta.llama3-3-70b-instruct-v1:0"),
"llama-3-2-90b": createAmazonBedrock({
region: process.env.AWS_REGION || "us-west-2",
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
})("meta.llama3-2-90b-instruct-v1:0"),
// Mistral Models
"mistral-large": createAmazonBedrock({
region: process.env.AWS_REGION || "us-west-2",
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
})("mistral.mistral-large-2407-v1:0"),
"mixtral-8x7b": createAmazonBedrock({
region: process.env.AWS_REGION || "us-west-2",
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
})("mistral.mixtral-8x7b-instruct-v0:1"),
// Anthropic Models
"anthropic.claude-3-5-sonnet-20240620-v1:0": createAmazonBedrock({
region: process.env.AWS_REGION || "us-west-2",
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
})("anthropic.claude-3-5-sonnet-20240620-v1:0"),
"anthropic.claude-3-5-haiku-20241022-v1:0": createAmazonBedrock({
region: process.env.AWS_REGION || "us-west-2",
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
})("anthropic.claude-3-5-haiku-20241022-v1:0"),
} : {}),
};

export const getModel = (name: string) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
async rewrites() {
return [
{
Expand Down
9 changes: 6 additions & 3 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"db:studio:prod": "pnpm dotenv -e .env.production.local -- drizzle-kit studio"
},
"dependencies": {
"@ai-sdk/anthropic": "^0.0.9",
"@ai-sdk/openai": "^0.0.68",
"@ai-sdk/amazon-bedrock": "^1.0.6",
"@ai-sdk/anthropic": "^1.0.6",
"@ai-sdk/openai": "^1.0.6",
"@browserbasehq/stagehand": "^1.5.0",
"@clerk/nextjs": "^5.7.5",
"@hookform/resolvers": "^3.9.1",
Expand All @@ -39,7 +40,7 @@
"@unkey/api": "^0.19.5",
"@vercel/postgres": "^0.8.0",
"@vercel/sdk": "^1.1.0",
"ai": "^3.4.33",
"ai": "^4.0.0",
"autoprefixer": "10.4.16",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand Down Expand Up @@ -82,6 +83,8 @@
"@types/jest": "^29.5.14",
"@types/supertest": "^2.0.16",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"supertest": "^6.3.4",
Expand Down
Loading

0 comments on commit 4736a68

Please sign in to comment.