Skip to content

Memory Playground #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

singhk97
Copy link
Contributor

@singhk97 singhk97 commented Jan 8, 2025

This PR introduces two high level applications:

  1. packages/memory-server: A FastAPI server that wraps around the memory module and exposes core features like adding message, and retrieving memories.
  2. playground: A simple web application to easily view and interact with the memory module.

Other changes

  • Ruff lint and format touched a bunch of unrelated files.

Example
image

@Copilot Copilot AI review requested due to automatic review settings January 8, 2025 20:38
@singhk97 singhk97 requested a review from a team as a code owner January 8, 2025 20:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 41 out of 56 changed files in this pull request and generated no comments.

Files not reviewed (15)
  • packages/memory-server/.python-version: Language not supported
  • packages/memory-server/sample.env: Language not supported
  • playground/.gitignore: Language not supported
  • playground/index.html: Language not supported
  • playground/package.json: Language not supported
  • packages/memory_module/utils/teams_bot_middlware.py: Evaluated as low risk
  • packages/memory_module/storage/in_memory_storage.py: Evaluated as low risk
  • packages/memory_module/storage/sqlite_memory_storage.py: Evaluated as low risk
  • packages/evals/benchmark_memory_module.py: Evaluated as low risk
  • packages/memory_module/storage/sqlite_storage.py: Evaluated as low risk
  • playground/postcss.config.js: Evaluated as low risk
  • playground/README.md: Evaluated as low risk
  • packages/memory-server/memory_service.py: Evaluated as low risk
  • playground/src/api/memoryServer.ts: Evaluated as low risk
  • packages/memory-server/README.md: Evaluated as low risk

@@ -0,0 +1,18 @@
# Memory Server
FastAPI wrapper around the memory module.
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the future, do we want to consider having the wrapper as separate package so people don't need to download the related dependencies if they want to?

(Can file for discussion and close this comment if anyone agrees)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what you mean since the wrapper is already a separate package. It's under packages/memory-server while the memory module is under packages/memory-module.

Copy link
Collaborator

Choose a reason for hiding this comment

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

as in, if we were publishing it, don't publish it with the rest of the code (bloat). but I'm still unclear on the publishing bit haha.

"preview": "vite preview"
},
"dependencies": {
"lucide-react": "^0.344.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unnecessary dependency. We should be using Microsoft's/Teams' fluent icons

"react-router-dom": "^6.14.2"
},
"devDependencies": {
"@eslint/js": "^9.9.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need the js eslint since the code is in typescript?

content: string;
created_at: string;
updated_at: string;
memory_type: 'semantic' | 'episodic';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: saving these as constants?

Copy link
Collaborator

@heyitsaamir heyitsaamir left a comment

Choose a reason for hiding this comment

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

This is helpful, but I think we should think about how this fits into the developer story. The memory module will be published as a separate package. This playground will only really come into play if the developer tries to pull this repo right?

@@ -0,0 +1,18 @@
# Memory Server
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't want to spend too much extra time on this tool, but it would be worth considering how we could combine the efforts in the sample and this. (i.e. the sample has a web component that is really simple to show a user's memories). Just a consideration, not actionable.

@@ -0,0 +1,19 @@
# Memory Playground UI

A simple web application to easily view and interact with the memory module.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth adding that this isn't meant for production

@@ -14,13 +14,12 @@

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from evals.helpers import Dataset, DatasetItem, load_dataset, setup_mlflow
Copy link
Collaborator

Choose a reason for hiding this comment

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

TODO for later: unit tests. Same for the playground.


