Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temperature param being ignored? #333

Closed
rishsriv opened this issue May 31, 2023 · 5 comments
Closed

Temperature param being ignored? #333

rishsriv opened this issue May 31, 2023 · 5 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@rishsriv
Copy link

rishsriv commented May 31, 2023

Hi there! Thank you for maintaining this package. It has made our lives so much simpler.

I wanted to check if the temperature parameter is somehow being ignored in the library?

We have an implementation that is something like this

resp, err := Openai.CreateChatCompletion(
	c,
	openai.ChatCompletionRequest{
		Model:       "gpt-3.5-turbo",
		Messages:    messages,
		MaxTokens:   600,
		Temperature: 0.0,
		Stop:        []string{"```"},
	},
)

But this is ignoring the temperature parameter and returning a different response every time. This issue does not seem to be present when using the Python library or making a CURL request to the OpenAI API.

@rishsriv
Copy link
Author

To replicate on Replit or one's own machine

package main

import (
	"context"
	"fmt"
	openai "github.com/sashabaranov/go-openai"
)

func main() {
	client := openai.NewClient("YOUR OPENAI TOKEN")
	resp, err := client.CreateChatCompletion(
		context.Background(),
		openai.ChatCompletionRequest{
			Model: openai.GPT3Dot5Turbo,
			Messages: []openai.ChatCompletionMessage{
				{
					Role:    openai.ChatMessageRoleUser,
					Content: "The president was",
				},
			},
      MaxTokens: 128,
      Temperature: 0.0,
		},
	)

	if err != nil {
		fmt.Printf("ChatCompletion error: %v\n", err)
		return
	}

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

This gives a different answer every time, while using Python or curl results in the same answer

vvatanabe added a commit to vvatanabe/go-openai that referenced this issue May 31, 2023
@vvatanabe
Copy link
Collaborator

vvatanabe commented May 31, 2023

@rishsriv @sashabaranov I investigated the cause of the problem. Please see here.
#334 (comment)

@rishsriv
Copy link
Author

rishsriv commented Jun 1, 2023

Thank you so much for investigating this, @vvatanabe !

@vvatanabe vvatanabe added bug Something isn't working duplicate This issue or pull request already exists labels Jun 30, 2023
@vvatanabe
Copy link
Collaborator

Duplicate #9

@vvatanabe
Copy link
Collaborator

This is a duplicate issue with #9, so please discuss it in #9 from now on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants