Hello, every time I try to send a query that utilizes the function calling feature gpt immediately responds with something like “I am not available right now. Please try again later.” But, if I send a query without the function calling feature, it works. I have tried gpt-4-1106-preview and gpt-4-turbo-preview. What am I doing wrong?
This is the class I use to make chat requests:
public class ChatCompletionRequest {
public String model;
public List<ChatMessageWithContent> messages;
public Double temperature;
public Double top_p;
public Integer n;
public Boolean stream;
public List<String> stop;
public Integer max_tokens;
public Double presence_penalty;
public Double frequency_penalty;
public Map<String, Integer> logit_bias;
public String user;
public List<ToolsForFunctionCalling> tools;
}
This is the class for ToolsForFunctionCalling:
public class ToolsForFunctionCalling {
public String type;
public Function function;
}
This is the Function class:
public class Function{
public String description;
public String name;
public String parameters;
}
This is the query I send:
ChatCompletionRequest completionRequest = new ChatCompletionRequest();
// olf function calling model → gpt-4-1106-preview; other → gpt-4-turbo-preview
completionRequest.model = “gpt-4-1106-preview”;
completionRequest.messages = this._session_messages;
completionRequest.n = 1;
completionRequest.temperature = 0.2;
completionRequest.max_tokens = 1000;
Function takeOutGarbage = new Function();
takeOutGarbage.name = "takeOutGarbage";
takeOutGarbage.description = "Takes out the garbage";
takeOutGarbage.parameters = "null";
ToolsForFunctionCalling takeOutGarbage_ = new ToolsForFunctionCalling();
takeOutGarbage_.type = "function";
takeOutGarbage_.function = takeOutGarbage;
List<ToolsForFunctionCalling> tools_ = new ArrayList<>();
tools_.add(takeOutGarbage_);
completionRequest.tools = tools_;
Then I turn this object into json format using:
ObjectMapper objectMapper = new ObjectMapper();
String jsonString = objectMapper.writeValueAsString(completionRequest);
Then I send my query but it fails. However, if I comment out all the code that has to do with adding to the tools list, it works. Any help would be appreciated.