const DataTableBase = function (props: any) {
return (
<DataTable
Copy link
Collaborator

Choose a reason for hiding this comment

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

TODO for future: read up on react-data-table-component's styles for dark mode :D

}`}
>
<span className="dark:hidden">
<svg
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally the svg should be in a different file and imported.

version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you change to

Suggested change
requires-python = ">=3.12"
requires-python = ">=3.11,<3.13"

[project]
name = "memory-server"
version = "0.1.0"
description = "Add your description here"
Copy link
Collaborator

Choose a reason for hiding this comment

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

description

@@ -0,0 +1,19 @@
[project]
name = "memory-server"
version = "0.1.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

version must be directly below [project]. Just did a PR that fixed this elsewhere :D

1. Navigate to this folder in the termainl.
1. Set up the dependencies by doing `pnpm install` in the root folder.
1. Run `pnpm run dev` to start the application on port 5173.
1. Ensure that the memory server is configured and running locally. See `packages/memory-server`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Link to memory server readme?


# Disclaimer

Some components were taken from [TailAdmin](https://tailadmin.com/)'s free to use component package, which is under the MIT License.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you haven't already, this disclaimer should be where that code is

"devDependencies": {
"@eslint/js": "^9.9.1",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

@types/react-hooks?

Comment on lines +3 to +4
"target": "ES2022",
"lib": ["ES2023"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

ESNext for both?

Comment on lines +3 to +5
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

ESNext? make sure all tsconfigs match


{/* <!-- ===== Content Area Start ===== --> */}
<div className="relative flex flex-1 flex-col overflow-y-auto overflow-x-hidden">
{/* <!-- ===== Header Start ===== --> */}
Copy link
Collaborator

Choose a reason for hiding this comment

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

These comments are messy. Is Header ever going to be more than one line?

{/* <!-- ===== Page Wrapper Start ===== --> */}
<div className="flex h-screen overflow-hidden">
{/* <!-- ===== Sidebar Start ===== --> */}
<Sidebar sidebarOpen={sidebarOpen} setSidebarOpen={setSidebarOpen} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sidebar seems unnecessary atm since it doesn't have anything. Title should be in main body.

@@ -0,0 +1,107 @@
import { useEffect, useRef } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is necessary since there's only one view.

@@ -0,0 +1,18 @@
import { useEffect } from 'react'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also unnecessary since there's only one view.

@@ -0,0 +1,17 @@
import routes
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmmmmm fastapi is a very old package and not maintained. We should find a better solution for v next


return (
<div className={surroundingBoxStyle}>
<div className="h-16 w-16 animate-spin rounded-full border-4 border-solid border-teams border-t-transparent"></div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

wait, what's spinning?

{/* <!-- Hamburger Toggle BTN --> */}
<button
aria-controls="sidebar"
onClick={(e) => {
Copy link
Collaborator

@corinagum corinagum Jan 10, 2025

Choose a reason for hiding this comment

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

refactor all functions outside of the jsx (use named functions)

import React from 'react';
import { Memory } from '../types';

interface DialogProps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is defined multiple times - put in types file?

min={1}
defaultValue={5}
{...register("limit", { required: false, min: 1 })}
className="p-2 rounded-md bg-white border border-gray-300 rounded-lg border-[1.5px] border-stroke bg-transparent py-3 px-5 text-black outline-none transition focus:border-teams active:border-teams disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-teams"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Future TODO: make all classname strings variables and refactor into separate file. Exception could be components with 3 or fewer classes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines +100 to +155
const ColumnTitle = (props: { title: string }) => {
const { title } = props;

return (
<div className="mb-1 text-gray-700 font-bold">
{title}
</div>
);
}

const CustomCell = (props: { content: string }) => {
const { content } = props;

return (
<div className="text-center">
{ content }
</div>
);
}

const columns = [
{
name: <ColumnTitle title="ID" />,
selector: (row: Memory) => row.id,
grow: 0.5,
cell: (row: Memory) => <CustomCell content={row.id} />
},
{
name: <ColumnTitle title="Content" />,
selector: (row: Memory) => row.content,
grow: 1,
},
{
name: <ColumnTitle title="Created At" />,
selector: (row: Memory) => row.created_at,
grow: 0.5,
},
{
name: <ColumnTitle title="User Id" />,
selector: (row: Memory) => row.user_id,
grow: 0.5
},
{
name: <ColumnTitle title="Memory Type" />,
selector: (row: Memory) => row.memory_type,
grow: 0.5
},
{
name: <ColumnTitle title="Update At" />,
selector: (row: Memory) => row.updated_at ?? "-",
grow: 0.5,
cell: (row: Memory) => <CustomCell content={row.updated_at ?? "-"} />,
onClick: handleRowClick // Add onClick handler to rows
},
];

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally defined in separate files

65: '.65',
},
backgroundImage: {
video: "url('../images/video/video.png')",
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's this? Are all of the defined props in this file being used in the project?

"react-hook-form": "^7.54.2",
"react-router-dom": "^6.14.2"
},
"devDependencies": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably want prettier & prettier tailwind plugin for class sorting

},
"dependencies": {
"lucide-react": "^0.344.0",
"openai": "^4.77.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update version?

e.stopPropagation();
props.setSidebarOpen(!props.sidebarOpen);
}}
className="z-99999 block rounded-sm border border-stroke bg-white p-1.5 shadow-sm dark:border-strokedark dark:bg-boxdark lg:hidden"
Copy link
Collaborator

Choose a reason for hiding this comment

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

z-index 🙁

return (
<header className="sticky top-0 z-999 flex w-full bg-gray-3 dark:bg-boxdark dark:drop-shadow-none">
<div className="flex flex-grow items-center justify-between px-4 py-4 md:px-6 2xl:px-11">
<div className="flex items-center gap-2 sm:gap-4 lg:hidden">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does this button show up in the UI?

aria-expanded={sidebarOpen}
className="block lg:hidden"
>
<svg
Copy link
Collaborator

Choose a reason for hiding this comment

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

export to assets jsx file with comment on what the svg looks like

Copy link
Collaborator

@corinagum corinagum left a comment

Choose a reason for hiding this comment

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

Cool feature! Seems like there's still bloat, like the sidebar?

@singhk97
Copy link
Contributor Author

Thanks for the feedback folks, I will be looking into this a bit later since it's lower priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants