#Function Calling – How to not output “content”, and only “function_call”?

1 messages · Page 1 of 1 (latest)

brave shadow
#

I am trying to use the new function calling with gpt-3.5-turbo-0613. One example of a response I get is this:

{
  "content": "Thank you for your willingness to assist! I have a text and I need to determine if it is written in English or Swedish. Can you help me with that?",
  "function_call": {
    "arguments": "{\n  \"decision\": \"ENGLISH\"\n}",
    "name": "english_or_swedish"
  },
  "role": "assistant"
}

I do not want it to write or output any unnecessary “content”, since I only need the “function_call”. It’s just wasting tokens. What should I change in my python code to never output “content”?

messages = [{'role':'user','content':text}]

functions = [
    {
        "name": "english_or_swedish",
        "description": "Based on the user message, determine if it is English or Swedish",
        "parameters": {
            "type": "object",
            "properties": {
                "decision": {
                    "type": "string",
                    "enum": ["ENGLISH", "SWEDISH"]
                },
            },
            "required": ["decision"]
        }
    }
]

response = openai.ChatCompletion.create(
    model="gpt-3.5-turbo-0613",
    messages=messages,
    functions=functions,
    temperature=0.2
)

Thank you for your help. It is really appreciated!