From e01f25a9ff433002b14b0410887672820893a327 Mon Sep 17 00:00:00 2001 From: Kye Date: Mon, 6 Nov 2023 19:08:13 -0500 Subject: [PATCH] clean up Former-commit-id: 8dc90648199f222582ef490a74931dbb45eb1cf2 --- docs/swarms/models/anthropic.md | 2 +- example.py | 6 ++++-- demos/positive_med.py => positive_med.py | 0 pyproject.toml | 2 +- swarms/agents/__init__.py | 4 ++-- swarms/agents/idea_to_image_agent.py | 2 +- swarms/models/anthropic.py | 5 ++++- 7 files changed, 13 insertions(+), 8 deletions(-) rename demos/positive_med.py => positive_med.py (100%) diff --git a/docs/swarms/models/anthropic.md b/docs/swarms/models/anthropic.md index cf139f761..85e7a4284 100644 --- a/docs/swarms/models/anthropic.md +++ b/docs/swarms/models/anthropic.md @@ -73,7 +73,7 @@ from swarms.models import Anthropic # Initialize an instance of the Anthropic class model = Anthropic( - anthropic_api_key="sk-" + anthropic_api_key="" ) # Using the run method diff --git a/example.py b/example.py index 8e34cce36..b3740aa22 100644 --- a/example.py +++ b/example.py @@ -11,11 +11,13 @@ # max_tokens=100, ) + ## Initialize the workflow flow = Flow( llm=llm, - max_loops=2, + max_loops=5, dashboard=True, + # tools = [search_api, slack, ] # stopping_condition=None, # You can define a stopping condition as needed. # loop_interval=1, # retry_attempts=3, @@ -27,7 +29,7 @@ # out = flow.load_state("flow_state.json") # temp = flow.dynamic_temperature() # filter = flow.add_response_filter("Trump") -out = flow.run("Generate a 10,000 word blog on health and wellness.") +out = flow.run("Generate a 10,000 word blog on mental clarity and the benefits of meditation.") # out = flow.validate_response(out) # out = flow.analyze_feedback(out) # out = flow.print_history_and_memory() diff --git a/demos/positive_med.py b/positive_med.py similarity index 100% rename from demos/positive_med.py rename to positive_med.py diff --git a/pyproject.toml b/pyproject.toml index 6aa8585da..a80b63899 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "1.9.9" +version = "2.0.1" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms/agents/__init__.py b/swarms/agents/__init__.py index 597c8c767..34dc0f1d2 100644 --- a/swarms/agents/__init__.py +++ b/swarms/agents/__init__.py @@ -5,7 +5,7 @@ # from swarms.agents.stream_response import stream from swarms.agents.base import AbstractAgent from swarms.agents.registry import Registry -from swarms.agents.idea_to_image_agent import Idea2Image +# from swarms.agents.idea_to_image_agent import Idea2Image from swarms.agents.simple_agent import SimpleAgent @@ -17,6 +17,6 @@ "Message", "AbstractAgent", "Registry", - "Idea2Image", + # "Idea2Image", "SimpleAgent", ] diff --git a/swarms/agents/idea_to_image_agent.py b/swarms/agents/idea_to_image_agent.py index f7e5ec0c8..ce3654e05 100644 --- a/swarms/agents/idea_to_image_agent.py +++ b/swarms/agents/idea_to_image_agent.py @@ -1,7 +1,7 @@ import os import logging from dataclasses import dataclass -from playground.models.dalle3 import Dalle +from swarms.models.dalle3 import Dalle from swarms.models import OpenAIChat diff --git a/swarms/models/anthropic.py b/swarms/models/anthropic.py index e20666372..9914fce90 100644 --- a/swarms/models/anthropic.py +++ b/swarms/models/anthropic.py @@ -44,6 +44,7 @@ def __init__( top_p=None, streaming=False, default_request_timeout=None, + api_key: str = None ): self.model = model self.max_tokens_to_sample = max_tokens_to_sample @@ -56,6 +57,7 @@ def __init__( "ANTHROPIC_API_URL", "https://api.anthropic.com" ) self.anthropic_api_key = os.getenv("ANTHROPIC_API_KEY") + self.api_key = api_key def _default_params(self): """Get the default parameters for calling Anthropic API.""" @@ -73,9 +75,10 @@ def _default_params(self): def run(self, task: str, stop=None): """Call out to Anthropic's completion endpoint.""" + api_key = self.api_key or self.anthropic_api_key stop = stop or [] params = self._default_params() - headers = {"Authorization": f"Bearer {self.anthropic_api_key}"} + headers = {"Authorization": f"Bearer {api_key}"} data = {"prompt": task, "stop_sequences": stop, **params} response = requests.post( f"{self.anthropic_api_url}/completions",