parent
b640688995
commit
80171b0e4f
@ -1,16 +1,33 @@
|
||||
from swarms.swarms import ModelParallelizer
|
||||
from swarms.models import OpenAIChat
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
api_key = ""
|
||||
from swarms.models import Anthropic, Gemini, Mixtral, OpenAIChat
|
||||
from swarms.swarms import ModelParallelizer
|
||||
|
||||
llm = OpenAIChat(openai_api_key=api_key)
|
||||
load_dotenv()
|
||||
|
||||
# API Keys
|
||||
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
|
||||
openai_api_key = os.getenv("OPENAI_API_KEY")
|
||||
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
||||
|
||||
llms = [llm, llm, llm]
|
||||
# Initialize the models
|
||||
llm = OpenAIChat(openai_api_key=openai_api_key)
|
||||
anthropic = Anthropic(anthropic_api_key=anthropic_api_key)
|
||||
mixtral = Mixtral()
|
||||
gemini = Gemini(gemini_api_key=gemini_api_key)
|
||||
|
||||
god_mode = ModelParallelizer(llms)
|
||||
# Initialize the parallelizer
|
||||
llms = [llm, anthropic, mixtral, gemini]
|
||||
parallelizer = ModelParallelizer(llms)
|
||||
|
||||
# Set the task
|
||||
task = "Generate a 10,000 word blog on health and wellness."
|
||||
|
||||
out = god_mode.run(task)
|
||||
god_mode.print_responses(task)
|
||||
# Run the task
|
||||
out = parallelizer.run(task)
|
||||
|
||||
# Print the responses 1 by 1
|
||||
for i in range(len(out)):
|
||||
print(f"Response from LLM {i}: {out[i]}")
|
Loading…
Reference in new issue