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

return appended entire schema #665

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions swarms/tools/base_tool.py
Original file line number Diff line number Diff line change
@@ -387,6 +387,8 @@ def convert_tool_into_openai_schema(self):
"Converting tools into OpenAI function calling schema"
)

tool_schemas = []

for tool in self.tools:
# Transform the tool into a openai function calling schema
if self.check_func_if_have_docs(
@@ -398,7 +400,7 @@ def convert_tool_into_openai_schema(self):
logger.info(
f"Converting tool: {name} into a OpenAI certified function calling schema. Add documentation and type hints."
)
tool_schema_list = (
tool_schema = (
get_openai_function_schema_from_func(
tool, name=name, description=description
)
@@ -408,18 +410,21 @@ def convert_tool_into_openai_schema(self):
f"Tool {name} converted successfully into OpenAI schema"
)

# Transform the dictionary to a string
tool_schema_list = json.dumps(
tool_schema_list, indent=4
)

return tool_schema_list
tool_schemas.append(tool_schema)
else:
logger.error(
f"Tool {tool.__name__} does not have documentation or type hints, please add them to make the tool execution reliable."
)

return tool_schema_list
# Combine all tool schemas into a single schema
if tool_schemas:
combined_schema = {
"type": "function",
"functions": [schema["function"] for schema in tool_schemas]
}
return json.dumps(combined_schema, indent=4)

return None

def check_func_if_have_docs(self, func: callable):
if func.__doc__ is not None:

Unchanged files with check annotations Beta

repos:

Check warning on line 1 in .pre-commit-config.yaml

GitHub Actions / yaml-lint

1:1 [document-start] missing document start "---"
- repo: https://github.com/ambv/black
rev: 22.3.0
hooks:
- id: black

Check failure on line 5 in .pre-commit-config.yaml

GitHub Actions / yaml-lint

5:5 [indentation] wrong indentation: expected 6 but found 4
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.255'
hooks:
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.6.3
hooks:
- id: nbqa-black

Check failure on line 14 in .pre-commit-config.yaml

GitHub Actions / yaml-lint

14:5 [indentation] wrong indentation: expected 6 but found 4
additional_dependencies: [ipython==8.12, black]
- id: nbqa-ruff

Check failure on line 16 in .pre-commit-config.yaml

GitHub Actions / yaml-lint

16:20 [trailing-spaces] trailing spaces
args: ["--ignore=I001"]
additional_dependencies: [ipython==8.12, ruff]

Check failure on line 18 in .pre-commit-config.yaml

GitHub Actions / yaml-lint

18:53 [new-line-at-end-of-file] no new line character at the end of file
configuration: docs/mkdocs.yml
python:
install:
- requirements: docs/requirements.txt

Check failure on line 11 in docs/.readthedocs.yaml

GitHub Actions / yaml-lint

11:42 [new-line-at-end-of-file] no new line character at the end of file
docs_dir: '.' # replace with the correct path if your documentation files are not in the same directory as mkdocs.yml

Check warning on line 1 in docs/mkdocs.yml

GitHub Actions / yaml-lint

1:1 [document-start] missing document start "---"

Check failure on line 1 in docs/mkdocs.yml

GitHub Actions / yaml-lint

1:81 [line-length] line too long (118 > 80 characters)
site_name: Swarms
site_url: https://docs.swarms.world
site_author: Swarms
site_description: The Enterprise-Grade Production-Ready Multi-Agent Orchestration Framework

Check failure on line 5 in docs/mkdocs.yml

GitHub Actions / yaml-lint

5:81 [line-length] line too long (91 > 80 characters)
repo_name: kyegomez/swarms
repo_url: https://github.com/kyegomez/swarms
edit_uri: https://github.com/kyegomez/swarms/tree/main/docs
- search
- git-authors
- mkdocs-jupyter:
kernel_name: python3

Check failure on line 16 in docs/mkdocs.yml

GitHub Actions / yaml-lint

16:9 [indentation] wrong indentation: expected 6 but found 8
execute: false
include_source: True

Check warning on line 18 in docs/mkdocs.yml

GitHub Actions / yaml-lint

18:25 [truthy] truthy value should be one of [false, true]
include_requirejs: true
- mkdocstrings:
default_handler: python
- pymdownx.tilde
nav:
- Home:
- Overview: "index.md"

Check failure on line 140 in docs/mkdocs.yml

GitHub Actions / yaml-lint

140:5 [indentation] wrong indentation: expected 6 but found 4
# - The Vision: "swarms/framework/vision.md"
# - Docker Setup: "swarms/install/docker_setup.md"
- Our Goal; The Ultimate Multi-Agent LLM Framework for Developers: "swarms/concept/vision.md"

Check failure on line 143 in docs/mkdocs.yml

GitHub Actions / yaml-lint

143:81 [line-length] line too long (97 > 80 characters)
- Swarm Ecosystem: "swarms/concept/swarm_ecosystem.md"
- Onboarding:
- Installation: "swarms/install/install.md"
- Swarms CLI: "swarms/cli/main.md"
# - Swarms + Docker:
- Swarms Framework Architecture: "swarms/concept/framework_architecture.md"
# - Prelimary:

Check warning on line 152 in docs/mkdocs.yml

GitHub Actions / yaml-lint

152:5 [comments-indentation] comment not indented like content
# - 80/20 Rule For Agents: "swarms/prompting/8020.md"
- Managing Prompts in Production: "swarms/prompts/main.md"
- Agents:
- Edit Agents: "swarms_platform/agents/edit_agent.md"
- Telemetry API:
- PUT: "swarms_platform/telemetry/index.md"
# - Tools API:

Check warning on line 254 in docs/mkdocs.yml

GitHub Actions / yaml-lint

254:5 [comments-indentation] comment not indented like content
# - Overview: "swarms_platform/tools_api.md"
# - Add Tools: "swarms_platform/fetch_tools.md"
- Guides:
name: Docker Image CI

Check warning on line 1 in .github/workflows/docker-image.yml

GitHub Actions / yaml-lint

1:1 [document-start] missing document start "---"
on:

Check warning on line 3 in .github/workflows/docker-image.yml

GitHub Actions / yaml-lint

3:1 [truthy] truthy value should be one of [false, true]
push:
branches: [ "master" ]
pull_request:
# https://github.com/actions/labeler
name: Labeler
on: [pull_request_target]

Check warning on line 10 in .github/workflows/label.yml

GitHub Actions / yaml-lint

10:1 [truthy] truthy value should be one of [false, true]
jobs:
label:
runs-on: ubuntu-latest
#
# See https://pyre-check.org
name: Pyre

Check warning on line 16 in .github/workflows/pyre.yml

GitHub Actions / yaml-lint

16:1 [document-start] missing document start "---"
on:

Check warning on line 18 in .github/workflows/pyre.yml

GitHub Actions / yaml-lint

18:1 [truthy] truthy value should be one of [false, true]
workflow_dispatch:
push:
branches: [ "master" ]