Skip to content

Commit

Permalink
organize the assistant command folder, make chat its own sub-command,…
Browse files Browse the repository at this point in the history
… allow users to request the chat id specifically through the describe command
  • Loading branch information
austin-denoble committed Jun 18, 2024
1 parent 333d7cf commit 3c6a482
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/pkg/assistants/assistant_chat_completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func GetAssistantChatCompletions(asstName string, msg string, stream bool) (*mod
}

// If the request was successful, update the chat history
chat.Id = resp.Id
chat.Messages = append(chat.Messages, processChatCompletionModel(resp)...)
(*chatHistory.History)[asstName] = chat
state.ChatHist.Set(&chatHistory)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

type AssistantChatDescribeCmdOptions struct {
assistant string
id bool
json bool
}

Expand All @@ -37,6 +38,13 @@ func NewAssistantChatDescribeCmd() *cobra.Command {
return
}

// If the chat ID was requested print that
if options.id {
pcio.Printf("id: %s\n", chat.Id)
return
}

// Otherwise print the chat history
if options.json {
text.PrettyPrintJSON(chat)
} else {
Expand All @@ -47,6 +55,7 @@ func NewAssistantChatDescribeCmd() *cobra.Command {

cmd.Flags().StringVarP(&options.assistant, "assistant", "a", "", "name of the assistant chat to describe")
cmd.Flags().BoolVar(&options.json, "json", false, "output as JSON")
cmd.Flags().BoolVar(&options.id, "id", false, "output the ID of the chat")

return cmd
}
3 changes: 2 additions & 1 deletion internal/pkg/cli/command/assistant/cmd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package assistant

import (
assistant "github.com/pinecone-io/cli/internal/pkg/cli/command/assistant/chat"
"github.com/pinecone-io/cli/internal/pkg/utils/help"
"github.com/pinecone-io/cli/internal/pkg/utils/text"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -30,7 +31,7 @@ func NewAssistantCommand() *cobra.Command {
// Assistant Operations
cmd.AddGroup(help.GROUP_ASSISTANT_OPERATIONS)
cmd.AddCommand(NewDescribeAssistantCmd())
cmd.AddCommand(NewAssistantChatCmd())
cmd.AddCommand(assistant.NewAssistantChatCmd())
cmd.AddCommand(NewListAssistantFilesCmd())
cmd.AddCommand(NewDeleteAssistantFileCmd())
cmd.AddCommand(NewUploadAssistantFileCmd())
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/utils/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ChatCompletionMessage struct {
type AssistantChatHistory map[string]AssistantChat

type AssistantChat struct {
Id string `json:"id"`
Messages []ChatCompletionMessage `json:"messages"`
CreatedOn time.Time `json:"created_on"`
}
Expand Down

0 comments on commit 3c6a482

Please sign in to comment.