I’m using Openai package in for the R language. I’m looking for a way to switch to JSON mode with the completion api.
At the moment I’m using the create_chat_completion
function such as:
create_chat_completion( model = model_type,
messages = user_conversation,
temperature = model_temperature,
max_tokens = model_max_tokens,
top_p = 1,
frequency_penalty = 0,
presence_penalty = 0 )
Documentation do not provide any hint on that and isn’t clear to me if there is something similar to the python such as response_format={ "type": "json_object" }
or if I’ve to build this with a raw httR
calls with the rights tool specification:
tools = [
{
"type": "function",
"function": {
"name": "ask_database",
"description": "Use this function to answer user questions about music. Input should be a fully formed SQL query.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": f"""
SQL query extracting info to answer the user's question.
SQL should be written using this database schema:
{database_schema_string}
The query should be returned in plain text, not in JSON.
""",
}
},
"required": ["query"],
},
}
}
]
Thanks