mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 08:03:39 +00:00
Update custom-compaction example to use serializeConversation
Also fix docs to show convertToLlm is needed first.
This commit is contained in:
parent
75269add96
commit
027d39aa33
2 changed files with 14 additions and 9 deletions
|
|
@ -303,13 +303,15 @@ pi.on("session_before_compact", async (event, ctx) => {
|
|||
To generate a summary with your own model, convert messages to text using `serializeConversation`:
|
||||
|
||||
```typescript
|
||||
import { serializeConversation } from "@mariozechner/pi-coding-agent";
|
||||
import { convertToLlm, serializeConversation } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
pi.on("session_before_compact", async (event, ctx) => {
|
||||
const { preparation } = event;
|
||||
|
||||
// Convert messages to readable text format
|
||||
const conversationText = serializeConversation(preparation.messagesToSummarize);
|
||||
// Convert AgentMessage[] to Message[], then serialize to text
|
||||
const conversationText = serializeConversation(
|
||||
convertToLlm(preparation.messagesToSummarize)
|
||||
);
|
||||
// Returns:
|
||||
// [User]: message text
|
||||
// [Assistant thinking]: thinking content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue