You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
According to the code of this example, everything can be run including creating Assistant and Thread. But there is a problem, maxTokens and Stream cannot be set. This results in a long wait for a response to be returned.After I checked the source code, I found that the above configuration information is not supported.
Describe the solution you'd like
Are there any plans to add configuration information to client.CreateRun() in the future? Or in the current situation, what can I do to return the request results multiple times?Please ignore my poor English!Thank you!
example code
package main
import (
"context"
"fmt"
"time"
"github.com/sashabaranov/go-openai"
)
func main() {
client := openai.NewClient("your token")
ctx := context.Background()
thread, err := client.CreateThread(ctx, openai.ThreadRequest{})
if err != nil {
fmt.Printf("CreateThread error: %v\n", err)
return
}
messageReq := openai.MessageRequest{
Role: openai.ChatMessageRoleUser,
Content: "Lorem ipsum",
}
_, err = client.CreateMessage(ctx, thread.ID, messageReq)
if err != nil {
fmt.Printf("CreateMessage error: %v\n", err)
return
}
runReq := openai.RunRequest{
AssistantID: assistantId,
}
run, err := client.CreateRun(ctx, thread.ID, runReq)
if err != nil {
fmt.Printf("CreateRun error: %v\n", err)
return
}
// Poll for a status that indicates run has finished
for run.Status == openai.RunStatusQueued || run.Status == openai.RunStatusInProgress {
run, err = client.RetrieveRun(ctx, run.ThreadID, run.ID)
if err != nil {
fmt.Printf("RetrieveRun error: %v\n", err)
return
}
time.Sleep(100 * time.Millisecond)
}
if run.Status != openai.RunStatusCompleted {
fmt.Printf("Run finised with status: %v\n", run.Status)
if run.Status == openai.RunStatusFailed {
fmt.Printf("Run error: [%v] %v\n", run.LastError.Code, run.LastError.Message)
}
return
}
// Get only latest message
numMessages := 1
messages, err := client.ListMessage(ctx, run.ThreadID, &numMessages, nil, nil, nil)
if err != nil {
fmt.Printf("RetrieveRun error: %v\n", err)
return
}
// When the text message is very long, the response time becomes very slow
fmt.Printf(messages.Messages[0].Content[0].Text.Value)
}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
According to the code of this example, everything can be run including creating Assistant and Thread. But there is a problem, maxTokens and Stream cannot be set. This results in a long wait for a response to be returned.After I checked the source code, I found that the above configuration information is not supported.
Describe the solution you'd like
Are there any plans to add configuration information to client.CreateRun() in the future? Or in the current situation, what can I do to return the request results multiple times?Please ignore my poor English!Thank you!
example code
The text was updated successfully, but these errors were encountered: