Former-commit-id: 8dc9064819
jojo-group-chat
Kye 1 year ago
parent f079e099af
commit e01f25a9ff

@ -73,7 +73,7 @@ from swarms.models import Anthropic
# Initialize an instance of the Anthropic class # Initialize an instance of the Anthropic class
model = Anthropic( model = Anthropic(
anthropic_api_key="sk-" anthropic_api_key=""
) )
# Using the run method # Using the run method

@ -11,11 +11,13 @@ llm = OpenAIChat(
# max_tokens=100, # max_tokens=100,
) )
## Initialize the workflow ## Initialize the workflow
flow = Flow( flow = Flow(
llm=llm, llm=llm,
max_loops=2, max_loops=5,
dashboard=True, dashboard=True,
# tools = [search_api, slack, ]
# stopping_condition=None, # You can define a stopping condition as needed. # stopping_condition=None, # You can define a stopping condition as needed.
# loop_interval=1, # loop_interval=1,
# retry_attempts=3, # retry_attempts=3,
@ -27,7 +29,7 @@ flow = Flow(
# out = flow.load_state("flow_state.json") # out = flow.load_state("flow_state.json")
# temp = flow.dynamic_temperature() # temp = flow.dynamic_temperature()
# filter = flow.add_response_filter("Trump") # 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.validate_response(out)
# out = flow.analyze_feedback(out) # out = flow.analyze_feedback(out)
# out = flow.print_history_and_memory() # out = flow.print_history_and_memory()

@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "swarms" name = "swarms"
version = "1.9.9" version = "2.0.1"
description = "Swarms - Pytorch" description = "Swarms - Pytorch"
license = "MIT" license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"] authors = ["Kye Gomez <kye@apac.ai>"]

@ -5,7 +5,7 @@ from swarms.agents.message import Message
# from swarms.agents.stream_response import stream # from swarms.agents.stream_response import stream
from swarms.agents.base import AbstractAgent from swarms.agents.base import AbstractAgent
from swarms.agents.registry import Registry 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 from swarms.agents.simple_agent import SimpleAgent
@ -17,6 +17,6 @@ __all__ = [
"Message", "Message",
"AbstractAgent", "AbstractAgent",
"Registry", "Registry",
"Idea2Image", # "Idea2Image",
"SimpleAgent", "SimpleAgent",
] ]

@ -1,7 +1,7 @@
import os import os
import logging import logging
from dataclasses import dataclass from dataclasses import dataclass
from playground.models.dalle3 import Dalle from swarms.models.dalle3 import Dalle
from swarms.models import OpenAIChat from swarms.models import OpenAIChat

@ -44,6 +44,7 @@ class Anthropic:
top_p=None, top_p=None,
streaming=False, streaming=False,
default_request_timeout=None, default_request_timeout=None,
api_key: str = None
): ):
self.model = model self.model = model
self.max_tokens_to_sample = max_tokens_to_sample self.max_tokens_to_sample = max_tokens_to_sample
@ -56,6 +57,7 @@ class Anthropic:
"ANTHROPIC_API_URL", "https://api.anthropic.com" "ANTHROPIC_API_URL", "https://api.anthropic.com"
) )
self.anthropic_api_key = os.getenv("ANTHROPIC_API_KEY") self.anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
self.api_key = api_key
def _default_params(self): def _default_params(self):
"""Get the default parameters for calling Anthropic API.""" """Get the default parameters for calling Anthropic API."""
@ -73,9 +75,10 @@ class Anthropic:
def run(self, task: str, stop=None): def run(self, task: str, stop=None):
"""Call out to Anthropic's completion endpoint.""" """Call out to Anthropic's completion endpoint."""
api_key = self.api_key or self.anthropic_api_key
stop = stop or [] stop = stop or []
params = self._default_params() 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} data = {"prompt": task, "stop_sequences": stop, **params}
response = requests.post( response = requests.post(
f"{self.anthropic_api_url}/completions", f"{self.anthropic_api_url}/completions",

Loading…
Cancel
Save