Private
Public Access
1
0

Add initial store.go for conversation/message persistence

This commit is contained in:
2023-11-03 16:56:20 +00:00
parent fd667a1f47
commit 8fe2a2cf53
4 changed files with 112 additions and 15 deletions

22
main.go
View File

@@ -7,21 +7,13 @@ import (
"github.com/spf13/cobra"
)
type Message struct {
MessageID string
ConversationID string
Conversation Conversation
OriginalContent string
Role string // 'user' or 'assistant'
}
var store, storeError = InitializeStore()
type Conversation struct {
ID string
Title string
}
type Context struct {
CurrentConversation string
func checkStore() {
if storeError != nil {
fmt.Fprintf(os.Stderr, "Error establishing connection to store: %v\n", storeError)
os.Exit(1)
}
}
var rootCmd = &cobra.Command{
@@ -29,6 +21,7 @@ var rootCmd = &cobra.Command{
Short: "Interact with Large Language Models",
Long: `lm is a CLI tool to interact with OpenAI's GPT 3.5 and GPT 4.`,
Run: func(cmd *cobra.Command, args []string) {
checkStore()
// execute `lm ls` by default
},
}
@@ -100,7 +93,6 @@ var newCmd = &cobra.Command{
fmt.Printf("> %s\n", messageContents)
// Initialize the messages array for this conversation.
messages := []Message{
{
OriginalContent: messageContents,