mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-14 23:21:20 +00:00
fixed eslint
This commit is contained in:
parent
46d97b624c
commit
4997579683
3 changed files with 47 additions and 47 deletions
|
|
@ -46,18 +46,18 @@ npx convex env set SUPERMEMORY_API_KEY your-api-key
|
|||
<Tabs>
|
||||
<Tab title="React Hooks">
|
||||
```tsx
|
||||
import { addMemory, searchMemories } from "@supermemory/convex-component/react";
|
||||
import { useAddMemory, useSupermemorySearch } from "@supermemory/convex-component/react";
|
||||
|
||||
function ChatApp() {
|
||||
const add = addMemory();
|
||||
const { results, isLoading, search } = searchMemories({
|
||||
const addMemory = useAddMemory();
|
||||
const { results, isLoading, search } = useSupermemorySearch({
|
||||
q: "user preferences",
|
||||
containerTag: "user_123",
|
||||
searchMode: "hybrid"
|
||||
});
|
||||
|
||||
const handleSendMessage = async (message: string) => {
|
||||
await add({
|
||||
await addMemory({
|
||||
content: message,
|
||||
containerTag: "user_123"
|
||||
});
|
||||
|
|
@ -112,14 +112,14 @@ npx convex env set SUPERMEMORY_API_KEY your-api-key
|
|||
|
||||
## React Hooks
|
||||
|
||||
### `addMemory()`
|
||||
### `useAddMemory()`
|
||||
|
||||
Add memories to Supermemory through a Convex action.
|
||||
Hook to add memories to Supermemory through a Convex action.
|
||||
|
||||
```tsx
|
||||
const add = addMemory();
|
||||
const addMemory = useAddMemory();
|
||||
|
||||
await add({
|
||||
await addMemory({
|
||||
content: "Meeting notes from Q1 planning",
|
||||
containerTag: "user_123",
|
||||
customId: "meeting_2024_q1",
|
||||
|
|
@ -127,12 +127,12 @@ await add({
|
|||
});
|
||||
```
|
||||
|
||||
### `searchMemories(args)`
|
||||
### `useSupermemorySearch(args)`
|
||||
|
||||
Reactive semantic search with loading and error states.
|
||||
Hook for reactive semantic search with loading and error states.
|
||||
|
||||
```tsx
|
||||
const { results, isLoading, error, search } = searchMemories({
|
||||
const { results, isLoading, error, search } = useSupermemorySearch({
|
||||
q: "project updates",
|
||||
containerTag: "user_123",
|
||||
searchMode: "hybrid",
|
||||
|
|
@ -143,12 +143,12 @@ const { results, isLoading, error, search } = searchMemories({
|
|||
await search({ q: "new query", containerTag: "user_123" });
|
||||
```
|
||||
|
||||
### `getProfile(args)`
|
||||
### `useSupermemoryProfile(args)`
|
||||
|
||||
Get user profile with static and dynamic facts.
|
||||
Hook to get user profile with static and dynamic facts.
|
||||
|
||||
```tsx
|
||||
const { profile, isLoading, refresh } = getProfile({
|
||||
const { profile, isLoading, refresh } = useSupermemoryProfile({
|
||||
containerTag: "user_123",
|
||||
q: "recent preferences"
|
||||
});
|
||||
|
|
@ -157,12 +157,12 @@ const { profile, isLoading, refresh } = getProfile({
|
|||
await refresh();
|
||||
```
|
||||
|
||||
### `listMemories(args)`
|
||||
### `useMemories(args)`
|
||||
|
||||
List memories by container tag and source.
|
||||
Hook to list memories by container tag and source.
|
||||
|
||||
```tsx
|
||||
const memories = listMemories({
|
||||
const memories = useMemories({
|
||||
containerTag: "user_123",
|
||||
source: "manual", // "chat" | "document" | "manual"
|
||||
limit: 50
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ npx convex env set SUPERMEMORY_API_KEY your-api-key
|
|||
#### React/Next.js with Hooks
|
||||
|
||||
```tsx
|
||||
import { addMemory, searchMemories } from "@supermemory/convex-component/react";
|
||||
import { useAddMemory, useSupermemorySearch } from "@supermemory/convex-component/react";
|
||||
|
||||
function ChatApp() {
|
||||
const add = addMemory();
|
||||
const { results, isLoading, search } = searchMemories({
|
||||
const addMemory = useAddMemory();
|
||||
const { results, isLoading, search } = useSupermemorySearch({
|
||||
q: "user preferences",
|
||||
containerTag: "user_123",
|
||||
searchMode: "hybrid"
|
||||
|
|
@ -66,7 +66,7 @@ function ChatApp() {
|
|||
|
||||
const handleSendMessage = async (message: string) => {
|
||||
// Add to memory
|
||||
await add({
|
||||
await addMemory({
|
||||
content: `User: ${message}`,
|
||||
containerTag: "user_123"
|
||||
});
|
||||
|
|
@ -127,14 +127,14 @@ console.log("Dynamic context:", profile.profile.dynamic);
|
|||
|
||||
### React Hooks
|
||||
|
||||
#### `addMemory(componentPath?)`
|
||||
#### `useAddMemory(componentPath?)`
|
||||
|
||||
Add memories to Supermemory.
|
||||
Hook to add memories to Supermemory.
|
||||
|
||||
```tsx
|
||||
const add = addMemory();
|
||||
const addMemory = useAddMemory();
|
||||
|
||||
await add({
|
||||
await addMemory({
|
||||
content: "Meeting notes from Q1 planning",
|
||||
containerTag: "user_123",
|
||||
customId: "meeting_2024_q1",
|
||||
|
|
@ -142,12 +142,12 @@ await add({
|
|||
});
|
||||
```
|
||||
|
||||
#### `searchMemories(args, componentPath?)`
|
||||
#### `useSupermemorySearch(args, componentPath?)`
|
||||
|
||||
Search Supermemory with reactive results.
|
||||
Hook for reactive semantic search with loading and error states.
|
||||
|
||||
```tsx
|
||||
const { results, isLoading, error, search } = searchMemories({
|
||||
const { results, isLoading, error, search } = useSupermemorySearch({
|
||||
q: "project updates",
|
||||
containerTag: "user_123",
|
||||
searchMode: "hybrid",
|
||||
|
|
@ -158,12 +158,12 @@ const { results, isLoading, error, search } = searchMemories({
|
|||
await search({ q: "new query", containerTag: "user_123" });
|
||||
```
|
||||
|
||||
#### `getProfile(args, componentPath?)`
|
||||
#### `useSupermemoryProfile(args, componentPath?)`
|
||||
|
||||
Get user profile with context.
|
||||
Hook to get user profile with static and dynamic facts.
|
||||
|
||||
```tsx
|
||||
const { profile, isLoading, refresh } = getProfile({
|
||||
const { profile, isLoading, refresh } = useSupermemoryProfile({
|
||||
containerTag: "user_123",
|
||||
q: "recent preferences"
|
||||
});
|
||||
|
|
@ -172,12 +172,12 @@ const { profile, isLoading, refresh } = getProfile({
|
|||
await refresh();
|
||||
```
|
||||
|
||||
#### `listMemories(args, componentPath?)`
|
||||
#### `useMemories(args, componentPath?)`
|
||||
|
||||
List memories reactively. Includes content and extracted memories.
|
||||
Hook to list memories reactively. Includes content and extracted memories.
|
||||
|
||||
```tsx
|
||||
const memories = listMemories({ containerTag: "user_123", limit: 20 });
|
||||
const memories = useMemories({ containerTag: "user_123", limit: 20 });
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -20,17 +20,17 @@ import type {
|
|||
*/
|
||||
|
||||
/**
|
||||
* Add memories to Supermemory
|
||||
* Hook to add memories to Supermemory
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* function ChatApp() {
|
||||
* const add = addMemory();
|
||||
* await add({ content: "Hello", containerTag: "user_123" });
|
||||
* const addMemory = useAddMemory();
|
||||
* await addMemory({ content: "Hello", containerTag: "user_123" });
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function addMemory(componentPath = "supermemory") {
|
||||
export function useAddMemory(componentPath = "supermemory") {
|
||||
const action =
|
||||
`${componentPath}:actions.add` as unknown as FunctionReference<"action">
|
||||
const addAction = useAction(action)
|
||||
|
|
@ -44,16 +44,16 @@ export function addMemory(componentPath = "supermemory") {
|
|||
}
|
||||
|
||||
/**
|
||||
* Search Supermemory with reactive results
|
||||
* Hook for reactive semantic search with loading and error states
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* const { results, isLoading, search } = searchMemories({
|
||||
* const { results, isLoading, search } = useSupermemorySearch({
|
||||
* q: "typescript", containerTag: "user_123"
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function searchMemories(
|
||||
export function useSupermemorySearch(
|
||||
args: SearchMemoriesArgs | null,
|
||||
componentPath = "supermemory",
|
||||
) {
|
||||
|
|
@ -88,16 +88,16 @@ export function searchMemories(
|
|||
}
|
||||
|
||||
/**
|
||||
* Get user profile
|
||||
* Hook to get user profile with static and dynamic facts
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* const { profile, isLoading, refresh } = getProfile({
|
||||
* const { profile, isLoading, refresh } = useSupermemoryProfile({
|
||||
* containerTag: "user_123"
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function getProfile(
|
||||
export function useSupermemoryProfile(
|
||||
args: ProfileArgs | null,
|
||||
componentPath = "supermemory",
|
||||
) {
|
||||
|
|
@ -132,15 +132,15 @@ export function getProfile(
|
|||
}
|
||||
|
||||
/**
|
||||
* List memories reactively
|
||||
* Hook to list memories reactively
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* const memories = listMemories({ containerTag: "user_123" });
|
||||
* const memories = useMemories({ containerTag: "user_123" });
|
||||
* // memories includes content + extractedMemories for each entry
|
||||
* ```
|
||||
*/
|
||||
export function listMemories(
|
||||
export function useMemories(
|
||||
args: {
|
||||
containerTag: string
|
||||
source?: "chat" | "document" | "manual"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue