Skip to content

getting an explenation rather than a function name in function_call_formatter #18

Answered by zhudotexe
dcssi asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, I think I see. You can access a mapping of function names to AIFunction objects through the Kani.functions attribute.

For example, if you wanted to print the docstring of a function when the AI requested to call it, you could do:

engine = ...
ai = MyKani(...)

def function_call_formatter(msg):
  func = ai.functions.get(message.function_call.name)
  if func is None:
    # raise some error - the AI requested a nonexistent function
  return f"The AI is calling {func.name}, which has this documentation:\n{func.desc}"

# ...
async for msg in ai.full_round_str(..., function_call_formatter=function_call_formatter):
  ...

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dcssi
Comment options

@zhudotexe
Comment options

Answer selected by zhudotexe
@zhudotexe
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants