Skip to content

Commit 3c6a482

Browse files
organize the assistant command folder, make chat its own sub-command, allow users to request the chat id specifically through the describe command
1 parent 333d7cf commit 3c6a482

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

internal/pkg/assistants/assistant_chat_completions.go

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func GetAssistantChatCompletions(asstName string, msg string, stream bool) (*mod
7575
}
7676

7777
// If the request was successful, update the chat history
78+
chat.Id = resp.Id
7879
chat.Messages = append(chat.Messages, processChatCompletionModel(resp)...)
7980
(*chatHistory.History)[asstName] = chat
8081
state.ChatHist.Set(&chatHistory)

internal/pkg/cli/command/assistant/chat_describe.go internal/pkg/cli/command/assistant/chat/describe.go

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
type AssistantChatDescribeCmdOptions struct {
1313
assistant string
14+
id bool
1415
json bool
1516
}
1617

@@ -37,6 +38,13 @@ func NewAssistantChatDescribeCmd() *cobra.Command {
3738
return
3839
}
3940

41+
// If the chat ID was requested print that
42+
if options.id {
43+
pcio.Printf("id: %s\n", chat.Id)
44+
return
45+
}
46+
47+
// Otherwise print the chat history
4048
if options.json {
4149
text.PrettyPrintJSON(chat)
4250
} else {
@@ -47,6 +55,7 @@ func NewAssistantChatDescribeCmd() *cobra.Command {
4755

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

5160
return cmd
5261
}

internal/pkg/cli/command/assistant/cmd.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package assistant
22

33
import (
4+
assistant "github.com/pinecone-io/cli/internal/pkg/cli/command/assistant/chat"
45
"github.com/pinecone-io/cli/internal/pkg/utils/help"
56
"github.com/pinecone-io/cli/internal/pkg/utils/text"
67
"github.com/spf13/cobra"
@@ -30,7 +31,7 @@ func NewAssistantCommand() *cobra.Command {
3031
// Assistant Operations
3132
cmd.AddGroup(help.GROUP_ASSISTANT_OPERATIONS)
3233
cmd.AddCommand(NewDescribeAssistantCmd())
33-
cmd.AddCommand(NewAssistantChatCmd())
34+
cmd.AddCommand(assistant.NewAssistantChatCmd())
3435
cmd.AddCommand(NewListAssistantFilesCmd())
3536
cmd.AddCommand(NewDeleteAssistantFileCmd())
3637
cmd.AddCommand(NewUploadAssistantFileCmd())

internal/pkg/utils/models/models.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type ChatCompletionMessage struct {
2727
type AssistantChatHistory map[string]AssistantChat
2828

2929
type AssistantChat struct {
30+
Id string `json:"id"`
3031
Messages []ChatCompletionMessage `json:"messages"`
3132
CreatedOn time.Time `json:"created_on"`
3233
}

0 commit comments

Comments
 (0)