Function Calling returns data i've provided in the prompt without doing its job

Hey everyone.

I’m trying to use gpt-4 (or gpt-4-0613) function calling feature and i do not receive the result i expect. Actually, the API returns the exact same data i’ve provided in the prompt.
Needless to mention that it works perfectly on the UI

Here’s my code:

const completionConfig = {
    model: "gpt-4",
    temperature: 0.2,
    messages: [
      {
        role: "system",
        content: `You are an expert CV writer. You will be provided with professional experiences, keywords, and a targeted job title. Your task is to refine the experiences to align with the targeted job position, naturally incorporate the provided keywords, and ensure the content is compelling while maintaining authenticity`,
      },
      {
        role: "user",
        content: ` 
          Job title: Web3 Frontend Developer
          Keywords: javascript,React,React Native,web3,blockchain,mobile development,QA,communication,collaboration,proactive,self-driven,kind,empathetic,supportive
          Experiences: 
           Web3 Developer At Google, Sept. 2022 – July 2023
           Built a landing page
           Developed 'Robo,' off-chain technology for payment on chain
          Contributed to the core smart contract
          Designed a standout landing page for Google's NFT collection
`,
      },
    ],
    functions: [
      {
        name: "refine_experiences",
        description: "Refined Experiences",
        parameters: {
          title: "Refined Experiences Schema",
          description: "Schema for storing the refined experiences",
          type: "object",
          properties: {
            experiences: {
              type: "array",
              items: {
                type: "object",
                properties: {
                  company: {
                    type: "string",
                    description: "Name of the Company",
                  },
                  title: { type: "string", description: "Job title" },
                  dates: {
                    type: "string",
                    description: "Dates of employements",
                  },
                  achievements: {
                    type: "array",
                    description: "Tasks/Responsibilities/Achievements ",
                    items: { type: "string" },
                  },
                },
                required: ["company", "title", "dates", "achievements"],
              },
            },
          },
          required: ["experiences"],
        },
      },
    ],
    function_call: { name: "refine_experiences" },
  };

And i got the following result:

{
  company: "Google",
  title: "Web3 Developer",
  dates: "Sept. 2022 – July 2023",
  achievements: [      
    "Built a landing page",
    "Developed 'Robo,' off-chain technology for payment on chain",
    "Contributed to the core smart contract",
    "Designed a standout landing page for Google's NFT collection"
  }

Basically the API is totally ignoring my prompt. I’ve tried with different temperatures, different prompt, use only user prompt, … same result.
This is why i decided to ask for help.

Thank you so much for your help!!

What is the response you’re expecting?

Reading the prompt it seems to me like it’s actually doing a good job extracting the arguments for a refine_experiences function call.

*also btw- what UI are you referring to?

Hi @ramn7
Thank you for your answer

Well i am expecting to have rewritten professional experiences achievements with the keywords i provide
For example:

 achievements: [      
    "Spearheaded the development and design of a standout landing page, employing JavaScript and React to ensure a seamless user experience.",
    "Innovated "Robo," a groundbreaking off-chain technology facilitating on-chain payment, demonstrating proficiency in web3 and blockchain dynamics",
    "Made pivotal contributions to the core smart contract, showcasing in-depth understanding of Fintech and blockchain integrations.",
    "..."
  }

I’m referring to Chat GPT UI (GPT-4).
Thank you

I see.
I think this usecase is not what function calling is intended for. Function calling simply outputs the parameters for a function call you’re supposed to call yourself afterwards.
Here is the description from the function calling documentation

In an API call, you can describe functions to gpt-3.5-turbo-0613 and gpt-4-0613 , and have the model intelligently choose to output a JSON object containing arguments to call those functions. The Chat completions API does not call the function; instead, the model generates JSON that you can use to call the function in your code.

For your usecase it might work better to phrase a templated prompt that describes what you want to do (probably similar to the one you used on the chatgpt ui) and call the API without function calling.

you are referring to a “targeted job position” but I don’t see the position anywhere? I only see you input an experience entry, so without adding the details of the job position you want it to refine your entries towards I don’t see how it would produce anything other than your current output

Hi @eslof.github
Thank you for your message.

Its actually a targeted job title and yes its in the user prompt.

Thanks @ramn7
That’s interesting because i have other API calls where i prompt something to do and i provide a function calling schema, and it does the job very well.

However if i call the API without function calling the job is done very well.
The thing is that i need to manipulate a JSON Object, its going to be pricey to call the API twice (one for text treatment and the other one for the function calling). Any ideas?
Thank you!

I actually think you can do it in one call by specifically asking for a json response in the system message. Here is an initial attempt to adjust your system message to support this (haven’t tested…):

You are an expert CV writer. You will be provided with professional "Experiences", "Keywords", and a targeted "Job title".
Your task is to refine the provided "Experiences" to align with the provided  "Job title", naturally incorporate the provided "Keywords", and ensure the content is compelling while maintaining authenticity.
Return the list of refined experiences in a json array.

I’m actually invested in this use-case myself (json response oriented prompt engineering) and have developed a platform to help with its development and testing. You’re welcome to check it out (it’s still in beta and free), it also has some examples on how this can be done: Promptotype
The platform helps more with testing deterministic prompts (not your use-case) but it can also help with making sure you’re at least receiving a correct json schema as a response.

Hey @ramn7

By adding “Return the list of refined experiences in a json array.” it actually solves my problem. Thank you for that!

Also, congrats for your platform, its great idea! Best of luck with it.

1 Like

@j3rome here’s an alternative version of your prompt including @ramn7 is recommendations

You are an expert CV writer. Your task is to refine the provided “Experiences” to better align with the targeted “Job title”. This involves rephrasing the experiences, emphasizing relevant aspects, or reordering the information.

You should also incorporate the provided “Keywords” into these experiences in a natural and seamless manner. Ensure the content is compelling by using strong action verbs and concrete details, while maintaining authenticity.

For example, if the job title is “Software Engineer” and one of the experiences is “Worked on a team to develop software”, you could refine this to “Collaborated with a cross-functional team to develop a user-friendly software solution, incorporating Agile methodologies”.

You ALWAYS return the list of refined experiences in a json array.

Here are the experiences, keywords, and job title: