mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-10 08:48:29 +00:00
Feat: UI changes
This commit is contained in:
parent
e62547526b
commit
56adc246c8
@ -1,4 +1,6 @@
|
|||||||
*/**.js
|
*/**.js
|
||||||
*/**.d.ts
|
*/**.d.ts
|
||||||
packages/*/dist
|
packages/*/dist
|
||||||
packages/*/lib
|
packages/*/lib
|
||||||
|
|
||||||
|
build/
|
||||||
1
apps/webapp/.eslintignore
Normal file
1
apps/webapp/.eslintignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
public/
|
||||||
@ -5,7 +5,6 @@
|
|||||||
{
|
{
|
||||||
"files": ["*.ts", "*.tsx"],
|
"files": ["*.ts", "*.tsx"],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
||||||
"@typescript-eslint/consistent-type-imports": [
|
"@typescript-eslint/consistent-type-imports": [
|
||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
@ -13,15 +12,15 @@
|
|||||||
// during some autofixes, so easier to just turn it off
|
// during some autofixes, so easier to just turn it off
|
||||||
"prefer": "type-imports",
|
"prefer": "type-imports",
|
||||||
"disallowTypeAnnotations": true,
|
"disallowTypeAnnotations": true,
|
||||||
"fixStyle": "inline-type-imports"
|
"fixStyle": "inline-type-imports",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
"import/no-duplicates": ["warn", { "prefer-inline": true }],
|
"import/no-duplicates": ["warn", { "prefer-inline": true }],
|
||||||
// lots of undeclared vars, enable this rule if you want to clean them up
|
// lots of undeclared vars, enable this rule if you want to clean them up
|
||||||
"turbo/no-undeclared-env-vars": "off"
|
"turbo/no-undeclared-env-vars": "off",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
"ignorePatterns": []
|
"ignorePatterns": ["public/"],
|
||||||
}
|
}
|
||||||
|
|||||||
1
apps/webapp/app/components/dashboard/index.ts
Normal file
1
apps/webapp/app/components/dashboard/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "./ingest";
|
||||||
47
apps/webapp/app/components/dashboard/ingest.tsx
Normal file
47
apps/webapp/app/components/dashboard/ingest.tsx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { PlusIcon } from "lucide-react";
|
||||||
|
import { Button } from "../ui";
|
||||||
|
import { Textarea } from "../ui/textarea";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { EpisodeType } from "@core/types";
|
||||||
|
|
||||||
|
export const IngestBodyRequest = z.object({
|
||||||
|
episodeBody: z.string(),
|
||||||
|
referenceTime: z.string(),
|
||||||
|
type: z.enum([EpisodeType.Conversation, EpisodeType.Text]), // Assuming these are the EpisodeType values
|
||||||
|
source: z.string(),
|
||||||
|
spaceId: z.string().optional(),
|
||||||
|
sessionId: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const Ingest = () => {
|
||||||
|
const [text, setText] = useState("");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<form method="POST" action="/home/dashboard" className="flex flex-col">
|
||||||
|
<input type="hidden" name="type" value="TEXT" />
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="referenceTime"
|
||||||
|
value={new Date().toISOString()}
|
||||||
|
/>
|
||||||
|
<input type="hidden" name="source" value="local" />
|
||||||
|
|
||||||
|
<Textarea
|
||||||
|
name="episodeBody"
|
||||||
|
value={text}
|
||||||
|
placeholder="Tell what you want to add"
|
||||||
|
onChange={(e) => setText(e.target.value)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="mt-2 flex justify-end">
|
||||||
|
<Button type="submit" variant="secondary" className="gap-1">
|
||||||
|
<PlusIcon size={16} />
|
||||||
|
Add
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -75,10 +75,11 @@ export function GraphPopovers({
|
|||||||
if (!nodePopupContent) {
|
if (!nodePopupContent) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const entityProperties = Object.fromEntries(
|
const entityProperties = Object.fromEntries(
|
||||||
Object.entries(nodePopupContent.node.attributes || {}).filter(
|
Object.entries(nodePopupContent.node.attributes || {}).filter(([key]) => {
|
||||||
([key]) => key !== "labels",
|
return key !== "labels" && !key.includes("Embedding");
|
||||||
),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return Object.entries(entityProperties).map(([key, value]) => ({
|
return Object.entries(entityProperties).map(([key, value]) => ({
|
||||||
@ -181,24 +182,6 @@ export function GraphPopovers({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{nodePopupContent?.node.labels?.length ? (
|
|
||||||
<div className="border-border border-t pt-2">
|
|
||||||
<p className="mb-1 text-sm font-medium text-black dark:text-white">
|
|
||||||
Labels:
|
|
||||||
</p>
|
|
||||||
<div className="mt-1 flex flex-wrap gap-2">
|
|
||||||
{nodePopupContent.node.labels.map((label) => (
|
|
||||||
<span
|
|
||||||
key={label}
|
|
||||||
className="bg-muted rounded-md px-2 py-1 text-xs"
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</span>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
@ -215,7 +198,7 @@ export function GraphPopovers({
|
|||||||
sideOffset={5}
|
sideOffset={5}
|
||||||
onOpenAutoFocus={(e) => e.preventDefault()}
|
onOpenAutoFocus={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
<div className="bg-muted mb-4 rounded-md p-2">
|
<div className="bg-grayAlpha-100 mb-4 rounded-md p-2">
|
||||||
<p className="text-sm break-all">
|
<p className="text-sm break-all">
|
||||||
{edgePopupContent?.source.name || "Unknown"} →{" "}
|
{edgePopupContent?.source.name || "Unknown"} →{" "}
|
||||||
<span className="font-medium">
|
<span className="font-medium">
|
||||||
|
|||||||
@ -1,18 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useMemo, forwardRef } from "react";
|
import { useState, useMemo, forwardRef } from "react";
|
||||||
import { Graph, GraphRef } from "./graph";
|
import { Graph, type GraphRef } from "./graph";
|
||||||
import { GraphPopovers } from "./graph-popover";
|
import { GraphPopovers } from "./graph-popover";
|
||||||
import type { RawTriplet, NodePopupContent, EdgePopupContent } from "./type";
|
import type { RawTriplet, NodePopupContent, EdgePopupContent } from "./type";
|
||||||
import { toGraphTriplets } from "./type";
|
|
||||||
import { createLabelColorMap, getNodeColor } from "./node-colors";
|
import { createLabelColorMap, getNodeColor } from "./node-colors";
|
||||||
|
|
||||||
import {
|
|
||||||
HoverCard,
|
|
||||||
HoverCardContent,
|
|
||||||
HoverCardTrigger,
|
|
||||||
} from "@/components/ui/hover-card";
|
|
||||||
import { useTheme } from "remix-themes";
|
import { useTheme } from "remix-themes";
|
||||||
|
import { toGraphTriplets } from "./utils";
|
||||||
|
|
||||||
interface GraphVisualizationProps {
|
interface GraphVisualizationProps {
|
||||||
triplets: RawTriplet[];
|
triplets: RawTriplet[];
|
||||||
@ -29,7 +25,7 @@ export const GraphVisualization = forwardRef<GraphRef, GraphVisualizationProps>(
|
|||||||
width = window.innerWidth * 0.85,
|
width = window.innerWidth * 0.85,
|
||||||
height = window.innerHeight * 0.85,
|
height = window.innerHeight * 0.85,
|
||||||
zoomOnMount = true,
|
zoomOnMount = true,
|
||||||
className = "border border-border rounded-md h-[85vh] overflow-hidden relative",
|
className = "rounded-md h-full overflow-hidden relative",
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
@ -120,11 +116,12 @@ export const GraphVisualization = forwardRef<GraphRef, GraphVisualizationProps>(
|
|||||||
setShowNodePopup(false);
|
setShowNodePopup(false);
|
||||||
setShowEdgePopup(false);
|
setShowEdgePopup(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
{/* Entity Types Legend Button */}
|
{/* Entity Types Legend Button */}
|
||||||
<div className="absolute top-4 left-4 z-50">
|
<div className="absolute top-4 left-4 z-50">
|
||||||
<HoverCard>
|
{/* <HoverCard>
|
||||||
<HoverCardTrigger asChild>
|
<HoverCardTrigger asChild>
|
||||||
<button className="bg-primary/10 text-primary hover:bg-primary/20 rounded-md px-2.5 py-1 text-xs transition-colors">
|
<button className="bg-primary/10 text-primary hover:bg-primary/20 rounded-md px-2.5 py-1 text-xs transition-colors">
|
||||||
Entity Types
|
Entity Types
|
||||||
@ -151,7 +148,7 @@ export const GraphVisualization = forwardRef<GraphRef, GraphVisualizationProps>(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</HoverCardContent>
|
</HoverCardContent>
|
||||||
</HoverCard>
|
</HoverCard> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{triplets.length > 0 ? (
|
{triplets.length > 0 ? (
|
||||||
|
|||||||
@ -991,7 +991,7 @@ export const Graph = forwardRef<GraphRef, GraphProps>(
|
|||||||
const svgElement = d3.select(svgRef.current);
|
const svgElement = d3.select(svgRef.current);
|
||||||
|
|
||||||
// Update background
|
// Update background
|
||||||
svgElement.style("background-color", theme.background);
|
svgElement.style("background-color", "var(--background-3)");
|
||||||
|
|
||||||
// Update nodes - use getNodeColor for proper color assignment
|
// Update nodes - use getNodeColor for proper color assignment
|
||||||
svgElement
|
svgElement
|
||||||
|
|||||||
@ -3,36 +3,32 @@ import colors from "tailwindcss/colors";
|
|||||||
// Define a color palette for node coloring
|
// Define a color palette for node coloring
|
||||||
export const nodeColorPalette = {
|
export const nodeColorPalette = {
|
||||||
light: [
|
light: [
|
||||||
colors.pink[500], // Entity (default)
|
"var(--custom-color-1)", // Entity (default)
|
||||||
colors.blue[500],
|
"var(--custom-color-2)",
|
||||||
colors.emerald[500],
|
"var(--custom-color-3)",
|
||||||
colors.amber[500],
|
"var(--custom-color-4)",
|
||||||
colors.indigo[500],
|
"var(--custom-color-5)",
|
||||||
colors.orange[500],
|
"var(--custom-color-6)",
|
||||||
colors.teal[500],
|
"var(--custom-color-7)",
|
||||||
colors.purple[500],
|
"var(--custom-color-8)",
|
||||||
colors.cyan[500],
|
"var(--custom-color-9)",
|
||||||
colors.lime[500],
|
"var(--custom-color-10)",
|
||||||
colors.rose[500],
|
"var(--custom-color-11)",
|
||||||
colors.violet[500],
|
"var(--custom-color-12)",
|
||||||
colors.green[500],
|
|
||||||
colors.red[500],
|
|
||||||
],
|
],
|
||||||
dark: [
|
dark: [
|
||||||
colors.pink[400], // Entity (default)
|
"var(--custom-color-1)", // Entity (default)
|
||||||
colors.blue[400],
|
"var(--custom-color-2)",
|
||||||
colors.emerald[400],
|
"var(--custom-color-3)",
|
||||||
colors.amber[400],
|
"var(--custom-color-4)",
|
||||||
colors.indigo[400],
|
"var(--custom-color-5)",
|
||||||
colors.orange[400],
|
"var(--custom-color-6)",
|
||||||
colors.teal[400],
|
"var(--custom-color-7)",
|
||||||
colors.purple[400],
|
"var(--custom-color-8)",
|
||||||
colors.cyan[400],
|
"var(--custom-color-9)",
|
||||||
colors.lime[400],
|
"var(--custom-color-10)",
|
||||||
colors.rose[400],
|
"var(--custom-color-11)",
|
||||||
colors.violet[400],
|
"var(--custom-color-12)",
|
||||||
colors.green[400],
|
|
||||||
colors.red[400],
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
107
apps/webapp/app/components/graph/utils.ts
Normal file
107
apps/webapp/app/components/graph/utils.ts
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
import type {
|
||||||
|
Node,
|
||||||
|
Edge,
|
||||||
|
GraphNode,
|
||||||
|
GraphEdge,
|
||||||
|
RawTriplet,
|
||||||
|
GraphTriplet,
|
||||||
|
} from "./type";
|
||||||
|
|
||||||
|
export function toGraphNode(node: Node): GraphNode {
|
||||||
|
const primaryLabel =
|
||||||
|
node.labels?.find((label) => label != "Entity") || "Entity";
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: node.uuid,
|
||||||
|
value: node.name,
|
||||||
|
uuid: node.uuid,
|
||||||
|
name: node.name,
|
||||||
|
created_at: node.created_at,
|
||||||
|
updated_at: node.updated_at,
|
||||||
|
attributes: node.attributes,
|
||||||
|
summary: node.summary,
|
||||||
|
labels: node.labels,
|
||||||
|
primaryLabel,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toGraphEdge(edge: Edge): GraphEdge {
|
||||||
|
return {
|
||||||
|
id: edge.uuid,
|
||||||
|
value: edge.name,
|
||||||
|
...edge,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toGraphTriplet(triplet: RawTriplet): GraphTriplet {
|
||||||
|
return {
|
||||||
|
source: toGraphNode(triplet.sourceNode),
|
||||||
|
relation: toGraphEdge(triplet.edge),
|
||||||
|
target: toGraphNode(triplet.targetNode),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toGraphTriplets(triplets: RawTriplet[]): GraphTriplet[] {
|
||||||
|
return triplets.map(toGraphTriplet);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createTriplets(edges: Edge[], nodes: Node[]): RawTriplet[] {
|
||||||
|
// Create a Set of node UUIDs that are connected by edges
|
||||||
|
const connectedNodeIds = new Set<string>();
|
||||||
|
|
||||||
|
// Create triplets from edges
|
||||||
|
const edgeTriplets = edges
|
||||||
|
.map((edge) => {
|
||||||
|
const sourceNode = nodes.find(
|
||||||
|
(node) => node.uuid === edge.source_node_uuid,
|
||||||
|
);
|
||||||
|
const targetNode = nodes.find(
|
||||||
|
(node) => node.uuid === edge.target_node_uuid,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!sourceNode || !targetNode) return null;
|
||||||
|
|
||||||
|
// Add source and target node IDs to connected set
|
||||||
|
connectedNodeIds.add(sourceNode.uuid);
|
||||||
|
connectedNodeIds.add(targetNode.uuid);
|
||||||
|
|
||||||
|
return {
|
||||||
|
sourceNode,
|
||||||
|
edge,
|
||||||
|
targetNode,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter(
|
||||||
|
(t): t is RawTriplet =>
|
||||||
|
t !== null && t.sourceNode !== undefined && t.targetNode !== undefined,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Find isolated nodes (nodes that don't appear in any edge)
|
||||||
|
const isolatedNodes = nodes.filter(
|
||||||
|
(node) => !connectedNodeIds.has(node.uuid),
|
||||||
|
);
|
||||||
|
|
||||||
|
// For isolated nodes, create special triplets
|
||||||
|
const isolatedTriplets: RawTriplet[] = isolatedNodes.map((node) => {
|
||||||
|
// Create a special marker edge for isolated nodes
|
||||||
|
const virtualEdge: Edge = {
|
||||||
|
uuid: `isolated-node-${node.uuid}`,
|
||||||
|
source_node_uuid: node.uuid,
|
||||||
|
target_node_uuid: node.uuid,
|
||||||
|
// Use a special type that we can filter out in the Graph component
|
||||||
|
type: "_isolated_node_",
|
||||||
|
name: "", // Empty name so it doesn't show a label
|
||||||
|
created_at: node.created_at,
|
||||||
|
updated_at: node.updated_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
sourceNode: node,
|
||||||
|
edge: virtualEdge,
|
||||||
|
targetNode: node,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Combine edge triplets with isolated node triplets
|
||||||
|
return [...edgeTriplets, ...isolatedTriplets];
|
||||||
|
}
|
||||||
@ -6,13 +6,14 @@ export function LoginPageLayout({ children }: { children: React.ReactNode }) {
|
|||||||
const [, setTheme] = useTheme();
|
const [, setTheme] = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen w-screen flex-col items-center justify-center">
|
<div className="flex min-h-svh flex-col items-center justify-center gap-6 p-6 md:p-10">
|
||||||
<div className="text-foreground flex flex-col items-center pt-8 font-mono">
|
<div className="flex w-full max-w-sm flex-col gap-6">
|
||||||
<Logo width={50} height={50} />
|
<a href="#" className="flex items-center gap-2 self-center font-medium">
|
||||||
C.O.R.E
|
<div className="bg-background-3 flex size-6 items-center justify-center rounded-md">
|
||||||
</div>
|
<Logo width={20} height={20} />
|
||||||
|
</div>
|
||||||
<div className="flex h-full flex-grow items-center justify-center">
|
<div className="font-mono">C.O.R.E.</div>
|
||||||
|
</a>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -25,12 +25,12 @@ const data = {
|
|||||||
navMain: [
|
navMain: [
|
||||||
{
|
{
|
||||||
title: "Dashboard",
|
title: "Dashboard",
|
||||||
url: "#",
|
url: "/",
|
||||||
icon: DashboardIcon,
|
icon: DashboardIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "API",
|
title: "API",
|
||||||
url: "#",
|
url: "/api",
|
||||||
icon: Code,
|
icon: Code,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import {
|
|||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from "../ui/sidebar";
|
} from "../ui/sidebar";
|
||||||
import { NavUser } from "./nav-user";
|
import { NavUser } from "./nav-user";
|
||||||
|
import { useLocation } from "@remix-run/react";
|
||||||
|
|
||||||
export const NavMain = ({
|
export const NavMain = ({
|
||||||
items,
|
items,
|
||||||
@ -18,14 +19,18 @@ export const NavMain = ({
|
|||||||
icon?: any;
|
icon?: any;
|
||||||
}[];
|
}[];
|
||||||
}) => {
|
}) => {
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarGroupContent className="flex flex-col gap-2">
|
<SidebarGroupContent className="flex flex-col gap-2">
|
||||||
<SidebarMenu></SidebarMenu>
|
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<SidebarMenuItem key={item.title}>
|
<SidebarMenuItem key={item.title}>
|
||||||
<SidebarMenuButton tooltip={item.title}>
|
<SidebarMenuButton
|
||||||
|
tooltip={item.title}
|
||||||
|
isActive={location.pathname.includes(item.url)}
|
||||||
|
>
|
||||||
{item.icon && <item.icon />}
|
{item.icon && <item.icon />}
|
||||||
<span>{item.title}</span>
|
<span>{item.title}</span>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
|
|||||||
47
apps/webapp/app/components/ui/resizable.tsx
Normal file
47
apps/webapp/app/components/ui/resizable.tsx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import type { ImperativePanelHandle } from "react-resizable-panels";
|
||||||
|
|
||||||
|
import { DragHandleDots2Icon } from "@radix-ui/react-icons";
|
||||||
|
import React from "react";
|
||||||
|
import * as ResizablePrimitive from "react-resizable-panels";
|
||||||
|
|
||||||
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
|
const ResizablePanelGroup = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
|
||||||
|
<ResizablePrimitive.PanelGroup
|
||||||
|
className={cn(
|
||||||
|
"flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const ResizablePanel = ResizablePrimitive.Panel;
|
||||||
|
|
||||||
|
const ResizableHandle = ({
|
||||||
|
withHandle,
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
|
||||||
|
withHandle?: boolean;
|
||||||
|
}) => (
|
||||||
|
<ResizablePrimitive.PanelResizeHandle
|
||||||
|
className={cn(
|
||||||
|
"bg-background-1 focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{withHandle && (
|
||||||
|
<div className="bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border">
|
||||||
|
<DragHandleDots2Icon className="h-2.5 w-2.5" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</ResizablePrimitive.PanelResizeHandle>
|
||||||
|
);
|
||||||
|
|
||||||
|
export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
|
||||||
|
export type { ImperativePanelHandle };
|
||||||
53
apps/webapp/app/components/ui/tabs.tsx
Normal file
53
apps/webapp/app/components/ui/tabs.tsx
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
|
const Tabs = TabsPrimitive.Root;
|
||||||
|
|
||||||
|
const TabsList = React.forwardRef<
|
||||||
|
React.ElementRef<typeof TabsPrimitive.List>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<TabsPrimitive.List
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"bg-grayAlpha-100 inline-flex h-9 items-center justify-center rounded-md p-1",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
TabsList.displayName = TabsPrimitive.List.displayName;
|
||||||
|
|
||||||
|
const TabsTrigger = React.forwardRef<
|
||||||
|
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<TabsPrimitive.Trigger
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"ring-offset-background focus-visible:ring-ring data-[state=active]:bg-accent data-[state=active]:text-accent-foreground inline-flex items-center justify-center rounded px-3 py-1 whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
||||||
|
|
||||||
|
const TabsContent = React.forwardRef<
|
||||||
|
React.ElementRef<typeof TabsPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<TabsPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
||||||
|
|
||||||
|
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
||||||
36
apps/webapp/app/components/ui/textarea.tsx
Normal file
36
apps/webapp/app/components/ui/textarea.tsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { useAutoSizeTextArea } from "../../hooks/use-autosize-textarea";
|
||||||
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
|
export interface TextareaProps
|
||||||
|
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
||||||
|
|
||||||
|
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||||
|
({ className, value, ...props }, ref) => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const textAreaRef = React.useRef<any>(ref);
|
||||||
|
const id = React.useMemo(() => {
|
||||||
|
return `id${Math.random().toString(16).slice(2)}`;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useAutoSizeTextArea(id, textAreaRef.current, value);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<textarea
|
||||||
|
className={cn(
|
||||||
|
"bg-input placeholder:text-muted-foreground focus-visible:ring-ring h-auto min-h-[30px] w-full rounded px-3 py-2 focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
id={id}
|
||||||
|
ref={textAreaRef}
|
||||||
|
contentEditable
|
||||||
|
value={value}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
Textarea.displayName = "Textarea";
|
||||||
|
|
||||||
|
export { Textarea };
|
||||||
23
apps/webapp/app/hooks/use-autosize-textarea.tsx
Normal file
23
apps/webapp/app/hooks/use-autosize-textarea.tsx
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
// Updates the height of a <textarea> when the value changes.
|
||||||
|
export const useAutoSizeTextArea = (
|
||||||
|
id: string,
|
||||||
|
textAreaRef: HTMLTextAreaElement | null,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
value: any,
|
||||||
|
) => {
|
||||||
|
React.useLayoutEffect(() => {
|
||||||
|
const textArea = textAreaRef ?? document.getElementById(id);
|
||||||
|
|
||||||
|
if (textArea && textArea.style && value) {
|
||||||
|
// We need to reset the height momentarily to get the correct scrollHeight for the textarea
|
||||||
|
textArea.style.height = "auto";
|
||||||
|
const scrollHeight = textArea.scrollHeight;
|
||||||
|
|
||||||
|
// We then set the height directly, outside of the render loop
|
||||||
|
// Trying to set this with state or a ref will product an incorrect value.
|
||||||
|
textArea.style.height = `${10 + scrollHeight}px`;
|
||||||
|
}
|
||||||
|
}, [textAreaRef, value, id]);
|
||||||
|
};
|
||||||
26
apps/webapp/app/hooks/use-local-state.tsx
Normal file
26
apps/webapp/app/hooks/use-local-state.tsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { useState, useEffect } from "react";
|
||||||
|
|
||||||
|
export const useLocalCommonState = <T,>(key: string, initialValue?: T) => {
|
||||||
|
const path = "userSettings";
|
||||||
|
const [state, setState] = useState<T>(() => {
|
||||||
|
// Try to load from localStorage on initial render
|
||||||
|
const savedObject = localStorage?.getItem(path);
|
||||||
|
const parsedObject = savedObject ? JSON.parse(savedObject) : {};
|
||||||
|
return key in parsedObject ? parsedObject[key] : initialValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save to localStorage whenever state changes
|
||||||
|
useEffect(() => {
|
||||||
|
const savedObject = localStorage.getItem(path);
|
||||||
|
const parsedObject = savedObject ? JSON.parse(savedObject) : {};
|
||||||
|
localStorage.setItem(
|
||||||
|
path,
|
||||||
|
JSON.stringify({
|
||||||
|
...parsedObject,
|
||||||
|
[key]: state,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}, [state, path, key]);
|
||||||
|
|
||||||
|
return [state, setState] as const;
|
||||||
|
};
|
||||||
@ -1,13 +1,14 @@
|
|||||||
import { type Workspace } from "@core/database";
|
import { type Workspace } from "@core/database";
|
||||||
import { type UIMatch } from "@remix-run/react";
|
import { type UIMatch } from "@remix-run/react";
|
||||||
import { type loader } from "~/routes/_index";
|
|
||||||
import { useTypedMatchesData } from "./useTypedMatchData";
|
import { useTypedMatchesData } from "./useTypedMatchData";
|
||||||
|
import { loader } from "~/routes/home";
|
||||||
|
|
||||||
export function useOptionalWorkspace(
|
export function useOptionalWorkspace(
|
||||||
matches?: UIMatch[],
|
matches?: UIMatch[],
|
||||||
): Workspace | undefined {
|
): Workspace | undefined {
|
||||||
const routeMatch = useTypedMatchesData<typeof loader>({
|
const routeMatch = useTypedMatchesData<typeof loader>({
|
||||||
id: "routes/_index",
|
id: "routes/home",
|
||||||
matches,
|
matches,
|
||||||
}) as any;
|
}) as any;
|
||||||
|
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
// lib/ingest.queue.ts
|
|
||||||
import { Queue, Worker } from "bullmq";
|
|
||||||
import IORedis from "ioredis";
|
|
||||||
import { env } from "~/env.server";
|
|
||||||
import { KnowledgeGraphService } from "../services/knowledgeGraph.server";
|
|
||||||
|
|
||||||
const connection = new IORedis({
|
|
||||||
port: env.REDIS_PORT,
|
|
||||||
host: env.REDIS_HOST,
|
|
||||||
maxRetriesPerRequest: null,
|
|
||||||
enableReadyCheck: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const userQueues = new Map<string, Queue>();
|
|
||||||
const userWorkers = new Map<string, Worker>();
|
|
||||||
|
|
||||||
async function processUserJob(userId: string, job: any) {
|
|
||||||
try {
|
|
||||||
console.log(job);
|
|
||||||
console.log(`Processing job for user ${userId}`);
|
|
||||||
const knowledgeGraphService = new KnowledgeGraphService();
|
|
||||||
|
|
||||||
knowledgeGraphService.addEpisode({ ...job.data.body, userId });
|
|
||||||
|
|
||||||
// your processing logic
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error processing job for user ${userId}:`, err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUserQueue(userId: string) {
|
|
||||||
if (!userQueues.has(userId)) {
|
|
||||||
const queueName = `ingest-${userId}`;
|
|
||||||
const queue = new Queue(queueName, { connection });
|
|
||||||
userQueues.set(userId, queue);
|
|
||||||
|
|
||||||
const worker = new Worker(queueName, (job) => processUserJob(userId, job), {
|
|
||||||
connection,
|
|
||||||
concurrency: 1,
|
|
||||||
});
|
|
||||||
userWorkers.set(userId, worker);
|
|
||||||
}
|
|
||||||
|
|
||||||
return userQueues.get(userId)!;
|
|
||||||
}
|
|
||||||
116
apps/webapp/app/lib/ingest.server.ts
Normal file
116
apps/webapp/app/lib/ingest.server.ts
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
// lib/ingest.queue.ts
|
||||||
|
import { Queue, Worker } from "bullmq";
|
||||||
|
import IORedis from "ioredis";
|
||||||
|
import { env } from "~/env.server";
|
||||||
|
import { KnowledgeGraphService } from "../services/knowledgeGraph.server";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { EpisodeType } from "@core/types";
|
||||||
|
import { prisma } from "~/db.server";
|
||||||
|
import { IngestionStatus } from "@core/database";
|
||||||
|
import { logger } from "~/services/logger.service";
|
||||||
|
|
||||||
|
const connection = new IORedis({
|
||||||
|
port: env.REDIS_PORT,
|
||||||
|
host: env.REDIS_HOST,
|
||||||
|
maxRetriesPerRequest: null,
|
||||||
|
enableReadyCheck: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const userQueues = new Map<string, Queue>();
|
||||||
|
const userWorkers = new Map<string, Worker>();
|
||||||
|
|
||||||
|
async function processUserJob(userId: string, job: any) {
|
||||||
|
try {
|
||||||
|
logger.log(`Processing job for user ${userId}`);
|
||||||
|
|
||||||
|
await prisma.ingestionQueue.update({
|
||||||
|
where: { id: job.data.queueId },
|
||||||
|
data: {
|
||||||
|
status: IngestionStatus.PROCESSING,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const knowledgeGraphService = new KnowledgeGraphService();
|
||||||
|
|
||||||
|
const episodeDetails = await knowledgeGraphService.addEpisode({
|
||||||
|
...job.data.body,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
await prisma.ingestionQueue.update({
|
||||||
|
where: { id: job.data.queueId },
|
||||||
|
data: {
|
||||||
|
status: IngestionStatus.COMPLETED,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// your processing logic
|
||||||
|
} catch (err) {
|
||||||
|
await prisma.ingestionQueue.update({
|
||||||
|
where: { id: job.data.queueId },
|
||||||
|
data: {
|
||||||
|
status: IngestionStatus.FAILED,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.error(`Error processing job for user ${userId}:`, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getUserQueue(userId: string) {
|
||||||
|
if (!userQueues.has(userId)) {
|
||||||
|
const queueName = `ingest-user-${userId}`;
|
||||||
|
const queue = new Queue(queueName, { connection });
|
||||||
|
userQueues.set(userId, queue);
|
||||||
|
|
||||||
|
const worker = new Worker(queueName, (job) => processUserJob(userId, job), {
|
||||||
|
connection,
|
||||||
|
concurrency: 1,
|
||||||
|
});
|
||||||
|
userWorkers.set(userId, worker);
|
||||||
|
}
|
||||||
|
|
||||||
|
return userQueues.get(userId)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const IngestBodyRequest = z.object({
|
||||||
|
episodeBody: z.string(),
|
||||||
|
referenceTime: z.string(),
|
||||||
|
type: z.enum([EpisodeType.Conversation, EpisodeType.Text]), // Assuming these are the EpisodeType values
|
||||||
|
source: z.string(),
|
||||||
|
spaceId: z.string().optional(),
|
||||||
|
sessionId: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const addToQueue = async (
|
||||||
|
body: z.infer<typeof IngestBodyRequest>,
|
||||||
|
userId: string,
|
||||||
|
) => {
|
||||||
|
const queuePersist = await prisma.ingestionQueue.create({
|
||||||
|
data: {
|
||||||
|
spaceId: body.spaceId,
|
||||||
|
data: body,
|
||||||
|
status: IngestionStatus.PENDING,
|
||||||
|
priority: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const ingestionQueue = getUserQueue(userId);
|
||||||
|
|
||||||
|
const jobDetails = await ingestionQueue.add(
|
||||||
|
`ingest-user-${userId}`, // 👈 unique name per user
|
||||||
|
{
|
||||||
|
queueId: queuePersist.id,
|
||||||
|
spaceId: body.spaceId,
|
||||||
|
userId: userId,
|
||||||
|
body,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
jobId: `${userId}-${Date.now()}`, // unique per job but grouped under user
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: jobDetails.id,
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { LLMMappings, LLMModelEnum } from "@recall/types";
|
import { LLMMappings, LLMModelEnum } from "@core/types";
|
||||||
import {
|
import {
|
||||||
type CoreMessage,
|
type CoreMessage,
|
||||||
type LanguageModelV1,
|
type LanguageModelV1,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import neo4j from "neo4j-driver";
|
import neo4j from "neo4j-driver";
|
||||||
|
import { type RawTriplet } from "~/components/graph/type";
|
||||||
import { env } from "~/env.server";
|
import { env } from "~/env.server";
|
||||||
import { logger } from "~/services/logger.service";
|
import { logger } from "~/services/logger.service";
|
||||||
|
|
||||||
@ -17,6 +18,8 @@ const driver = neo4j.driver(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let schemaInitialized = false;
|
||||||
|
|
||||||
// Test the connection
|
// Test the connection
|
||||||
const verifyConnectivity = async () => {
|
const verifyConnectivity = async () => {
|
||||||
try {
|
try {
|
||||||
@ -28,7 +31,6 @@ const verifyConnectivity = async () => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Run a Cypher query
|
// Run a Cypher query
|
||||||
const runQuery = async (cypher: string, params = {}) => {
|
const runQuery = async (cypher: string, params = {}) => {
|
||||||
const session = driver.session();
|
const session = driver.session();
|
||||||
@ -43,9 +45,94 @@ const runQuery = async (cypher: string, params = {}) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get all nodes and relationships for a user
|
||||||
|
export const getAllNodesForUser = async (userId: string) => {
|
||||||
|
const session = driver.session();
|
||||||
|
try {
|
||||||
|
const result = await session.run(
|
||||||
|
`MATCH (n)-[r]->(m)
|
||||||
|
WHERE n.userId = $userId OR m.userId = $userId
|
||||||
|
RETURN n, r, m`,
|
||||||
|
{ userId },
|
||||||
|
);
|
||||||
|
return result.records;
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Error getting nodes for user ${userId}: ${error}`);
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
await session.close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getNodeLinks = async (userId: string) => {
|
||||||
|
const result = await getAllNodesForUser(userId);
|
||||||
|
const triplets: RawTriplet[] = [];
|
||||||
|
|
||||||
|
result.forEach((record) => {
|
||||||
|
const sourceNode = record.get("n");
|
||||||
|
const targetNode = record.get("m");
|
||||||
|
const edge = record.get("r");
|
||||||
|
triplets.push({
|
||||||
|
sourceNode: {
|
||||||
|
uuid: sourceNode.identity.toString(),
|
||||||
|
labels: sourceNode.labels,
|
||||||
|
attributes: sourceNode.properties,
|
||||||
|
name: sourceNode.properties.name || "",
|
||||||
|
created_at: sourceNode.properties.created_at || "",
|
||||||
|
updated_at: sourceNode.properties.updated_at || "",
|
||||||
|
},
|
||||||
|
edge: {
|
||||||
|
uuid: edge.identity.toString(),
|
||||||
|
type: edge.type,
|
||||||
|
source_node_uuid: sourceNode.identity.toString(),
|
||||||
|
target_node_uuid: targetNode.identity.toString(),
|
||||||
|
name: edge.properties.name || "",
|
||||||
|
created_at: edge.properties.created_at || "",
|
||||||
|
updated_at: edge.properties.updated_at || "",
|
||||||
|
},
|
||||||
|
targetNode: {
|
||||||
|
uuid: targetNode.identity.toString(),
|
||||||
|
labels: targetNode.labels,
|
||||||
|
attributes: targetNode.properties,
|
||||||
|
name: targetNode.properties.name || "",
|
||||||
|
created_at: targetNode.properties.created_at || "",
|
||||||
|
updated_at: targetNode.properties.updated_at || "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return triplets;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function initNeo4jSchemaOnce() {
|
||||||
|
if (schemaInitialized) return;
|
||||||
|
|
||||||
|
const session = driver.session();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Check if schema already exists
|
||||||
|
const result = await session.run(`
|
||||||
|
SHOW INDEXES YIELD name WHERE name = "entity_name" RETURN name
|
||||||
|
`);
|
||||||
|
|
||||||
|
if (result.records.length === 0) {
|
||||||
|
// Run your schema creation here (indexes, constraints, etc.)
|
||||||
|
await initializeSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
schemaInitialized = true;
|
||||||
|
} catch (e: any) {
|
||||||
|
logger.error("Error in initialising", e);
|
||||||
|
} finally {
|
||||||
|
await session.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the database schema
|
// Initialize the database schema
|
||||||
const initializeSchema = async () => {
|
const initializeSchema = async () => {
|
||||||
try {
|
try {
|
||||||
|
logger.info("Initialising neo4j schema");
|
||||||
|
|
||||||
// Create constraints for unique IDs
|
// Create constraints for unique IDs
|
||||||
await runQuery(
|
await runQuery(
|
||||||
"CREATE CONSTRAINT episode_uuid IF NOT EXISTS FOR (n:Episode) REQUIRE n.uuid IS UNIQUE",
|
"CREATE CONSTRAINT episode_uuid IF NOT EXISTS FOR (n:Episode) REQUIRE n.uuid IS UNIQUE",
|
||||||
@ -122,6 +209,4 @@ const closeDriver = async () => {
|
|||||||
logger.info("Neo4j driver closed");
|
logger.info("Neo4j driver closed");
|
||||||
};
|
};
|
||||||
|
|
||||||
// await initializeSchema();
|
|
||||||
|
|
||||||
export { driver, verifyConnectivity, runQuery, initializeSchema, closeDriver };
|
export { driver, verifyConnectivity, runQuery, initializeSchema, closeDriver };
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
Links,
|
Links,
|
||||||
LiveReload,
|
|
||||||
Meta,
|
Meta,
|
||||||
Outlet,
|
Outlet,
|
||||||
Scripts,
|
Scripts,
|
||||||
@ -42,6 +41,7 @@ import {
|
|||||||
useTheme,
|
useTheme,
|
||||||
} from "remix-themes";
|
} from "remix-themes";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
import { initNeo4jSchemaOnce } from "./lib/neo4j.server";
|
||||||
|
|
||||||
export const links: LinksFunction = () => [{ rel: "stylesheet", href: styles }];
|
export const links: LinksFunction = () => [{ rel: "stylesheet", href: styles }];
|
||||||
|
|
||||||
@ -50,6 +50,8 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|||||||
const toastMessage = session.get("toastMessage") as ToastMessage;
|
const toastMessage = session.get("toastMessage") as ToastMessage;
|
||||||
const { getTheme } = await themeSessionResolver(request);
|
const { getTheme } = await themeSessionResolver(request);
|
||||||
|
|
||||||
|
await initNeo4jSchemaOnce();
|
||||||
|
|
||||||
const posthogProjectKey = env.POSTHOG_PROJECT_KEY;
|
const posthogProjectKey = env.POSTHOG_PROJECT_KEY;
|
||||||
|
|
||||||
return typedjson(
|
return typedjson(
|
||||||
@ -126,7 +128,6 @@ function App() {
|
|||||||
<ScrollRestoration />
|
<ScrollRestoration />
|
||||||
|
|
||||||
<Scripts />
|
<Scripts />
|
||||||
<LiveReload />
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -1,15 +1,12 @@
|
|||||||
import { redirect, type MetaFunction } from "@remix-run/node";
|
import { redirect, type MetaFunction } from "@remix-run/node";
|
||||||
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
|
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
|
||||||
import { typedjson } from "remix-typedjson";
|
|
||||||
import { AppSidebar } from "~/components/sidebar/app-sidebar";
|
|
||||||
import { SidebarInset, SidebarProvider } from "~/components/ui/sidebar";
|
|
||||||
import { clearRedirectTo, commitSession } from "~/services/redirectTo.server";
|
|
||||||
|
|
||||||
import { requireUser, requireWorkpace } from "~/services/session.server";
|
import { requireUser } from "~/services/session.server";
|
||||||
import { confirmBasicDetailsPath } from "~/utils/pathBuilder";
|
import { confirmBasicDetailsPath, dashboardPath } from "~/utils/pathBuilder";
|
||||||
|
|
||||||
export const meta: MetaFunction = () => {
|
export const meta: MetaFunction = () => {
|
||||||
return [
|
return [
|
||||||
{ title: "C.O.R.E" },
|
{ title: "C.O.R.E." },
|
||||||
{ name: "description", content: "Welcome to C.O.R.E!" },
|
{ name: "description", content: "Welcome to C.O.R.E!" },
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@ -20,41 +17,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|||||||
//you have to confirm basic details before you can do anything
|
//you have to confirm basic details before you can do anything
|
||||||
if (!user.confirmedBasicDetails) {
|
if (!user.confirmedBasicDetails) {
|
||||||
return redirect(confirmBasicDetailsPath());
|
return redirect(confirmBasicDetailsPath());
|
||||||
|
} else {
|
||||||
|
return redirect(dashboardPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
const workspace = await requireWorkpace(request);
|
|
||||||
|
|
||||||
return typedjson(
|
|
||||||
{
|
|
||||||
workspace,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Set-Cookie": await commitSession(await clearRedirectTo(request)),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
return (
|
return <p>Loading</p>;
|
||||||
<SidebarProvider
|
|
||||||
style={
|
|
||||||
{
|
|
||||||
"--sidebar-width": "calc(var(--spacing) * 54)",
|
|
||||||
"--header-height": "calc(var(--spacing) * 12)",
|
|
||||||
background: "var(--background)",
|
|
||||||
} as React.CSSProperties
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<AppSidebar variant="inset" />
|
|
||||||
<SidebarInset className="bg-background-2">
|
|
||||||
<div className="flex flex-1 flex-col">
|
|
||||||
<div className="@container/main flex flex-1 flex-col gap-2">
|
|
||||||
<div className="flex flex-col gap-4 py-4 md:gap-6 md:py-6"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</SidebarInset>
|
|
||||||
</SidebarProvider>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,6 @@ export let loader: LoaderFunction = async ({ request }) => {
|
|||||||
try {
|
try {
|
||||||
// call authenticate as usual, in successRedirect use returnTo or a fallback
|
// call authenticate as usual, in successRedirect use returnTo or a fallback
|
||||||
const rf = await authenticator.authenticate("google", request);
|
const rf = await authenticator.authenticate("google", request);
|
||||||
console.log(rf);
|
|
||||||
|
|
||||||
return rf;
|
return rf;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -68,12 +68,8 @@ export default function ConfirmBasicDetails() {
|
|||||||
lastSubmission: lastSubmission as any,
|
lastSubmission: lastSubmission as any,
|
||||||
constraint: getFieldsetConstraint(schema),
|
constraint: getFieldsetConstraint(schema),
|
||||||
onValidate({ formData }) {
|
onValidate({ formData }) {
|
||||||
console.log(parse(formData, { schema }));
|
|
||||||
return parse(formData, { schema });
|
return parse(formData, { schema });
|
||||||
},
|
},
|
||||||
onSubmit(event, context) {
|
|
||||||
console.log(event);
|
|
||||||
},
|
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
integrations: [],
|
integrations: [],
|
||||||
},
|
},
|
||||||
|
|||||||
95
apps/webapp/app/routes/home.dashboard.tsx
Normal file
95
apps/webapp/app/routes/home.dashboard.tsx
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
import { useLocalCommonState } from "~/hooks/use-local-state";
|
||||||
|
import {
|
||||||
|
ResizableHandle,
|
||||||
|
ResizablePanel,
|
||||||
|
ResizablePanelGroup,
|
||||||
|
} from "~/components/ui/resizable";
|
||||||
|
import { parse } from "@conform-to/zod";
|
||||||
|
import { json } from "@remix-run/node";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "~/components/ui/tabs";
|
||||||
|
import { Ingest } from "~/components/dashboard/ingest";
|
||||||
|
import {
|
||||||
|
type LoaderFunctionArgs,
|
||||||
|
type ActionFunctionArgs,
|
||||||
|
} from "@remix-run/server-runtime";
|
||||||
|
import { requireUserId } from "~/services/session.server";
|
||||||
|
import { useActionData } from "@remix-run/react";
|
||||||
|
import { addToQueue, IngestBodyRequest } from "~/lib/ingest.server";
|
||||||
|
import { getNodeLinks } from "~/lib/neo4j.server";
|
||||||
|
import { useTypedLoaderData } from "remix-typedjson";
|
||||||
|
|
||||||
|
import { GraphVisualization } from "~/components/graph/graph-visualization";
|
||||||
|
|
||||||
|
export async function action({ request }: ActionFunctionArgs) {
|
||||||
|
const userId = await requireUserId(request);
|
||||||
|
|
||||||
|
const formData = await request.formData();
|
||||||
|
const submission = parse(formData, { schema: IngestBodyRequest });
|
||||||
|
|
||||||
|
if (!submission.value || submission.intent !== "submit") {
|
||||||
|
return json(submission);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await addToQueue(submission.value, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function loader({ request }: LoaderFunctionArgs) {
|
||||||
|
const userId = await requireUserId(request);
|
||||||
|
const nodeLinks = await getNodeLinks(userId);
|
||||||
|
|
||||||
|
return nodeLinks;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Dashboard() {
|
||||||
|
const nodeLinks = useTypedLoaderData<typeof loader>();
|
||||||
|
|
||||||
|
const actionData = useActionData<typeof action>();
|
||||||
|
|
||||||
|
const [size, setSize] = useState(15);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ResizablePanelGroup direction="horizontal">
|
||||||
|
<ResizablePanel
|
||||||
|
collapsible={false}
|
||||||
|
className="h-[calc(100vh_-_20px)] overflow-hidden rounded-md"
|
||||||
|
order={1}
|
||||||
|
id="home"
|
||||||
|
>
|
||||||
|
<div className="home flex h-full flex-col overflow-y-auto p-3">
|
||||||
|
<h2 className="text-xl"> Graph </h2>
|
||||||
|
<p className="text-muted-foreground"> Your memory graph </p>
|
||||||
|
|
||||||
|
<div className="bg-background-3 mt-2 grow rounded">
|
||||||
|
{typeof window !== "undefined" && (
|
||||||
|
<GraphVisualization triplets={nodeLinks} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ResizablePanel>
|
||||||
|
<ResizableHandle className="bg-border w-[0.5px]" />
|
||||||
|
|
||||||
|
<ResizablePanel
|
||||||
|
className="rounded-md"
|
||||||
|
collapsible={false}
|
||||||
|
maxSize={50}
|
||||||
|
minSize={25}
|
||||||
|
defaultSize={size}
|
||||||
|
onResize={(size) => setSize(size)}
|
||||||
|
order={2}
|
||||||
|
id="rightScreen"
|
||||||
|
>
|
||||||
|
<Tabs defaultValue="ingest" className="p-3 text-base">
|
||||||
|
<TabsList>
|
||||||
|
<TabsTrigger value="ingest">Add</TabsTrigger>
|
||||||
|
<TabsTrigger value="retrieve">Retrieve</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
|
<TabsContent value="ingest">
|
||||||
|
<Ingest actionData={actionData} />
|
||||||
|
</TabsContent>
|
||||||
|
</Tabs>
|
||||||
|
</ResizablePanel>
|
||||||
|
</ResizablePanelGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
58
apps/webapp/app/routes/home.tsx
Normal file
58
apps/webapp/app/routes/home.tsx
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import {
|
||||||
|
type ActionFunctionArgs,
|
||||||
|
type LoaderFunctionArgs,
|
||||||
|
} from "@remix-run/server-runtime";
|
||||||
|
import {
|
||||||
|
requireUser,
|
||||||
|
requireUserId,
|
||||||
|
requireWorkpace,
|
||||||
|
} from "~/services/session.server";
|
||||||
|
|
||||||
|
import { Outlet, useActionData } from "@remix-run/react";
|
||||||
|
import { typedjson } from "remix-typedjson";
|
||||||
|
import { clearRedirectTo, commitSession } from "~/services/redirectTo.server";
|
||||||
|
|
||||||
|
import { AppSidebar } from "~/components/sidebar/app-sidebar";
|
||||||
|
import { SidebarInset, SidebarProvider } from "~/components/ui/sidebar";
|
||||||
|
|
||||||
|
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||||
|
const user = await requireUser(request);
|
||||||
|
const workspace = await requireWorkpace(request);
|
||||||
|
|
||||||
|
return typedjson(
|
||||||
|
{
|
||||||
|
user,
|
||||||
|
workspace,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Set-Cookie": await commitSession(await clearRedirectTo(request)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
return (
|
||||||
|
<SidebarProvider
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
"--sidebar-width": "calc(var(--spacing) * 54)",
|
||||||
|
"--header-height": "calc(var(--spacing) * 12)",
|
||||||
|
background: "var(--background)",
|
||||||
|
} as React.CSSProperties
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<AppSidebar variant="inset" />
|
||||||
|
<SidebarInset className="bg-background-2">
|
||||||
|
<div className="flex flex-1 flex-col">
|
||||||
|
<div className="@container/main flex flex-1 flex-col gap-2">
|
||||||
|
<div className="flex h-full flex-col">
|
||||||
|
<Outlet />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</SidebarInset>
|
||||||
|
</SidebarProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,20 +1,7 @@
|
|||||||
import { EpisodeType } from "@core/types";
|
import { json } from "@remix-run/node";
|
||||||
import { json, LoaderFunctionArgs } from "@remix-run/node";
|
|
||||||
import { z } from "zod";
|
|
||||||
import { createActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
|
|
||||||
import { getUserQueue } from "~/lib/ingest.queue";
|
|
||||||
import { prisma } from "~/db.server";
|
|
||||||
import { IngestionStatus } from "@core/database";
|
|
||||||
|
|
||||||
export const IngestBodyRequest = z.object({
|
import { createActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
|
||||||
name: z.string(),
|
import { addToQueue, IngestBodyRequest } from "~/lib/ingest.server";
|
||||||
episodeBody: z.string(),
|
|
||||||
referenceTime: z.string(),
|
|
||||||
type: z.enum([EpisodeType.Conversation, EpisodeType.Text]), // Assuming these are the EpisodeType values
|
|
||||||
source: z.string(),
|
|
||||||
spaceId: z.string().optional(),
|
|
||||||
sessionId: z.string().optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const { action, loader } = createActionApiRoute(
|
const { action, loader } = createActionApiRoute(
|
||||||
{
|
{
|
||||||
@ -25,32 +12,9 @@ const { action, loader } = createActionApiRoute(
|
|||||||
},
|
},
|
||||||
corsStrategy: "all",
|
corsStrategy: "all",
|
||||||
},
|
},
|
||||||
async ({ body, headers, params, authentication }) => {
|
async ({ body, authentication }) => {
|
||||||
const queuePersist = await prisma.ingestionQueue.create({
|
const response = addToQueue(body, authentication.userId);
|
||||||
data: {
|
return json({ ...response });
|
||||||
spaceId: body.spaceId,
|
|
||||||
data: body,
|
|
||||||
status: IngestionStatus.PENDING,
|
|
||||||
priority: 1,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const ingestionQueue = getUserQueue(authentication.userId);
|
|
||||||
|
|
||||||
await ingestionQueue.add(
|
|
||||||
`ingest-user-${authentication.userId}`, // 👈 unique name per user
|
|
||||||
{
|
|
||||||
queueId: queuePersist.id,
|
|
||||||
spaceId: body.spaceId,
|
|
||||||
userId: authentication.userId,
|
|
||||||
body,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
jobId: `${authentication.userId}-${Date.now()}`, // unique per job but grouped under user
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return json({});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,10 @@ const { action, loader } = createActionApiRoute(
|
|||||||
corsStrategy: "all",
|
corsStrategy: "all",
|
||||||
},
|
},
|
||||||
async ({ body, authentication }) => {
|
async ({ body, authentication }) => {
|
||||||
const results = await searchService.search(body.query, authentication.userId);
|
const results = await searchService.search(
|
||||||
|
body.query,
|
||||||
|
authentication.userId,
|
||||||
|
);
|
||||||
return json(results);
|
return json(results);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -24,10 +24,13 @@ export const apiRateLimiter = authorizationRateLimitMiddleware({
|
|||||||
stale: 60_000 * 20, // Date is stale after 20 minutes
|
stale: 60_000 * 20, // Date is stale after 20 minutes
|
||||||
},
|
},
|
||||||
limiterConfigOverride: async (authorizationValue) => {
|
limiterConfigOverride: async (authorizationValue) => {
|
||||||
const authenticatedEnv = await authenticateAuthorizationHeader(authorizationValue, {
|
const authenticatedEnv = await authenticateAuthorizationHeader(
|
||||||
allowPublicKey: true,
|
authorizationValue,
|
||||||
allowJWT: true,
|
{
|
||||||
});
|
allowPublicKey: true,
|
||||||
|
allowJWT: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (!authenticatedEnv || !authenticatedEnv.ok) {
|
if (!authenticatedEnv || !authenticatedEnv.ok) {
|
||||||
return;
|
return;
|
||||||
@ -61,4 +64,6 @@ export const apiRateLimiter = authorizationRateLimitMiddleware({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export type RateLimitMiddleware = ReturnType<typeof authorizationRateLimitMiddleware>;
|
export type RateLimitMiddleware = ReturnType<
|
||||||
|
typeof authorizationRateLimitMiddleware
|
||||||
|
>;
|
||||||
|
|||||||
@ -25,8 +25,6 @@ export function addGoogleStrategy(
|
|||||||
throw new Error("Google login requires an email address");
|
throw new Error("Google login requires an email address");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(tokens);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.debug("Google login", {
|
logger.debug("Google login", {
|
||||||
emails,
|
emails,
|
||||||
|
|||||||
@ -5,7 +5,6 @@ export async function saveEpisode(episode: EpisodicNode): Promise<string> {
|
|||||||
const query = `
|
const query = `
|
||||||
MERGE (e:Episode {uuid: $uuid})
|
MERGE (e:Episode {uuid: $uuid})
|
||||||
ON CREATE SET
|
ON CREATE SET
|
||||||
e.name = $name,
|
|
||||||
e.content = $content,
|
e.content = $content,
|
||||||
e.contentEmbedding = $contentEmbedding,
|
e.contentEmbedding = $contentEmbedding,
|
||||||
e.type = $type,
|
e.type = $type,
|
||||||
@ -17,7 +16,6 @@ export async function saveEpisode(episode: EpisodicNode): Promise<string> {
|
|||||||
e.space = $space,
|
e.space = $space,
|
||||||
e.sessionId = $sessionId
|
e.sessionId = $sessionId
|
||||||
ON MATCH SET
|
ON MATCH SET
|
||||||
e.name = $name,
|
|
||||||
e.content = $content,
|
e.content = $content,
|
||||||
e.contentEmbedding = $contentEmbedding,
|
e.contentEmbedding = $contentEmbedding,
|
||||||
e.type = $type,
|
e.type = $type,
|
||||||
@ -31,7 +29,6 @@ export async function saveEpisode(episode: EpisodicNode): Promise<string> {
|
|||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
uuid: episode.uuid,
|
uuid: episode.uuid,
|
||||||
name: episode.name,
|
|
||||||
content: episode.content,
|
content: episode.content,
|
||||||
source: episode.source,
|
source: episode.source,
|
||||||
type: episode.type,
|
type: episode.type,
|
||||||
@ -61,7 +58,6 @@ export async function getEpisode(uuid: string): Promise<EpisodicNode | null> {
|
|||||||
const episode = result[0].get("e").properties;
|
const episode = result[0].get("e").properties;
|
||||||
return {
|
return {
|
||||||
uuid: episode.uuid,
|
uuid: episode.uuid,
|
||||||
name: episode.name,
|
|
||||||
content: episode.content,
|
content: episode.content,
|
||||||
contentEmbedding: episode.contentEmbedding,
|
contentEmbedding: episode.contentEmbedding,
|
||||||
type: episode.type,
|
type: episode.type,
|
||||||
@ -115,7 +111,6 @@ export async function getRecentEpisodes(params: {
|
|||||||
const episode = record.get("e").properties;
|
const episode = record.get("e").properties;
|
||||||
return {
|
return {
|
||||||
uuid: episode.uuid,
|
uuid: episode.uuid,
|
||||||
name: episode.name,
|
|
||||||
content: episode.content,
|
content: episode.content,
|
||||||
contentEmbedding: episode.contentEmbedding,
|
contentEmbedding: episode.contentEmbedding,
|
||||||
type: episode.type,
|
type: episode.type,
|
||||||
|
|||||||
@ -266,7 +266,6 @@ export async function getTripleForStatement({
|
|||||||
// Episode might be null
|
// Episode might be null
|
||||||
const provenance: EpisodicNode = {
|
const provenance: EpisodicNode = {
|
||||||
uuid: episodeProps.uuid,
|
uuid: episodeProps.uuid,
|
||||||
name: episodeProps.name,
|
|
||||||
content: episodeProps.content,
|
content: episodeProps.content,
|
||||||
source: episodeProps.source,
|
source: episodeProps.source,
|
||||||
type: episodeProps.type,
|
type: episodeProps.type,
|
||||||
|
|||||||
@ -64,7 +64,6 @@ export class KnowledgeGraphService {
|
|||||||
// Step 2: Episode Creation - Create or retrieve the episode
|
// Step 2: Episode Creation - Create or retrieve the episode
|
||||||
const episode: EpisodicNode = {
|
const episode: EpisodicNode = {
|
||||||
uuid: crypto.randomUUID(),
|
uuid: crypto.randomUUID(),
|
||||||
name: params.name,
|
|
||||||
content: params.episodeBody,
|
content: params.episodeBody,
|
||||||
source: params.source,
|
source: params.source,
|
||||||
type: params.type || EpisodeType.Text,
|
type: params.type || EpisodeType.Text,
|
||||||
@ -115,7 +114,7 @@ export class KnowledgeGraphService {
|
|||||||
return {
|
return {
|
||||||
episodeUuid: episode.uuid,
|
episodeUuid: episode.uuid,
|
||||||
// nodesCreated: hydratedNodes.length,
|
// nodesCreated: hydratedNodes.length,
|
||||||
// statementsCreated: resolvedStatements.length,
|
statementsCreated: resolvedStatements.length,
|
||||||
processingTimeMs,
|
processingTimeMs,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { openai } from "@ai-sdk/openai";
|
import { openai } from "@ai-sdk/openai";
|
||||||
import type { StatementNode } from "@recall/types";
|
import type { StatementNode } from "@core/types";
|
||||||
import { embed } from "ai";
|
import { embed } from "ai";
|
||||||
import { logger } from "./logger.service";
|
import { logger } from "./logger.service";
|
||||||
import { applyCrossEncoderReranking, applyWeightedRRF } from "./search/rerank";
|
import { applyCrossEncoderReranking, applyWeightedRRF } from "./search/rerank";
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { LLMModelEnum, type StatementNode } from "@recall/types";
|
import { LLMModelEnum, type StatementNode } from "@core/types";
|
||||||
import { combineAndDeduplicateStatements } from "./utils";
|
import { combineAndDeduplicateStatements } from "./utils";
|
||||||
import { type CoreMessage } from "ai";
|
import { type CoreMessage } from "ai";
|
||||||
import { makeModelCall } from "~/lib/model.server";
|
import { makeModelCall } from "~/lib/model.server";
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { EntityNode, StatementNode } from "@recall/types";
|
import type { EntityNode, StatementNode } from "@core/types";
|
||||||
import type { SearchOptions } from "../search.server";
|
import type { SearchOptions } from "../search.server";
|
||||||
import type { Embedding } from "ai";
|
import type { Embedding } from "ai";
|
||||||
import { logger } from "../logger.service";
|
import { logger } from "../logger.service";
|
||||||
@ -35,8 +35,7 @@ export async function performBM25Search(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const records = await runQuery(cypher, params);
|
const records = await runQuery(cypher, params);
|
||||||
// return records.map((record) => record.get("s").properties as StatementNode);
|
return records.map((record) => record.get("s").properties as StatementNode);
|
||||||
return [];
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("BM25 search error:", { error });
|
logger.error("BM25 search error:", { error });
|
||||||
return [];
|
return [];
|
||||||
@ -81,7 +80,7 @@ export async function performVectorSearch(
|
|||||||
WHERE
|
WHERE
|
||||||
s.validAt <= $validAt
|
s.validAt <= $validAt
|
||||||
AND (s.invalidAt IS NULL OR s.invalidAt > $validAt)
|
AND (s.invalidAt IS NULL OR s.invalidAt > $validAt)
|
||||||
AND (s.userId = $userId OR s.isPublic = true)
|
AND (s.userId = $userId)
|
||||||
WITH s, vector.similarity.cosine(s.factEmbedding, $embedding) AS score
|
WITH s, vector.similarity.cosine(s.factEmbedding, $embedding) AS score
|
||||||
WHERE score > 0.7
|
WHERE score > 0.7
|
||||||
RETURN s, score
|
RETURN s, score
|
||||||
@ -95,8 +94,7 @@ export async function performVectorSearch(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const records = await runQuery(cypher, params);
|
const records = await runQuery(cypher, params);
|
||||||
// return records.map((record) => record.get("s").properties as StatementNode);
|
return records.map((record) => record.get("s").properties as StatementNode);
|
||||||
return [];
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("Vector search error:", { error });
|
logger.error("Vector search error:", { error });
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@ -2,6 +2,14 @@ export function confirmBasicDetailsPath() {
|
|||||||
return `/confirm-basic-details`;
|
return `/confirm-basic-details`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function homePath() {
|
||||||
|
return `/home`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dashboardPath() {
|
||||||
|
return `/home/dashboard`;
|
||||||
|
}
|
||||||
|
|
||||||
export function rootPath() {
|
export function rootPath() {
|
||||||
return `/`;
|
return `/`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,10 @@ export const GENERAL_NODE_TYPES = {
|
|||||||
name: "Event",
|
name: "Event",
|
||||||
description: "A meeting, deadline, or any time-based occurrence",
|
description: "A meeting, deadline, or any time-based occurrence",
|
||||||
},
|
},
|
||||||
|
ALIAS: {
|
||||||
|
name: "Alias",
|
||||||
|
description: "An alternative name or identifier for an entity",
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// App-specific node types
|
// App-specific node types
|
||||||
@ -54,7 +54,6 @@
|
|||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"d3": "^7.9.0",
|
"d3": "^7.9.0",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
|
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.1",
|
||||||
"ioredis": "^5.6.1",
|
"ioredis": "^5.6.1",
|
||||||
"isbot": "^4.1.0",
|
"isbot": "^4.1.0",
|
||||||
@ -72,6 +71,7 @@
|
|||||||
"remix-themes": "^1.3.1",
|
"remix-themes": "^1.3.1",
|
||||||
"remix-typedjson": "0.3.1",
|
"remix-typedjson": "0.3.1",
|
||||||
"remix-utils": "^7.7.0",
|
"remix-utils": "^7.7.0",
|
||||||
|
"react-resizable-panels": "^1.0.9",
|
||||||
"tailwind-merge": "^2.6.0",
|
"tailwind-merge": "^2.6.0",
|
||||||
"tailwind-scrollbar-hide": "^2.0.0",
|
"tailwind-scrollbar-hide": "^2.0.0",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
|
|||||||
@ -24,8 +24,8 @@ export default defineConfig({
|
|||||||
tsconfigPaths(),
|
tsconfigPaths(),
|
||||||
],
|
],
|
||||||
server: {
|
server: {
|
||||||
|
middlewareMode: true,
|
||||||
allowedHosts: true,
|
allowedHosts: true,
|
||||||
port: 3033,
|
|
||||||
},
|
},
|
||||||
ssr: {
|
ssr: {
|
||||||
noExternal: ["helix-ts"],
|
noExternal: ["helix-ts"],
|
||||||
|
|||||||
@ -9,7 +9,6 @@ export enum EpisodeType {
|
|||||||
*/
|
*/
|
||||||
export interface EpisodicNode {
|
export interface EpisodicNode {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
|
||||||
content: string;
|
content: string;
|
||||||
contentEmbedding?: number[];
|
contentEmbedding?: number[];
|
||||||
type: string;
|
type: string;
|
||||||
|
|||||||
14
pnpm-lock.yaml
generated
14
pnpm-lock.yaml
generated
@ -195,6 +195,9 @@ importers:
|
|||||||
react-dom:
|
react-dom:
|
||||||
specifier: ^18.2.0
|
specifier: ^18.2.0
|
||||||
version: 18.3.1(react@18.3.1)
|
version: 18.3.1(react@18.3.1)
|
||||||
|
react-resizable-panels:
|
||||||
|
specifier: ^1.0.9
|
||||||
|
version: 1.0.10(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
remix-auth:
|
remix-auth:
|
||||||
specifier: ^4.2.0
|
specifier: ^4.2.0
|
||||||
version: 4.2.0
|
version: 4.2.0
|
||||||
@ -5656,6 +5659,12 @@ packages:
|
|||||||
'@types/react':
|
'@types/react':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
react-resizable-panels@1.0.10:
|
||||||
|
resolution: {integrity: sha512-0+g0CNqregkuocr+Mi+e6wgWVARnKTYIX3U1QK7GlkLQKCmbymZakx80YGwcRO7HNnKJTQ5v38HlBos/cGxWvg==}
|
||||||
|
peerDependencies:
|
||||||
|
react: ^16.14.0 || ^17.0.0 || ^18.0.0
|
||||||
|
react-dom: ^16.14.0 || ^17.0.0 || ^18.0.0
|
||||||
|
|
||||||
react-router-dom@6.30.0:
|
react-router-dom@6.30.0:
|
||||||
resolution: {integrity: sha512-x30B78HV5tFk8ex0ITwzC9TTZMua4jGyA9IUlH1JLQYQTFyxr/ZxwOJq7evg1JX1qGVUcvhsmQSKdPncQrjTgA==}
|
resolution: {integrity: sha512-x30B78HV5tFk8ex0ITwzC9TTZMua4jGyA9IUlH1JLQYQTFyxr/ZxwOJq7evg1JX1qGVUcvhsmQSKdPncQrjTgA==}
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=14.0.0'}
|
||||||
@ -12629,6 +12638,11 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@types/react': 18.3.23
|
'@types/react': 18.3.23
|
||||||
|
|
||||||
|
react-resizable-panels@1.0.10(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||||
|
dependencies:
|
||||||
|
react: 18.3.1
|
||||||
|
react-dom: 18.3.1(react@18.3.1)
|
||||||
|
|
||||||
react-router-dom@6.30.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
react-router-dom@6.30.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@remix-run/router': 1.23.0
|
'@remix-run/router': 1.23.0
|
||||||
|
|||||||
17
turbo.json
17
turbo.json
@ -3,18 +3,19 @@
|
|||||||
"ui": "tui",
|
"ui": "tui",
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"build": {
|
"build": {
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": [ "^build" ],
|
||||||
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
"inputs": [ "$TURBO_DEFAULT$", ".env*" ],
|
||||||
"outputs": ["dist/**", "public/build/**", "build/**", "app/styles/tailwind.css", ".cache"]
|
"outputs": [ "dist/**", "public/build/**", "build/**", "app/styles/tailwind.css", ".cache" ]
|
||||||
},
|
},
|
||||||
"lint": {
|
"lint": {
|
||||||
"dependsOn": ["^lint"]
|
"dependsOn": [ "^lint" ]
|
||||||
},
|
},
|
||||||
"check-types": {
|
"check-types": {
|
||||||
"dependsOn": ["^check-types"]
|
"dependsOn": [ "^check-types" ]
|
||||||
},
|
},
|
||||||
"dev": {
|
"dev": {
|
||||||
"cache": false
|
"cache": false,
|
||||||
|
"interactive": true
|
||||||
},
|
},
|
||||||
"db:generate": {
|
"db:generate": {
|
||||||
"cache": false
|
"cache": false
|
||||||
@ -30,10 +31,10 @@
|
|||||||
"cache": false
|
"cache": false
|
||||||
},
|
},
|
||||||
"generate": {
|
"generate": {
|
||||||
"dependsOn": ["^generate"]
|
"dependsOn": [ "^generate" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalDependencies": [".env"],
|
"globalDependencies": [ ".env" ],
|
||||||
"globalEnv": [
|
"globalEnv": [
|
||||||
"NODE_ENV",
|
"NODE_ENV",
|
||||||
"REMIX_APP_PORT",
|
"REMIX_APP_PORT",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user