Run gofmt/goimports on go sources

This commit is contained in:
Matt Low 2023-11-04 22:56:22 +00:00
parent 4590f1db38
commit 200ec57f29
4 changed files with 27 additions and 26 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
)
@ -83,8 +84,8 @@ var newCmd = &cobra.Command{
messages := []Message{
{
OriginalContent: messageContents,
Role: "user",
OriginalContent: messageContents,
},
}
@ -111,8 +112,8 @@ var promptCmd = &cobra.Command{
messages := []Message{
{
OriginalContent: message,
Role: "user",
OriginalContent: message,
},
}
@ -128,5 +129,5 @@ var promptCmd = &cobra.Command{
func NewRootCmd() *cobra.Command {
rootCmd.AddCommand(newCmd, promptCmd)
return rootCmd;
return rootCmd
}

View File

@ -37,7 +37,6 @@ func InitializeConfig() *Config {
defaultConfig := &Config{}
defaultConfig.OpenAI.APIKey = "your_key_here"
file, err := os.Create(configFile)
if err != nil {
Fatal("Could not open config file for writing: %v", err)

View File

@ -5,10 +5,11 @@ import (
"errors"
"fmt"
"io"
openai "github.com/sashabaranov/go-openai"
)
func CreateChatCompletionRequest(system string, messages []Message) (*openai.ChatCompletionRequest) {
func CreateChatCompletionRequest(system string, messages []Message) *openai.ChatCompletionRequest {
chatCompletionMessages := []openai.ChatCompletionMessage{
{
Role: "system",
@ -16,7 +17,7 @@ func CreateChatCompletionRequest(system string, messages []Message) (*openai.Cha
},
}
for _, m := range(messages) {
for _, m := range messages {
chatCompletionMessages = append(chatCompletionMessages, openai.ChatCompletionMessage{
Role: m.Role,
Content: m.OriginalContent,

View File

@ -4,9 +4,10 @@ import (
"database/sql"
"os"
"path/filepath"
"gorm.io/gorm"
"gorm.io/driver/sqlite"
sqids "github.com/sqids/sqids-go"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
type Store struct {
@ -28,9 +29,8 @@ type Conversation struct {
Title string
}
func getDataDir() string {
var dataDir string;
var dataDir string
xdgDataHome := os.Getenv("XDG_DATA_HOME")
if xdgDataHome != "" {
@ -57,7 +57,7 @@ func InitializeStore() *Store {
&Message{},
}
for _, x := range(models) {
for _, x := range models {
err := db.AutoMigrate(x)
if err != nil {
Fatal("Could not perform database migrations: %v\n", err)
@ -76,7 +76,7 @@ func (s *Store) SaveConversation(conversation *Conversation) error {
}
if !conversation.ShortName.Valid {
shortName, _ := s.sqids.Encode([]uint64{ uint64(conversation.ID) })
shortName, _ := s.sqids.Encode([]uint64{uint64(conversation.ID)})
conversation.ShortName = sql.NullString{String: shortName, Valid: true}
err = s.db.Save(&conversation).Error
}