@letta-ai/letta-react 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -2
- package/dist/hooks/useAgentPassages/useAgentPassages.d.ts +2 -1
- package/dist/hooks/useAgentPassages/useAgentPassages.js +4 -3
- package/hooks/useAgentPassages/useAgentPassages.d.ts +2 -1
- package/hooks/useAgentPassages/useAgentPassages.js +4 -3
- package/package.json +1 -1
- package/src/hooks/useAgentPassages/useAgentPassages.ts +4 -3
package/README.md
CHANGED
@@ -110,12 +110,29 @@ const {
|
|
110
110
|
});
|
111
111
|
```
|
112
112
|
|
113
|
-
##### Getting Agent State
|
113
|
+
##### Getting/Setting Agent State
|
114
114
|
|
115
115
|
Check out [this example](./packages/letta-react/examples/view-and-send-messages) for more detailed usage.
|
116
116
|
|
117
117
|
```typescript jsx
|
118
|
-
const {
|
118
|
+
const {
|
119
|
+
agentState,
|
120
|
+
loadingError,
|
121
|
+
isLoading,
|
122
|
+
refresh,
|
123
|
+
updateAgentState,
|
124
|
+
isUpdating,
|
125
|
+
updatingError,
|
126
|
+
} = useAgentState({
|
119
127
|
agentId: `your-agent-id`,
|
120
128
|
});
|
121
129
|
```
|
130
|
+
|
131
|
+
##### Listing Agent Passages
|
132
|
+
|
133
|
+
```typescript jsx
|
134
|
+
const { passages, loadingError, isLoadingError, isLoading, refresh } =
|
135
|
+
useAgentPassages({
|
136
|
+
agentId: `your-agent-id`,
|
137
|
+
});
|
138
|
+
```
|
@@ -6,7 +6,8 @@ interface UseAgentStateOptions {
|
|
6
6
|
}
|
7
7
|
export declare function useAgentPassages(options: UseAgentStateOptions): {
|
8
8
|
isLoading: boolean;
|
9
|
-
|
9
|
+
loadingError: unknown;
|
10
|
+
isLoadingError: boolean;
|
10
11
|
passages: Passage[] | undefined;
|
11
12
|
refresh: () => Promise<void>;
|
12
13
|
};
|
@@ -16,14 +16,14 @@ export function useAgentPassages(options) {
|
|
16
16
|
const loadedAgentId = useRef(null);
|
17
17
|
const [localState, setLocalState] = useCachedState(`agent-passages-${agentId}`, undefined);
|
18
18
|
const [isLoading, setIsLoading] = useState(true);
|
19
|
-
const [
|
19
|
+
const [loadingError, setLoadingError] = useState(null);
|
20
20
|
const getAgentPassages = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
21
21
|
try {
|
22
22
|
const state = yield localClient.agents.passages.list(agentId);
|
23
23
|
setLocalState(state);
|
24
24
|
}
|
25
25
|
catch (error) {
|
26
|
-
|
26
|
+
setLoadingError(error);
|
27
27
|
}
|
28
28
|
finally {
|
29
29
|
setIsLoading(false);
|
@@ -38,7 +38,8 @@ export function useAgentPassages(options) {
|
|
38
38
|
}, [agentId, getAgentPassages]);
|
39
39
|
return {
|
40
40
|
isLoading,
|
41
|
-
|
41
|
+
loadingError,
|
42
|
+
isLoadingError: !!loadingError,
|
42
43
|
passages: localState,
|
43
44
|
refresh: getAgentPassages,
|
44
45
|
};
|
@@ -6,7 +6,8 @@ interface UseAgentStateOptions {
|
|
6
6
|
}
|
7
7
|
export declare function useAgentPassages(options: UseAgentStateOptions): {
|
8
8
|
isLoading: boolean;
|
9
|
-
|
9
|
+
loadingError: unknown;
|
10
|
+
isLoadingError: boolean;
|
10
11
|
passages: Passage[] | undefined;
|
11
12
|
refresh: () => Promise<void>;
|
12
13
|
};
|
@@ -16,14 +16,14 @@ export function useAgentPassages(options) {
|
|
16
16
|
const loadedAgentId = useRef(null);
|
17
17
|
const [localState, setLocalState] = useCachedState(`agent-passages-${agentId}`, undefined);
|
18
18
|
const [isLoading, setIsLoading] = useState(true);
|
19
|
-
const [
|
19
|
+
const [loadingError, setLoadingError] = useState(null);
|
20
20
|
const getAgentPassages = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
21
21
|
try {
|
22
22
|
const state = yield localClient.agents.passages.list(agentId);
|
23
23
|
setLocalState(state);
|
24
24
|
}
|
25
25
|
catch (error) {
|
26
|
-
|
26
|
+
setLoadingError(error);
|
27
27
|
}
|
28
28
|
finally {
|
29
29
|
setIsLoading(false);
|
@@ -38,7 +38,8 @@ export function useAgentPassages(options) {
|
|
38
38
|
}, [agentId, getAgentPassages]);
|
39
39
|
return {
|
40
40
|
isLoading,
|
41
|
-
|
41
|
+
loadingError,
|
42
|
+
isLoadingError: !!loadingError,
|
42
43
|
passages: localState,
|
43
44
|
refresh: getAgentPassages,
|
44
45
|
};
|
package/package.json
CHANGED
@@ -20,7 +20,7 @@ export function useAgentPassages(options: UseAgentStateOptions) {
|
|
20
20
|
);
|
21
21
|
|
22
22
|
const [isLoading, setIsLoading] = useState(true);
|
23
|
-
const [
|
23
|
+
const [loadingError, setLoadingError] = useState<unknown | null>(null);
|
24
24
|
|
25
25
|
const getAgentPassages = useCallback(async () => {
|
26
26
|
try {
|
@@ -28,7 +28,7 @@ export function useAgentPassages(options: UseAgentStateOptions) {
|
|
28
28
|
|
29
29
|
setLocalState(state);
|
30
30
|
} catch (error) {
|
31
|
-
|
31
|
+
setLoadingError(error);
|
32
32
|
} finally {
|
33
33
|
setIsLoading(false);
|
34
34
|
}
|
@@ -44,7 +44,8 @@ export function useAgentPassages(options: UseAgentStateOptions) {
|
|
44
44
|
|
45
45
|
return {
|
46
46
|
isLoading,
|
47
|
-
|
47
|
+
loadingError,
|
48
|
+
isLoadingError: !!loadingError,
|
48
49
|
passages: localState,
|
49
50
|
refresh: getAgentPassages,
|
50
51
|
};
|