Working on cool stuff
This commit is contained in:
parent
0143e7d44e
commit
d030a98ba2
|
@ -17,18 +17,21 @@ def search(query: str):
|
||||||
return "It's 60 degrees and foggy."
|
return "It's 60 degrees and foggy."
|
||||||
return "It's 90 degrees and sunny."
|
return "It's 90 degrees and sunny."
|
||||||
|
|
||||||
def wrap(class_, method):
|
def wrap_method(class_, method):
|
||||||
logger.debug("Wrapping %s.%s", class_.__name__, method.__name__)
|
logger.info("Wrapping %s.%s", class_.__name__, method.__name__)
|
||||||
is_iterator = str(method.__annotations__.get('return', '')).startswith('collections.abc.Iterator')
|
is_iterator = str(method.__annotations__.get('return', '')).startswith('collections.abc.Iterator')
|
||||||
def wrapper(input):
|
|
||||||
logger.info("AI called %s.%s(%s)", class_.__name__, method.__name__, input)
|
def wrapper(input_value):
|
||||||
result = method(input)
|
if isinstance(input_value, dict):
|
||||||
|
logger.warning("Silently converting from dict to plain value!")
|
||||||
|
input_value = next(input_value.values())
|
||||||
|
logger.info("AI called %s.%s(%s)", class_.__name__, method.__name__, repr(input_value))
|
||||||
|
result = method(input_value)
|
||||||
if is_iterator:
|
if is_iterator:
|
||||||
result = list(result)
|
result = list(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
#wrapper.__name__ = f'{class_.__name__}.{method.__name__}'
|
wrapper.__name__ = f'{class_.__name__}.{method.__name__}'
|
||||||
wrapper.__name__ = f'{method.__name__}'
|
|
||||||
wrapper.__doc__ = method.__doc__
|
wrapper.__doc__ = method.__doc__
|
||||||
wrapper.__annotations__ = method.__annotations__
|
wrapper.__annotations__ = method.__annotations__
|
||||||
return tool(wrapper)
|
return tool(wrapper)
|
||||||
|
@ -42,7 +45,7 @@ def wrap_all_methods_on_client(obj):
|
||||||
continue
|
continue
|
||||||
if method.__doc__ is None:
|
if method.__doc__ is None:
|
||||||
continue
|
continue
|
||||||
yield wrap(obj.__class__, method)
|
yield wrap_method(obj.__class__, method)
|
||||||
|
|
||||||
def get_tools():
|
def get_tools():
|
||||||
session = requests_cache.CachedSession('output/test.sqlite')
|
session = requests_cache.CachedSession('output/test.sqlite')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user