Documentation
¶
Overview ¶
Package inmemory provides the in-process reference history store. Its zero value is ready to use: see Store.
Example ¶
package main
import (
"context"
"fmt"
"github.com/Tangerg/scope/core/chat"
"github.com/Tangerg/scope/core/history"
"github.com/Tangerg/scope/core/history/inmemory"
)
func main() {
ctx := context.Background()
store := new(inmemory.Store)
message := chat.NewUserMessage(chat.NewTextPart("hello"))
batch, err := history.NewBatch("demo", "first-turn", message)
if err != nil {
panic(err)
}
if _, err = store.Append(ctx, batch); err != nil {
panic(err)
}
messages, err := store.Read(ctx, history.ConversationID("demo"))
if err != nil {
panic(err)
}
fmt.Println(len(messages), messages[0].Text())
}
Output: 1 hello
Index ¶
- type Store
- func (s *Store) Append(ctx context.Context, batch history.Batch) (history.Receipt, error)
- func (s *Store) Clear(ctx context.Context, conversationID history.ConversationID) error
- func (s *Store) Conversations(ctx context.Context) ([]history.ConversationID, error)
- func (s *Store) Read(ctx context.Context, conversationID history.ConversationID) ([]chat.Message, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds messages, append receipts, and closed identities under one lock. Its zero value is usable. All records are lost when the process exits.
func (*Store) Conversations ¶
Click to show internal directories.
Click to hide internal directories.