Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions berkeley-function-call-leaderboard/bfcl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ def list_commands(self, ctx):
)


# Input is like 'a,b,c,d', we need to transform it to ['a', 'b', 'c', 'd'] because that's the expected format in the actual main funciton
handle_multiple_input = lambda x: [
item.strip() for item in ",".join(x).split(",") if item.strip()
]
def handle_multiple_input(input_str):
"""
Input is like 'a,b,c,d', we need to transform it to ['a', 'b', 'c', 'd'] because that's the expected format in the actual main funciton
"""
if input_str is None:
"""
Cannot return None here, as typer will check the length of the return value and len(None) will raise an error
But when default is None, an empty list will be internally converted to None, and so the pipeline still works as expected
```
if default_value is None and len(value) == 0:
return None
```
"""
return []

return [item.strip() for item in ",".join(input_str).split(",") if item.strip()]


@cli.command()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ def __init__(self, model_name, temperature) -> None:

@overrides
def decode_ast(self, result, language="Python"):
# The input is already a list of dictionaries, so no need to decode
# `[{func1:{param1:val1,...}},{func2:{param2:val2,...}}]`
if type(result) != list:
return []
return result

@overrides
def decode_execute(self, result):
if type(result) != list:
return []
return convert_to_function_call(result)

@overrides
Expand Down