Skip to content

Commit

Permalink
[DOCS] [TESTS] [LAZY LOADING]
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Jan 28, 2025
1 parent bbb8f4e commit 834b9c5
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 107 deletions.
96 changes: 0 additions & 96 deletions ca_to_name.py

This file was deleted.

6 changes: 3 additions & 3 deletions docs/guides/financial_analysis_swarm_mm.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Before we dive into the code, let's briefly introduce the Swarms framework. Swar
For more information and to contribute to the project, visit the [Swarms GitHub repository](https://github.com/kyegomez/swarms). We highly recommend exploring the documentation for a deeper understanding of Swarms' capabilities.

Additional resources:
- [Swarms Discord](https://discord.com/servers/agora-999382051935506503) for community discussions
- [Swarms Discord](https://discord.gg/swarms) for community discussions
- [Swarms Twitter](https://x.com/swarms_corp) for updates
- [Swarms Spotify](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994) for podcasts
- [Swarms Blog](https://medium.com/@kyeg) for in-depth articles
Expand Down Expand Up @@ -460,7 +460,7 @@ This system provides a powerful foundation for financial analysis, but there's a

Remember, the Swarms framework is a powerful and flexible tool that can be adapted to a wide range of complex tasks beyond just financial analysis. We encourage you to explore the [Swarms GitHub repository](https://github.com/kyegomez/swarms) for more examples and inspiration.

For more in-depth discussions and community support, consider joining the [Swarms Discord](https://discord.com/servers/agora-999382051935506503). You can also stay updated with the latest developments by following [Swarms on Twitter](https://x.com/swarms_corp).
For more in-depth discussions and community support, consider joining the [Swarms Discord](https://discord.gg/swarms). You can also stay updated with the latest developments by following [Swarms on Twitter](https://x.com/swarms_corp).

If you're interested in learning more about AI and its applications in various fields, check out the [Swarms Spotify podcast](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994) and the [Swarms Blog](https://medium.com/@kyeg) for insightful articles and discussions.

Expand All @@ -474,7 +474,7 @@ By leveraging the power of multi-agent AI systems, you're well-equipped to navig


* [Swarms Github](https://github.com/kyegomez/swarms)
* [Swarms Discord](https://discord.com/servers/agora-999382051935506503)
* [Swarms Discord](https://discord.gg/swarms)
* [Swarms Twitter](https://x.com/swarms_corp)
* [Swarms Spotify](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994)
* [Swarms Blog](https://medium.com/@kyeg)
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/healthcare_blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ The table below summarizes the estimated savings for each use case:

- [book a call](https://cal.com/swarms)

- Swarms Discord: https://discord.com/servers/agora-999382051935506503
- Swarms Discord: https://discord.gg/swarms

- Swarms Twitter: https://x.com/swarms_corp

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Here you'll find references about the Swarms framework, marketplace, community,
## Community
| Section | Links |
|----------------------|--------------------------------------------------------------------------------------------|
| Community | [Discord](https://discord.com/servers/agora-999382051935506503) |
| Community | [Discord](https://discord.gg/swarms) |
| Blog | [Blog](https://medium.com/@kyeg) |
| Event Calendar | [LUMA](https://lu.ma/swarms_calendar) |
| Twitter | [Twitter](https://x.com/swarms_corp) |
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extra:
- icon: fontawesome/brands/twitter
link: https://x.com/swarms_corp
- icon: fontawesome/brands/discord
link: https://discord.com/servers/agora-999382051935506503
link: https://discord.gg/swarms

analytics:
provider: google
Expand Down
4 changes: 2 additions & 2 deletions docs/swarms_platform/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ To further enhance your understanding and usage of the Swarms Platform, explore
### Links

- [API Documentation](https://docs.swarms.world)
- [Community Forums](https://discord.com/servers/agora-999382051935506503)
- [Community Forums](https://discord.gg/swarms)
- [Tutorials and Guides](https://docs.swarms.world))
- [Support](https://discord.com/servers/agora-999382051935506503)
- [Support](https://discord.gg/swarms)

## Conclusion

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "swarms"
version = "6.9.8"
version = "6.9.9"
description = "Swarms - TGSC"
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand Down
4 changes: 4 additions & 0 deletions swarms/utils/auto_download_check_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,7 @@ def auto_check_and_download_package(
success = False

return success


if __name__ == "__main__":
print(auto_check_and_download_package("torch"))
15 changes: 13 additions & 2 deletions swarms/utils/litellm_tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
from litellm import encode

import subprocess

def count_tokens(text: str, model: str = "gpt-4o") -> int:
"""Count the number of tokens in the given text."""
try:
from litellm import encode
except ImportError:
subprocess.run(["pip", "install", "litellm"])
from litellm import encode


return len(encode(model=model, text=text))



# if __name__ == "__main__":
# print(count_tokens("Hello, how are you?"))
65 changes: 65 additions & 0 deletions tests/utils/test_auto_check_download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from swarms.utils.auto_download_check_packages import auto_check_and_download_package, check_and_install_package

def test_check_and_install_package_pip():
result = check_and_install_package("numpy", package_manager="pip")
print(f"Test result for 'numpy' installation using pip: {result}")
assert result, "Failed to install or verify 'numpy' using pip"

def test_check_and_install_package_conda():
result = check_and_install_package("numpy", package_manager="conda")
print(f"Test result for 'numpy' installation using conda: {result}")
assert result, "Failed to install or verify 'numpy' using conda"

def test_check_and_install_specific_version():
result = check_and_install_package("numpy", package_manager="pip", version="1.21.0")
print(f"Test result for specific version of 'numpy' installation using pip: {result}")
assert result, "Failed to install or verify specific version of 'numpy' using pip"

def test_check_and_install_with_upgrade():
result = check_and_install_package("numpy", package_manager="pip", upgrade=True)
print(f"Test result for 'numpy' upgrade using pip: {result}")
assert result, "Failed to upgrade 'numpy' using pip"

def test_auto_check_and_download_single_package():
result = auto_check_and_download_package("scipy", package_manager="pip")
print(f"Test result for 'scipy' installation using pip: {result}")
assert result, "Failed to install or verify 'scipy' using pip"

def test_auto_check_and_download_multiple_packages():
packages = ["scipy", "pandas"]
result = auto_check_and_download_package(packages, package_manager="pip")
print(f"Test result for multiple packages installation using pip: {result}")
assert result, f"Failed to install or verify one or more packages in {packages} using pip"

def test_auto_check_and_download_multiple_packages_with_versions():
packages = ["numpy:1.21.0", "pandas:1.3.0"]
result = auto_check_and_download_package(packages, package_manager="pip")
print(f"Test result for multiple packages with versions installation using pip: {result}")
assert result, f"Failed to install or verify one or more packages in {packages} with specific versions using pip"

# Example of running tests
if __name__ == "__main__":
try:
test_check_and_install_package_pip()
print("test_check_and_install_package_pip passed")

test_check_and_install_package_conda()
print("test_check_and_install_package_conda passed")

test_check_and_install_specific_version()
print("test_check_and_install_specific_version passed")

test_check_and_install_with_upgrade()
print("test_check_and_install_with_upgrade passed")

test_auto_check_and_download_single_package()
print("test_auto_check_and_download_single_package passed")

test_auto_check_and_download_multiple_packages()
print("test_auto_check_and_download_multiple_packages passed")

test_auto_check_and_download_multiple_packages_with_versions()
print("test_auto_check_and_download_multiple_packages_with_versions passed")

except AssertionError as e:
print(f"Test failed: {str(e)}")

0 comments on commit 834b9c5

Please sign in to comment.