Skip to content

Commit

Permalink
Swapping to @ai-sdk/amazon-bedrock from directly querying Anthropic (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dubwub authored Jan 8, 2025
1 parent a1fa3d9 commit a76b4f2
Show file tree
Hide file tree
Showing 3 changed files with 977 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/fern-docs/bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"test": "vitest --run --passWithNoTests --globals"
},
"dependencies": {
"@ai-sdk/amazon-bedrock": "^1.0.7",
"@ai-sdk/anthropic": "^1.0.5",
"@ai-sdk/openai": "^1.0.8",
"@algolia/client-search": "^5.15.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { track } from "@/server/analytics/posthog";
import { safeVerifyFernJWTConfig } from "@/server/auth/FernJWT";
import { getOrgMetadataForDomain } from "@/server/auth/metadata-for-url";
import {
anthropicApiKey,
openaiApiKey,
turbopufferApiKey,
} from "@/server/env-variables";
import { openaiApiKey, turbopufferApiKey } from "@/server/env-variables";
import { getDocsDomainEdge } from "@/server/xfernhost/edge";
import { createAnthropic } from "@ai-sdk/anthropic";
import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock";
import { createOpenAI } from "@ai-sdk/openai";
import { getAuthEdgeConfig, getFeatureFlags } from "@fern-docs/edge-config";
import { createDefaultSystemPrompt } from "@fern-docs/search-server";
Expand All @@ -22,8 +18,12 @@ import { NextRequest, NextResponse } from "next/server";
import { z } from "zod";

export async function POST(req: NextRequest) {
const anthropic = createAnthropic({ apiKey: anthropicApiKey() });
const languageModel = anthropic.languageModel("claude-3-5-sonnet-latest");
const bedrock = createAmazonBedrock({
region: "us-east-1",
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});
const languageModel = bedrock("us.anthropic.claude-3-5-sonnet-20241022-v2:0");

const openai = createOpenAI({ apiKey: openaiApiKey() });
const embeddingModel = openai.embedding("text-embedding-3-small");
Expand Down
Loading

0 comments on commit a76b4f2

Please sign in to comment.