openai-cookbook icon indicating copy to clipboard operation
openai-cookbook copied to clipboard

[FEATURE] Update token counting example to include function calling feature

Open bakkot opened this issue 1 year ago • 5 comments

The new function calling API is neat, but there's no docs anywhere I can find which tell you how many tokens your functions will cost. Can you update the sample notebook to account for provided functions?

bakkot avatar Jun 14 '23 00:06 bakkot

Agree it would be a nice feature. Not sure if I'll have time soon, unfortunately.

ted-at-openai avatar Jun 14 '23 00:06 ted-at-openai

If you can give a rough description of how it works I can try to put together a PR following that description, if that would be useful.

bakkot avatar Jun 14 '23 00:06 bakkot

After some testing it looks close to the token count of json-encoded function definition, but would be great to know the official answer, to make it possible to adjust the input text so that it fits within the context.

lopuhin avatar Jun 14 '23 17:06 lopuhin

@lopuhin is that json-encoded without any indentation? I.e. json.dumps(value) as opposed to e.g. json.dumps(value, indent=2)

adri1wald avatar Jun 20 '23 16:06 adri1wald

@adri1wald yes I meant just json.dumps(value)

lopuhin avatar Jun 21 '23 11:06 lopuhin

FYI @CGamesPlay did great job reverse engeneering it here

ju-bezdek avatar Aug 15 '23 19:08 ju-bezdek

+1. Also waiting for an official implementation.

ifsheldon avatar Sep 11 '23 15:09 ifsheldon

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Nov 11 '23 01:11 github-actions[bot]

This issue was closed because it has been stalled for 10 days with no activity.

github-actions[bot] avatar Nov 21 '23 01:11 github-actions[bot]