Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: remove old code

Marc Seitz8fb8d13f2c0a
diff --git a/ee/features/ai/components/chat-message.tsx b/ee/features/ai/components/chat-message.tsx
index f3e0f717..b9adab04 100644
--- a/ee/features/ai/components/chat-message.tsx
+++ b/ee/features/ai/components/chat-message.tsx
@@ -18,8 +18,6 @@ import {
} from "@/components/ai-elements/message";
import { Shimmer } from "@/components/ai-elements/shimmer";
-import type { FileCitation } from "../lib/stream/parse-ui-message-stream";
-
// ============================================================================
// Types
// ============================================================================
@@ -27,7 +25,6 @@ import type { FileCitation } from "../lib/stream/parse-ui-message-stream";
export interface ChatMessageProps {
role: "user" | "assistant";
content: string;
- citations?: FileCitation[];
isStreaming?: boolean;
className?: string;
messageId?: string;
diff --git a/lib/utils.ts b/lib/utils.ts
index 236a2986..7bc27768 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -2,14 +2,12 @@ import { NextRouter } from "next/router";
import slugify from "@sindresorhus/slugify";
import { upload } from "@vercel/blob/client";
-import { Message } from "ai";
import bcrypt from "bcryptjs";
import * as chrono from "chrono-node";
import { type ClassValue, clsx } from "clsx";
import crypto from "crypto";
import ms from "ms";
import { customAlphabet } from "nanoid";
-import { ThreadMessage } from "openai/resources/beta/threads/messages/messages";
import { rgb } from "pdf-lib";
import { ParsedUrlQuery } from "querystring";
import { toast } from "sonner";
@@ -343,53 +341,6 @@ export const calculateDaysLeft = (accountCreationDate: Date): number => {
return daysLeft(accountCreationDate, maxDays);
};
-// helper function to convert ThreadMessages (an OpenAI type for messages) to Messages (an vercel/ai type for messages)
-export const convertThreadMessagesToMessages = (
- threadMessages: ThreadMessage[],
-): Message[] => {
- // Filter out messages with metaData.intitialMessage == 'True'
- const filteredMessages = threadMessages.filter((threadMessage) => {
- if (
- typeof threadMessage.metadata === "object" &&
- threadMessage.metadata !== null
- ) {
- // Safely typecast metadata to an object with the expected structure
- const metadata = threadMessage.metadata as { intitialMessage?: string };
- return metadata.intitialMessage !== "True";
- }
- return true; // Include messages where metadata is not an object or is null
- });
-
- return filteredMessages.map((threadMessage) => {
- const {
- id,
- created_at,
- content,
- role,
- // other fields you might need from ThreadMessage
- } = threadMessage;
-
- // Assuming content is an array and you want to convert it into a string or JSX element
- const messageContent = content.map((item) => {
- if (item.type === "text") {
- return item.text.value;
- } else {
- return "";
- }
- });
-
- return {
- id,
- createdAt: new Date(created_at * 1000), // converting Unix timestamp to Date object
- content: messageContent[0],
- role: role === "assistant" ? "assistant" : "user", // Adjust according to your needs
- // Set other properties as required by Message interface
- ui: null, // example, set based on your UI requirements
- // name, function_call, and other fields as needed
- };
- });
-};
-
export function constructMetadata({
title = "Papermark | The Open Source DocSend Alternative",
description = "Papermark is an open-source document sharing alternative to DocSend with built-in engagement analytics and 100% white-labeling.",