Merge branch 'main' into kush/be-queue-fixes

This commit is contained in:
Kush Thaker 2024-08-09 18:50:05 +05:30 committed by GitHub
commit ed5ed419e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 56 additions and 60 deletions

View file

@ -76,7 +76,8 @@ To use the chrome extension,
#### Architecture:
![overview](https://i.dhr.wtf/r/Clipboard_Apr_14,_2024_at_4.52PM.png)
<img width="715" alt="image" src="https://github.com/user-attachments/assets/f2e38b28-8cfe-4331-9b84-a91902682ddd">
Supermemory has three main modules, managed by [turborepo](https://turbo.build):
@ -123,6 +124,7 @@ Built with:
- [Cloudflare Queues](https://developers.cloudflare.com/queues/)
- [Cloudflare Browser Rendering](https://developers.cloudflare.com/browser-rendering/)
- [Cloudflare KV](https://developers.cloudflare.com/kv)
- [mem0](https://app.mem0.ai)
## Star History

View file

@ -9,7 +9,7 @@ import { z } from "zod";
import { seededRandom } from "./utils/seededRandom";
import { bulkInsertKv } from "./utils/kvBulkInsert";
export async function initQuery(env: Env, model: string = "gpt-4o") {
export async function initQuery(env: Env, model: string = "gemini-1.5-pro") {
const embeddings = new OpenAIEmbeddings({
apiKey: env.OPENAI_API_KEY,
modelName: "text-embedding-3-small",
@ -35,12 +35,13 @@ export async function initQuery(env: Env, model: string = "gpt-4o") {
console.log("Selected model: ", selectedModel);
break;
case "gemini-1.5-pro":
console.log("YES GOOGLE");
const googleai = createGoogleGenerativeAI({
apiKey: env.GOOGLE_AI_API_KEY,
baseURL:
"https://gateway.ai.cloudflare.com/v1/47c2b4d598af9d423c06fc9f936226d5/supermemory/google-vertex-ai",
});
selectedModel = googleai.chat("models/gemini-1.5-pro-latest");
selectedModel = googleai.chat("models/gemini-pro");
console.log("Selected model: ", selectedModel);
break;
case "gpt-4o":
@ -49,7 +50,6 @@ export async function initQuery(env: Env, model: string = "gpt-4o") {
apiKey: env.OPENAI_API_KEY,
baseURL:
"https://gateway.ai.cloudflare.com/v1/47c2b4d598af9d423c06fc9f936226d5/supermemory/openai",
compatibility: "strict",
});
selectedModel = openai.chat("gpt-4o-mini");
break;

View file

@ -229,6 +229,18 @@ export default function ContentApp({
if (rep.status === 200) {
toast({
title: "Saved to supermemory.ai",
action: (
<button
onClick={() => {
window.open(
`https://supermemory.ai`,
"_blank",
);
}}
>
View
</button>
),
});
} else {
toast({

View file

@ -1,7 +1,7 @@
{
"manifest_version": 3,
"$schema": "https://json.schemastore.org/chrome-manifest",
"version": "2.63.1",
"version": "2.63.2",
"name": "supermemory",
"description": "An extension for https://supermemory.ai - an AI hub for all your bookmarks.",
"background": {

View file

@ -1,5 +1,6 @@
{
"devDependencies": {
"@extension-create/develop": "^1.8.0",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.5",
"@webpack-cli/generators": "^3.0.7",

View file

@ -31,10 +31,20 @@ import ComboboxWithCreate from "@repo/ui/shadcn/combobox";
import { StoredSpace } from "@repo/db/schema";
import useMeasure from "react-use-measure";
import { useKeyPress } from "@/lib/useKeyPress";
import { useFormStatus } from "react-dom";
function Menu() {
const [spaces, setSpaces] = useState<StoredSpace[]>([]);
function SubmitButton() {
const status = useFormStatus();
return (
<Button disabled={status.pending} variant={"secondary"} type="submit">
Save {autoDetectedType != "none" && autoDetectedType}
</Button>
);
}
useEffect(() => {
(async () => {
let spaces = await getSpaces();
@ -120,15 +130,21 @@ function Menu() {
});
setContent("");
setSelectedSpaces([]);
if (cont.success) {
toast.success("Memory queued", {
richColors: true,
});
} else {
toast.error(`Memory creation failed: ${cont.error}`);
throw new Error(`Memory creation failed: ${cont.error}`);
return cont;
}
return cont;
};
const formSubmit = () => {
toast.promise(handleSubmit(content, selectedSpaces), {
loading: (
<span>
<PlusCircleIcon className="w-4 h-4 inline mr-2 text-white animate-spin" />{" "}
Creating memory...
</span>
),
success: (data) => "Memory queued",
error: (error) => `Memory creation failed: ${error}`,
richColors: true,
});
};
return (
@ -180,23 +196,7 @@ function Menu() {
</div>
<DialogContent className="sm:max-w-[475px] text-[#F2F3F5] rounded-2xl bg-background z-[39]">
<form
action={async (e: FormData) => {
const content = e.get("content")?.toString();
toast.promise(handleSubmit(content, selectedSpaces), {
loading: (
<span>
<PlusCircleIcon className="w-4 h-4 inline mr-2 text-white animate-spin" />{" "}
Creating memory...
</span>
),
success: (data) => "Memory queued",
error: (error) => error.message,
richColors: true,
});
}}
className="flex flex-col gap-4 "
>
<form action={formSubmit} className="flex flex-col gap-4 ">
<DialogHeader>
<DialogTitle>Add memory</DialogTitle>
<DialogDescription className="text-[#F2F3F5]">
@ -217,17 +217,7 @@ function Menu() {
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
toast.promise(handleSubmit(content, selectedSpaces), {
loading: (
<span>
<PlusCircleIcon className="w-4 h-4 inline mr-2 text-white animate-spin" />{" "}
Creating memory...
</span>
),
success: (data) => "Memory created",
error: (error) => error.message,
richColors: true,
});
formSubmit();
}
}}
/>
@ -319,13 +309,7 @@ function Menu() {
</div>
<DialogFooter>
<Button
disabled={autoDetectedType === "none"}
variant={"secondary"}
type="submit"
>
Save {autoDetectedType != "none" && autoDetectedType}
</Button>
<SubmitButton />
</DialogFooter>
</form>
</DialogContent>

View file

@ -86,7 +86,7 @@ export default function RootLayout({
>
{children}
<Toaster />
<PostHogPageView />
{/* <PostHogPageView /> */}
</body>
</PHProvider>
</html>

View file

@ -4,12 +4,6 @@ import posthog from "posthog-js";
import { PostHogProvider } from "posthog-js/react";
if (typeof window !== "undefined") {
if (
!process.env.NEXT_PUBLIC_POSTHOG_KEY ||
!process.env.NEXT_PUBLIC_POSTHOG_HOST
) {
console.error("PostHog key or host not found");
}
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
person_profiles: "identified_only",

View file

@ -26,8 +26,8 @@ bucket_name = "dev-r2-anycontext"
[[d1_databases]]
binding = "DATABASE"
database_name = "dev-d1-anycontext"
database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c"
database_name = "prod-d1-supermemory"
database_id = "f527a727-c472-41d4-8eaf-3d7ba0f2f395"
[[env.production.d1_databases]]
binding = "DATABASE"

View file

@ -113,8 +113,8 @@ export const storedContent = createTable(
description: text("description", { length: 255 }),
url: text("url").notNull(),
savedAt: int("savedAt", { mode: "timestamp" }).notNull(),
baseUrl: text("baseUrl", { length: 255 }).unique(),
ogImage: text("ogImage", { length: 255 }),
baseUrl: text("baseUrl"),
ogImage: text("ogImage"),
type: text("type").default("page"),
image: text("image", { length: 255 }),
userId: text("user").references(() => users.id, {

3
pnpm-lock.yaml generated
View file

@ -338,6 +338,9 @@ importers:
specifier: ^1.0.7
version: 1.0.7(tailwindcss@3.4.7)
devDependencies:
'@extension-create/develop':
specifier: ^1.8.0
version: 1.8.0(browserslist@4.23.2)(esbuild@0.19.12)(typescript@5.3.3)(vue@3.4.34)(webpack-cli@5.1.4)
'@types/react':
specifier: ^18.0.9
version: 18.3.3