8000 Confusing error without a token ('Raix::ChatCompletion#openai_request': undefined method 'chat' for nil (NoMethodError)) · Issue #10 · Shopify/roast · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Confusing error without a token ('Raix::ChatCompletion#openai_request': undefined method 'chat' for nil (NoMethodError)) #10

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

Open
dblock opened this issue May 10, 2025 · 4 comments

Comments

@dblock
Copy link
Contributor
dblock commented May 10, 2025

Without a token the error is not helpful.

~/src/github.com/Shopify/roast (main)$ ./exe/roast execute examples/grading/workflow.yml test/roast/resources_test.rb 
🔥🔥🔥 Everyone loves a good roast 🔥🔥🔥

Starting workflow...
Workflow: /Users/dblock/src/github.com/Shopify/roast/examples/grading/workflow.yml
Options: {}
Running workflow for file: test/roast/resources_test.rb
Executing: read_dependencies (Resource type: none)


Exiting due to error: NoMethodError: undefined method 'chat' for nil
/Users/dblock/.gem/ruby/3.4.2/gems/raix-0.8.4/lib/raix/chat_completion.rb:230:in 'Raix::ChatCompletion#openai_request': undefined method 'chat' for nil (NoMethodError)

      Raix.configuration.openai_client.chat(parameters: params.compact.merge(model:, messages:))
                                      ^^^^^
	from /Users/dblock/.gem/ruby/3.4.2/gems/raix-0.8.4/lib/raix/chat_completion.rb:111:in 'Raix::ChatCompletion#chat_completion'
	from /Users/dblock/.gem/ruby/3.4.2/gems/raix-0.8.4/lib/raix/function_dispatch.rb:104:in 'Raix::FunctionDispatch#chat_completion'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/base_workflow.rb:78:in 'Roast::Workflow::BaseWorkflow#chat_completion'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/base_step.rb:38:in 'Roast::Workflow::BaseStep#chat_completion'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/base_step.rb:32:in 'Roast::Workflow::BaseStep#call'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/workflow_executor.rb:60:in 'Roast::Workflow::WorkflowExecutor#execute_step'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/workflow_executor.rb:113:in 'Roast::Workflow::WorkflowExecutor#execute_string_step'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/workflow_executor.rb:29:in 'block in Roast::Workflow::WorkflowExecutor#execute_steps'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/workflow_executor.rb:22:in 'Array#each'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/workflow_executor.rb:22:in 'Roast::Workflow::WorkflowExecutor#execute_steps'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/configuration_parser.rb:242:in 'Roast::Workflow::ConfigurationParser#parse'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/configuration_parser.rb:49:in 'block in Roast::Workflow::ConfigurationParser#begin!'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/configuration_parser.rb:46:in 'Array#each'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast/workflow/configuration_parser.rb:46:in 'Roast::Workflow::ConfigurationParser#begin!'
	from /Users/dblock/src/github.com/Shopify/roast/lib/roast.rb:28:in 'Roast::CLI#execute'
	from /Users/dblock/.gem/ruby/3.4.2/gems/thor-1.3.2/lib/thor/command.rb:28:in 'Thor::Command#run'
	from /Users/dblock/.gem/ruby/3.4.2/gems/thor-1.3.2/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
	from /Users/dblock/.gem/ruby/3.4.2/gems/thor-1.3.2/lib/thor.rb:538:in 'Thor.dispatch'
	from /Users/dblock/.gem/ruby/3.4.2/gems/thor-1.3.2/lib/thor/base.rb:584:in 'Thor::Base::ClassMethods#start'
	from ./exe/roast:17:in '<main>'

Should we also fallback on a global ENV['OPENAI_API_TOKEN']?

@dereklucas
Copy link

My reading of the docs was that the default was api_token: $(echo $OPENAI_API_KEY). Since the workflow doesn't work until that is added, it's not. Is there a recommended way to share keys?

@dblock
Copy link
Contributor Author
dblock commented May 16, 2025

@dereklucas Could you please elaborate what you mean by "sharing"? With others?

At Shopify we have a tool that obtains a short lived token so that's why this was built like this I believe. It probably makes sense to default to OPENAI_API_TOKEN in code so that the behavior is to use that by default. Please feel free to PR that change!

@dereklucas
Copy link

@dblock yeah sorry that's not worded correctly: I meant sharing workflows in a company without sharing the keys. Defaulting to ENV['OPENAI_API_TOKEN'] like you've said is probably the simplest option.

@xrendan
Copy link
Contributor
xrendan commented May 19, 2025

Added support for env vars in #56. it uses OPENAI_API_KEY instead of OPENAI_API_TOKEN to follow OpenAI's best practices guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0