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

Functions Calling capability from ChatGPT model gpt-3.5-turbo-0613 not working #280

Open
kris2150 opened this issue Jun 17, 2023 · 5 comments

Comments

@kris2150
Copy link

Describe the bug
This function throws a 500 error

**ArgumentError (unknown keyword: :functions):

app/controllers/openai_controller.rb:120:in `generate_insight'**

Am i doing something wrong

To Reproduce
Steps to reproduce the behavior:
# ChatGPT Prompt
begin
@aiResponseSleep = ChatGPTclient.completions(
model: "gpt-3.5-turbo-0613",
messages: [
{
role: "user",
content:"Your role is to be a Data Analyst with expert knowledge on sleep"
},
{
role: "user",
content:"
Your goal is to
- Provide a natural language comparison between these two data sets attached below make it short and interesting.
- Provide a comparison of the summariest from Today's day and past 3 Day
- Use days instead of full dates and bold these days
- Provide insights based on notes and based on your trained knowlege.
- Use an encouraging tone to make sure I keep up these habits
- Use HTML formatting and mark up to bold dates, number of days, REM, Deep, Light, Total
- Avoid displaying the data tables
"
},
{
role: "user",
content: "Today's Data: #{ formatted_latest_sleep_record.to_json }"
},
{
role: "user",
content: "Past 3 Days Sleep Recorded Data: #{ formatted_3days_data.to_json }"
}
]
)
rescue OpenaiChatgpt::Error => e
puts e.message
end

@johnwahba
Copy link

My guess:
you passed in functions as a peer of parameters rather than nested under parameters

@kris2150
Copy link
Author

My guess:

you passed in functions as a peer of parameters rather than nested under parameters

How would you update this code in order for this to work?

@seanmccann
Copy link
Contributor

I added a function calling example to the README: #281

@alexrudall
Copy link
Owner

I merged that example so it's in the main README now @kris2150. Can you try that example and let us know if it's working for you?

@kris2150
Copy link
Author

kris2150 commented Jul 3, 2023

@alexrudall

# ChatGPT Functions

begin
@airesponse = ChatGPTclient.chat(
parameters: {
model: "gpt-3.5-turbo-16k",
temperature: 1,
frequency_penalty: 0,
messages: [
{
role: "user",
content:"
- Come up with 15 different goals derived from the data attached below with 5 goals benefits generated by You associated to each goal?"
},
{
role: "user",
content:"#{@selected_text}"
},
],
functions: [
{
name: "get_goals_from_questionnaires",
description: "15 different goals derived from the data attached below with 5 goals",
parameters: {
type: :object,
properties: {
goal_name: {
type: :string,
description: "Goal Name, e.g Maintain 7 hrs sleep schedule consistently",
},
goal_benefits: {
type: :string,
description: "Goal Benefits, e.g be more energized through the day, experience better mental clairity",
},
},
required: ["goal_name", "goal_benefits"],
},
},
],
}
)
rescue OpenaiChatgpt::Error => e
puts e.message
end

message = @aiResponse.dig("choices", 0, "message")

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

4 participants