7
7
"net/http"
8
8
"os"
9
9
"strings"
10
+ "time"
10
11
12
+ "github.com/briandowns/spinner"
11
13
"github.com/pinecone-io/cli/internal/pkg/utils/configuration/state"
12
14
"github.com/pinecone-io/cli/internal/pkg/utils/log"
13
15
"github.com/pinecone-io/cli/internal/pkg/utils/models"
@@ -44,13 +46,17 @@ func GetAssistantChatCompletions(asstName string, msg string, stream bool) (*mod
44
46
return nil , err
45
47
}
46
48
49
+ s := spinner .New (spinner .CharSets [11 ], 100 * time .Millisecond )
50
+ s .Start ()
51
+
47
52
var resp * models.ChatCompletionModel
48
53
if ! stream {
49
54
resp , err = network .PostAndDecode [models.ChatCompletionRequest , models.ChatCompletionModel ](
50
55
assistantDataUrl ,
51
56
fmt .Sprintf (URL_ASSISTANT_CHAT_COMPLETIONS , asstName ),
52
57
body ,
53
58
)
59
+ s .Stop ()
54
60
if err != nil {
55
61
return nil , err
56
62
}
@@ -59,6 +65,7 @@ func GetAssistantChatCompletions(asstName string, msg string, stream bool) (*mod
59
65
assistantDataUrl ,
60
66
fmt .Sprintf (URL_ASSISTANT_CHAT_COMPLETIONS , asstName ),
61
67
body ,
68
+ s ,
62
69
)
63
70
if err != nil {
64
71
return nil , err
@@ -73,12 +80,13 @@ func GetAssistantChatCompletions(asstName string, msg string, stream bool) (*mod
73
80
return resp , nil
74
81
}
75
82
76
- func PostAndStreamChatResponse [B any ](baseUrl string , path string , body B ) (* models.ChatCompletionModel , error ) {
83
+ func PostAndStreamChatResponse [B any ](baseUrl string , path string , body B , spinner * spinner. Spinner ) (* models.ChatCompletionModel , error ) {
77
84
resp , err := network .RequestWithBody [B ](baseUrl , path , http .MethodPost , body )
78
85
if err != nil {
79
86
return nil , err
80
87
}
81
88
defer resp .Body .Close ()
89
+ spinner .Stop ()
82
90
83
91
var completeResponse string
84
92
var id string
0 commit comments