Created
January 30, 2024 06:01
-
-
Save lgastako/f94de517c70863c5e00272b8e11ba2a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abc import ABC, abstractmethod | |
class Fn(ABC): | |
def __init__(self, | |
name, | |
description, | |
params, | |
required=None): | |
self.name = name | |
self.description = description | |
self.params = params | |
self.required = required or [] | |
@abstractmethod | |
def call(self, workspace_root: str, **params): | |
pass | |
def to_openai(self): | |
return { | |
"name": self.name, | |
"description": self.description, | |
"parameters": { | |
"type": "object", | |
"properties": self.params, | |
"required": self.required | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment