Add initial store.go for conversation/message persistence
This commit is contained in:
22
main.go
22
main.go
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user