Closed rzc331 closed 1 year ago
Thank you for your issue.
The code you referenced means convert str
to string
which's the standard type name of str arg in function schema and other type (e.g int
float
) don't need to convert.
As for the list
and dict
types you mentioned, I haven't tested them yet. Can you provide some sample functions?
The code you referenced means convert
str
tostring
which's the standard type name of str arg in function schema and other type (e.gint
float
) don't need to convert.
I tried int, and got the error code
'int' is not valid under any of the given schemas
As for the
list
anddict
types you mentioned, I haven't tested them yet. Can you provide some sample functions?
I wrote a dummy function:
def create_shopping_list(shopping_list: list):
"""
Create a shopping list that we should buy today
Args:
shopping_list(list): a list of the chemicals that we need to buy today
Returns:
String of all the item in the shopping list
"""
return ', '.join(shopping_list)
which will cause the error TypeError: __str__ returned non-string (type list)
I mentioned above when we ask the first prompt
As long as we change the type from list to str, it works
fixed, upgrade CallingGPT
and try:
def hello() -> None:
"""Print "Hello, world!"""
print("Hello, world!")
def greet(user: str) -> str:
"""Return a greeting to `user`.
Args:
user: the name to greet
"""
return "Hello, {}!".format(user)
def add_up(a: int, b: float) -> float:
"""Add `a` and `b` and return the result.
Args:
a: the first number
b: the second number
"""
return a + b
def get_not(b: bool) -> bool:
"""Return the opposite of `b`.
Args:
b: the boolean to negate
"""
return not b
def list_to_str(l: list[int]) -> str: # if you don't specific the type of list element, the type will be set to `string` by default
"""Return a string representation of `l`.
Args:
l: the list to convert
"""
return str(l)
def dict_to_str(d: dict) -> str:
"""Return a string representation of `d`.
Args:
d: the dict to convert
"""
return str(d)
well, list's recursively parsing is still not supported now.
well, list's recursively parsing is still not supported now.
Thanks for prompt fix! It somehow works for me now!
Noticed another minor issue:
If a "from ... import ..." statement exists in the module, the imported function will also be parsed in the namespace. Not sure if it's desired, because the doc_str of the imported external functions may not follow the required format
Noticed another minor issue:
If a "from ... import ..." statement exists in the module, the imported function will also be parsed in the namespace. Not sure if it's desired, because the doc_str of the imported external functions may not follow the required format
fixed
I might be wrong about this, it seems that only string-type args are now supported?
https://github.com/RockChinQ/CallingGPT/blob/e49643a7001a8d556aa6e7b535eeca9528ea12a7/CallingGPT/entities/namespace.py#L92C9-L93
I tried to implement other arg types, among which I found list to be most tricky. As my understanding, one has to recursively define the type of the element in the list, until the element is not a list (e.g. List[List[str]]). There might be same issue with dict.
If the type of element in the list is not clearly defined, there will be an error like this