Documentation
¶
Overview ¶
Package inmemory provides a zero-value-ready in-process history 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() {
store := new(inmemory.Store)
message := chat.NewUserMessage(chat.NewTextPart("hello"))
if _, err := store.Write(context.Background(), history.ConversationID("demo"), message); err != nil {
panic(err)
}
messages, err := store.Read(context.Background(), history.ConversationID("demo"))
if err != nil {
panic(err)
}
fmt.Println(len(messages), messages[0].Text())
}
Output: 1 hello
Index ¶
- type Store
- 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)
- func (s *Store) Write(ctx context.Context, conversationID history.ConversationID, ...) (history.WriteOutcome, 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 is a concurrent in-process history store suitable for tests, development, and single-instance applications. Its zero value is ready to use. Writes validate then snapshot messages before locking; reads return deep caller-owned snapshots, and missing conversations behave as empty histories.
func (*Store) Conversations ¶
Click to show internal directories.
Click to hide internal directories.