Skip to content

Commit

Permalink
refactor: planetscale lib
Browse files Browse the repository at this point in the history
  • Loading branch information
yutakobayashidev committed Sep 29, 2023
1 parent 44afc92 commit 44637ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
8 changes: 1 addition & 7 deletions frontend/src/app/api/chat/functions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { connect } from "@planetscale/database";
import { conn } from "@src/lib/planetscale";
import { ChatCompletionCreateParams } from "openai/resources/chat";

const pscale_config = {
url: process.env.DATABASE_URL || "mysql://user:pass@host",
};

const conn = process.env.DATABASE_URL ? connect(pscale_config) : null;

export const functions: ChatCompletionCreateParams.Function[] = [
{
name: "get_member_info",
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/app/api/summarize/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connect } from "@planetscale/database";
import { conn } from "@src/lib/planetscale";
import { SpeechRecord } from "@src/types/api";
import { loadSummarizationChain } from "langchain/chains";
import { ChatOpenAI } from "langchain/chat_models/openai";
Expand Down Expand Up @@ -106,12 +106,6 @@ REFINED SUMMARY:`;
return stream.readable;
}

const pscale_config = {
url: process.env.DATABASE_URL || "mysql://user:pass@host",
};

const conn = process.env.DATABASE_URL ? connect(pscale_config) : null;

export async function POST(request: Request) {
if (!conn) return null;

Expand Down
7 changes: 7 additions & 0 deletions frontend/src/lib/planetscale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { connect } from "@planetscale/database";

export const pscale_config = {
url: process.env.DATABASE_URL || "mysql://user:pass@host",
};

export const conn = connect(pscale_config);

1 comment on commit 44637ca

@vercel
Copy link

@vercel vercel bot commented on 44637ca Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.