Skip to content

Instantly share code, notes, and snippets.

@lgastako
Created January 30, 2024 06:01
Show Gist options
  • Save lgastako/f94de517c70863c5e00272b8e11ba2a5 to your computer and use it in GitHub Desktop.
Save lgastako/f94de517c70863c5e00272b8e11ba2a5 to your computer and use it in GitHub Desktop.
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