php-llm / llm-chain

PHP library for building LLM-based features and applications.
MIT License
12 stars 3 forks source link

Empower tools to return whatever they want instead of `string` #132

Open chr-hertel opened 1 month ago

chr-hertel commented 1 month ago

Currently tools can only return string which makes sense in the first place since we need to provide the LLM a stringy result, but in the end it would be beneficial for users to just mark basically any public method, that returns something, as tool.

One example would be a ProductRepository->findByName(string $name): Product

By default it would be one solution to just call the serializer for array and object to serialize to json.

potentially later we could extend the AsTool config to cover the serializer context as well - enabling groups or similar.