Skip to content

Commit

Permalink
error handling inline with other examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mirackara committed Feb 28, 2024
1 parent 3ba0862 commit ff9c7a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ func main() {
Temperature: 0.7,
MaxTokens: 150,
Messages: []openai.ChatCompletionMessage{
{
Role: openai.ChatMessageRoleUser,
Content: "What is 1+2?",
},
{
Role: openai.ChatMessageRoleUser,
Content: "What is 8*5",
Expand All @@ -58,11 +54,11 @@ func main() {
resp, err := nropenai.NRCreateChatCompletion(client, req, app)

if err != nil {
fmt.Println("Unable to create chat completion: ", err)
} else {
fmt.Println(resp.ChatCompletionResponse.Choices[0].Message.Content)
panic(err)
}

fmt.Println(resp.ChatCompletionResponse.Choices[0].Message.Content)

// Shutdown Application
app.Shutdown(5 * time.Second)
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ func main() {
resp, err := nropenai.NRCreateChatCompletion(client, req, app)

if err != nil {
fmt.Println("Unable to create chat completion: ", err)
} else {
// Print the contents of the message
fmt.Println("Message Response: ", resp.ChatCompletionResponse.Choices[0].Message.Content)
SendFeedback(app, resp)
panic(err)
}
// Print the contents of the message
fmt.Println("Message Response: ", resp.ChatCompletionResponse.Choices[0].Message.Content)
SendFeedback(app, resp)

// Shutdown Application
app.Shutdown(5 * time.Second)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ func main() {
}
resp, err := nropenai.NRCreateEmbedding(client, embeddingReq, app)
if err != nil {
fmt.Println("Unable to create embedding: ", err)
} else {
fmt.Println("Embedding Created!")
fmt.Println(resp.Usage.PromptTokens)
panic(err)
}

fmt.Println("Embedding Created!")
fmt.Println(resp.Usage.PromptTokens)
// Shutdown Application
app.Shutdown(5 * time.Second)
}

0 comments on commit ff9c7a9

Please sign in to comment.