@applica-software-guru/persona-sdk 0.1.60 → 0.1.61
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 +45 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Persona SDK is the official SDK for the Persona API. It provides a simple and ef
|
|
|
13
13
|
- [Features](#features)
|
|
14
14
|
- [Installation](#installation)
|
|
15
15
|
- [Usage](#usage)
|
|
16
|
+
- [Accessing Messages](#accessing-messages)
|
|
16
17
|
- [Protocols Overview](#protocols-overview)
|
|
17
18
|
- [API Reference](#api-reference)
|
|
18
19
|
- [Customization](#customization)
|
|
@@ -86,6 +87,50 @@ Use the `dev` prop to enable development mode. This redirects all traffic to a l
|
|
|
86
87
|
|
|
87
88
|
---
|
|
88
89
|
|
|
90
|
+
## Accessing Messages
|
|
91
|
+
|
|
92
|
+
### usePersonaRuntimeMessages
|
|
93
|
+
|
|
94
|
+
The `usePersonaRuntimeMessages` hook provides a simple way to access the current list of messages managed by the Persona SDK runtime. This hook returns an array of `PersonaMessage` objects, which represent the conversation history, including user, assistant, and reasoning messages.
|
|
95
|
+
|
|
96
|
+
**Usage Example:**
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import { usePersonaRuntimeMessages } from '@applica-software-guru/persona-sdk';
|
|
100
|
+
|
|
101
|
+
function MessageLogger() {
|
|
102
|
+
const messages = usePersonaRuntimeMessages();
|
|
103
|
+
return (
|
|
104
|
+
<div>
|
|
105
|
+
<h3>Messages</h3>
|
|
106
|
+
<pre>{JSON.stringify(messages, null, 2)}</pre>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This hook must be used within a `PersonaRuntimeProvider`.
|
|
113
|
+
|
|
114
|
+
### usePersonaRuntime and getMessages
|
|
115
|
+
|
|
116
|
+
The `usePersonaRuntime` hook gives you access to the Persona runtime context, which now includes a `getMessages` method. This method returns the current array of `PersonaMessage` objects, allowing you to programmatically retrieve the latest messages at any time.
|
|
117
|
+
|
|
118
|
+
**Usage Example:**
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { usePersonaRuntime } from '@applica-software-guru/persona-sdk';
|
|
122
|
+
|
|
123
|
+
function MyComponent() {
|
|
124
|
+
const { getMessages } = usePersonaRuntime();
|
|
125
|
+
const messages = getMessages();
|
|
126
|
+
// Use messages as needed
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Both approaches are useful for building custom UI components, analytics, or debugging tools that need access to the chat history.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
89
134
|
## Protocols Overview
|
|
90
135
|
|
|
91
136
|
The Persona SDK supports multiple communication protocols to provide flexibility and performance. These protocols can work together, sharing the same session and data, to ensure the best possible experience.
|