Llmfuncs

Latest version: v0.2.3

Safety actively analyzes 681866 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.2.3

Release Notes

- Fix handling of nested data types

0.2.2

Release Notes

- Fix tool useage

0.2.1

Release Notes

- Added more type hints
- Minor bug fixes

0.2.0

Release Notes

- The `Tool` class encapsulates a function and its associated schema, and provides a simple API for interacting with the function (calling it and getting its schema).
- The `ToolCollection` class is a container for multiple `Tool` objects. It provides methods to add tools individually or from different sources (modules, packages, glob patterns), and also provides a method for using a tool (validating and calling the function with given JSON arguments). Additionally, it provides a method to get the schema of all its tools.
- The `add_tool` method in `ToolCollection` is versatile. You can add tools individually, or you can add them in bulk from a module, a package, or a glob pattern. This makes it easy to manage tools, especially when there are many of them spread across different modules or packages.
- The `use_tool` method is designed to handle the whole process of using a tool: it fetches the tool, validates the arguments against the tool's schema, and calls the function with the validated arguments. This simplifies the process of using a tool and reduces the risk of errors.

0.1.1

Release Notes

New Features

- Improved Type Mapping: Improved the handling of complex type hints such as `List[int]`, `Dict[str, int]`, and `Optional[str]`. Now the code is capable of handling more complex types beyond simple ones like `int`, `str`, etc. The mappings for `List` and `Dict` are now applied to the nested types.
- Added Error Handling: Added error handling for cases where type hints or docstrings are not provided. The code now throws a `ValueError` if a function doesn't have a docstring, or if a parameter is missing a type hint or a description in the docstring.

0.1.0

New Features

- The `llmfuncs` package has been created! This Python package is designed to facilitate interaction with OpenAI's ChatGPT function call API. It does this by extracting function definitions from Python modules and converting them into a schema that can be consumed by the API.
- Added the function `schema.from_function()`. This function takes a Python function and its name, and returns a schema representing the function.
- Added the function `schema.from_module()`. This function takes a Python module and returns a list of schemas, each representing one function in the module.

Known Issues

- The package does not currently handle complex type hints such as `Union` or `Optional`. This is a known limitation and these cases are currently mapped to "any" in the schema.

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.