Skip to content

Commit

Permalink
refactor: improve the folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 5, 2023
1 parent 31d96cd commit 71eda66
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion utils/3rd/bilibili.ts → lib/bilibili.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sample } from "../fp";
import { sample } from "../utils/fp";

const run = async (bvId: string) => {
const requestUrl = `https://api.bilibili.com/x/web-interface/view?bvid=${bvId}`;
Expand Down
File renamed without changes.
10 changes: 3 additions & 7 deletions utils/OpenAIResult.ts → lib/openai/OpenAIResult.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {
createParser,
ParsedEvent,
ReconnectInterval,
} from "eventsource-parser";
import { checkOpenaiApiKey, checkOpenaiApiKeys } from "./3rd/openai";
import { sample } from "./fp";
import { createParser, ParsedEvent, ReconnectInterval } from "eventsource-parser";
import { checkOpenaiApiKeys } from "~/lib/openai/openai";
import { sample } from "../../utils/fp";

// TODO: maybe chat with video?
export type ChatGPTAgent = "user" | "system" | "assistant";
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion utils/3rd/upstash.ts → lib/upstash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
import { RATE_LIMIT_COUNT } from "../constants";
import { RATE_LIMIT_COUNT } from "~/utils/constants";

export const ratelimit = new Ratelimit({
redis: new Redis({
Expand Down
6 changes: 3 additions & 3 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Redis } from "@upstash/redis";
import type { NextFetchEvent, NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { validateLicenseKey } from "./utils/3rd/lemon";
import { checkOpenaiApiKeys } from "./utils/3rd/openai";
import { ratelimit } from "./utils/3rd/upstash";
import { validateLicenseKey } from "./lib/lemon";
import { checkOpenaiApiKeys } from "./lib/openai/openai";
import { ratelimit } from "./lib/upstash";
import { isDev } from "./utils/env";

const redis = Redis.fromEnv();
Expand Down
6 changes: 3 additions & 3 deletions pages/api/summarize.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Redis } from "@upstash/redis";
import type { NextFetchEvent, NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { fetchSubtitle } from "../../utils/3rd/bilibili";
import { fetchSubtitle } from "../../lib/bilibili";
import { isDev } from "../../utils/env";
import { OpenAIResult } from "../../utils/OpenAIResult";
import { getChunckedTranscripts, getSummaryPrompt } from "../../utils/prompt";
import { OpenAIResult } from "../../lib/openai/OpenAIResult";
import { getChunckedTranscripts, getSummaryPrompt } from "../../lib/openai/prompt";

export const config = {
runtime: "edge",
Expand Down

1 comment on commit 71eda66

@vercel
Copy link

@vercel vercel bot commented on 71eda66 Mar 5, 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.