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
I noticed that in the recent commit (dc4d1c6) on https://github.com/alexrudall/ruby-openai, the processing for JSON.parse within the json_post method seems to have been removed. Could you please clarify the reason behind this change?
After creating a stub with WebMock as shown below, I encountered an error during the execution of dig('choices', 0, 'message', 'content') due to the absence of JSON.parse being executed.
response={"model"=>"gpt-4-0613","choices"=>[{"message"=>{"role"=>"assistant","content"=>"Response from the API",},"finish_reason"=>"stop","index"=>0}]}stub_request(:post,"https://api.openai.com/v1/chat/completions").to_return(status: 200,body: response.to_json,headers: {})
ERROR -- : undefined method `dig' for "{\"model\":\"gpt-4-0613\",\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"Response from the API\"},\"finish_reason\":\"stop\",\"index\":0}]}":String
response.dig('choices', 0, 'message', 'content')
^^^^ (NoMethodError)
It seems like the removal of JSON.parse from json_post might be the cause of this issue. What are your thoughts on this?
The text was updated successfully, but these errors were encountered:
I ran into this error too. In lieu for there being a solution, I came up with this monkey patch:
# workaround for https://github.com/alexrudall/ruby-openai/issues/416ifRails.env.test?moduleOpenAIClientExtensionsdefchat(**kwargs)rez=superJSON.parse(rez)endendmoduleOpenAIclassClientprependOpenAIClientExtensionsendendend
I noticed that in the recent commit (dc4d1c6) on https://github.com/alexrudall/ruby-openai, the processing for JSON.parse within the json_post method seems to have been removed. Could you please clarify the reason behind this change?
dc4d1c6
After creating a stub with WebMock as shown below, I encountered an error during the execution of dig('choices', 0, 'message', 'content') due to the absence of JSON.parse being executed.
It seems like the removal of JSON.parse from json_post might be the cause of this issue. What are your thoughts on this?
The text was updated successfully, but these errors were encountered: