Skip to content

Commit

Permalink
update hack with getting the right docs url
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohin Bhargava authored and RohinBhargava committed Jul 29, 2024
1 parent ee41049 commit 58fbe83
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/ui/docs-bundle/src/pages/api/fern-docs/search/cohere.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import algolia from "algoliasearch";
import { Cohere, CohereClient } from "cohere-ai";
import { NextRequest } from "next/server";
import { v4 } from "uuid";
import { FernRegistryClient } from "../../../../../../../fdr-sdk/src/client/generated";
import { getXFernHostEdge } from "../../../../utils/xFernHost";

export const runtime = "edge";

const cohere = new CohereClient({
token: process.env.COHERE_API_KEY,
});

if (!process.env.ALGOLIA_APP_ID || !process.env.ALGOLIA_ADMIN_API_KEY || !process.env.ALGOLIA_SEARCH_INDEX) {
if (!process.env.ALGOLIA_APP_ID || !process.env.ALGOLIA_API_KEY) {
throw new Error("Missing Algolia environment variables");
}

if (!process.env.DOCS_URL) {
throw new Error("Missing DOCS_URL environment variable");
}

const docsUrl = process.env.DOCS_URL;

const algoliaClient = algolia(process.env.ALGOLIA_APP_ID, process.env.ALGOLIA_ADMIN_API_KEY); // this can probably be hardcoded in cohere for app hack
const algoliaClient = algolia(process.env.ALGOLIA_APP_ID, process.env.ALGOLIA_API_KEY); // this can probably be hardcoded in cohere for app hack

const PREAMBLE = `
You are an expert AI assistant called Fernie that helps developers answer questions about Cohere's APIs and SDKs.
Expand All @@ -41,6 +38,8 @@ export default async function handler(req: Request): Promise<Response> {
return new Response(null, { status: 405 });
}

const docsUrl = getXFernHostEdge(req as NextRequest);

const body = await req.json();

let conversationId = body.conversationId;
Expand Down

0 comments on commit 58fbe83

Please sign in to comment.