Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use marshalling for function calls #13

Merged
merged 8 commits into from
Oct 26, 2024
Merged

Use marshalling for function calls #13

merged 8 commits into from
Oct 26, 2024

Conversation

thekid
Copy link
Member

@thekid thekid commented Oct 26, 2024

Example

use com\mongodb\{Collection, ObjectId};
use com\openai\tools\Functions;

$conn= ...
$users= $conn->collection('database', 'users');

$functions= (new Functions())->register('testing', new class($users) {
  public function __construct(private Collection $users) { }

  public function user(ObjectId $id) {
    return $this->users->find($id)->first();
  }
});

$result= $functions->calls()->call('testing_user', '{"id": "507f1f77bcf86cd799439011"}');

The LLM will pass a user ID per string to the function, which will unmarshal it to an ObjectId. The returned Document will be marshalled to its properties, and yielded as a JSON object.

@thekid thekid added the enhancement New feature or request label Oct 26, 2024
@thekid thekid merged commit 1ba020a into main Oct 26, 2024
12 checks passed
@thekid thekid deleted the feature/marshalling branch October 26, 2024 19:43
@thekid
Copy link
Member Author

thekid commented Oct 26, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant