Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Nov 7, 2023
1 parent 4c6bbad commit 8dc9064
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/swarms/models/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <kye@apac.ai>"]
Expand Down
4 changes: 2 additions & 2 deletions swarms/agents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -17,6 +17,6 @@
"Message",
"AbstractAgent",
"Registry",
"Idea2Image",
# "Idea2Image",
"SimpleAgent",
]
2 changes: 1 addition & 1 deletion swarms/agents/idea_to_image_agent.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
5 changes: 4 additions & 1 deletion swarms/models/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."""
Expand All @@ -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",
Expand Down

0 comments on commit 8dc9064

Please sign in to comment.