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

feat: add metadata to GET tools route #1117

Merged
merged 1 commit into from
Mar 8, 2024
Merged

feat: add metadata to GET tools route #1117

merged 1 commit into from
Mar 8, 2024

Conversation

cpacker
Copy link
Owner

@cpacker cpacker commented Mar 8, 2024

This PR adds a metadata tag to the GET tools route so that the chat UI can highlight core MemGPT functions (vs other functions) without having to rely on hardcoded string matching.

Please describe the purpose of this pull request.

  • add a metadata tags field to the tool model, return tags memgpt-base and memgpt-extras on the batteries-included functions so that it can be reflected in the chat ui
  • rename API function to 'list all tools' instead of 'list tools'

How to test

GET /tools route now provides a metadata tag (empty if not from base or extras modules):

{
	"tools": [
		{
			"name": "append_to_text_file",
			"json_schema": {
				"name": "append_to_text_file",
				"description": "Append to a text file.",
				"parameters": {
					"type": "object",
					"properties": {
						"filename": {
							"type": "string",
							"description": "The name of the file to append to."
						},
						"content": {
							"type": "string",
							"description": "Content to append to the file."
						},
						"request_heartbeat": {
							"type": "boolean",
							"description": "Request an immediate heartbeat after function execution. Set to 'true' if you want to send a follow-up message or run a follow-up function."
						}
					},
					"required": [
						"filename",
						"content",
						"request_heartbeat"
					]
				}
			},
			"tags": [
				"memgpt-extras"
			],
			"source_type": "python",
			"source_code": "def append_to_text_file(self, filename: str, content: str):\n    \"\"\"\n    Append to a text file.\n\n    Args:\n        filename (str): The name of the file to append to.\n        content (str): Content to append to the file.\n\n    Returns:\n        Optional[str]: None is always returned as this function does not produce a response.\n    \"\"\"\n    if not os.path.exists(filename):\n        raise FileNotFoundError(f\"The file '{filename}' does not exist.\")\n\n    with open(filename, \"a\", encoding=\"utf-8\") as file:\n        file.write(content + \"\\n\")\n"
		},

…a metadata tags field to the tool model, return tags memgpt-base and memgpt-extras on the batteries-included functions so that it can be reflected in the chat ui
@cpacker cpacker added the API Related to MemGPT API label Mar 8, 2024
@cpacker cpacker merged commit 7030048 into main Mar 8, 2024
4 checks passed
@cpacker cpacker deleted the tools-api-misc branch March 8, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Related to MemGPT API
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant