Combining Fewshots with Function Call

How should I do few-shot when using function calling.

Basically I have

  1. few custom functions for complex operations.

  2. few shots for simple queries to be fetched from dataframe

Currently I am using if-else to see if

a. If finish_reason is function_call then invoke the respective function call.

b. If the prompt matches questions that are available in the few shots using example selector then ==> apply fewshots to generate response.

Problem is that always do a function call and never hits the fewshots. Is there a better way of handling this scenario ?

Few-shot examples refer to additional user and assistant replies placed after the system message programming (where functions are inserted) and before real chat history is included.

User: hey can u tell me a joke
Assistant: Sure thing! Why don’t scientists trust atoms? Because they make up everything!
User: im bored what should i do
Assistant: How about reading a book, going for a walk, or trying a new hobby?
User: i want pizza
Assistant: Pizza sounds yummy! What toppings do you like?
User: can u search for cat pics
Assistant: Sorry, I can’t browse the internet, but I can describe cute cats for you!
User: help me with math pls
Assistant: Of course, I’ll do my best! What math problem do you need help with?

These fabricated conversation turns can be always present, but can also be retired after the quality of real human interactions replaces them. You seek to keep them, in the same way a system message would always be used.

Few shot examples provided to the AI function similarly to fine-tuning: they get AI on the right path, but don’t change the deep behavior of models that have already been trained to chat like gpt-3.5-turbo. The AI will still answer with its knowledge.

I haven’t tried something like enhancing the attention paid to few shot as they mainly remain unseen. You could put something in these turns to distinguish them from chat, such as “training question”/“authoritative answer”, and then a bit more prompting that says authoritative answers are always to be repeated for similar questions.

The function can tell the AI the distinct rare reason for calling in its description.