Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Implement creation of "function" parameters at runtime #339

Merged
merged 3 commits into from
Nov 12, 2023

Conversation

BartSoj
Copy link
Contributor

@BartSoj BartSoj commented Jul 14, 2023

It was not possible to define function parameters with custom properties such as name, type, and description at runtime. This pull request introduces an alternative way of creating a ChatFunction that allows for this.

The new ChatFunctionProperty class allows you to use a builder to add all the properties. Since the original ChatFunction class only accepts parameters that are instances of Class, I have created an additional class called ChatFunctionDynamic.

These changes make functions more flexible and powerful.

This pull request closes issue #333.

* Enable dynamic definition of "function" parameters instead of using Class instance

* Add tests to new "function" capabilities

* Add example of creating "function" parameters in runtime

* Add documentation to ChatFunctions
@Ronass
Copy link

Ronass commented Jul 20, 2023

Thanks for adding this feature, why hasn't the admin handled pr yet

@catapop84
Copy link

great job. This is a much needed feature. Hope it gets merged soon

@BartSoj
Copy link
Contributor Author

BartSoj commented Jul 31, 2023

@TheoKanning There are new features coming from open ai and it would be helpful to merge this so we can start working on them.

@kingxjs
Copy link

kingxjs commented Aug 14, 2023

Is the author still maintaining it? Why hasn't it been adopted yet

@mbayou
Copy link

mbayou commented Aug 14, 2023

Anyone with the write access could have a look? Nothing really at risk and it would give us more flexibility.

@fallbackwjj
Copy link

please merge this pr

@BartSoj
Copy link
Contributor Author

BartSoj commented Aug 25, 2023

@TheoKanning can you merge this or is there a problem?

@BartSoj BartSoj mentioned this pull request Sep 7, 2023
@@ -98,7 +98,7 @@ public class ChatCompletionRequest {
/**
* A list of the available functions.
*/
List<ChatFunction> functions;
List<?> functions;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense for ChatFunction and ChatFunctionDynamic to implement a shared interface so that this can be typed as something other than <?>?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if just extending Runnable might be a good place to start?

@TheoKanning TheoKanning merged commit 3a2d010 into TheoKanning:main Nov 12, 2023
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants