flow -> example.py

Former-commit-id: 2f31a63494
jojo-group-chat
Kye 1 year ago
parent c7648510ff
commit 89dffeb46c

@ -1,24 +1,35 @@
from swarms.models import OpenAIChat from swarms.models import OpenAIChat
from swarms import Worker from swarms.structs import Flow
from swarms.prompts import PRODUCT_AGENT_PROMPT
api_key = "" api_key = ""
# Initialize the language model, this model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC
llm = OpenAIChat( llm = OpenAIChat(
# model_name="gpt-4"
openai_api_key=api_key, openai_api_key=api_key,
temperature=0.5, temperature=0.5,
#max_tokens=100,
) )
node = Worker( ## Initialize the workflow
flow = Flow(
llm=llm, llm=llm,
ai_name="Optimus Prime", max_loops=1,
openai_api_key=api_key, dashboard=True,
ai_role=PRODUCT_AGENT_PROMPT, # stopping_condition=None, # You can define a stopping condition as needed.
external_tools=None, # loop_interval=1,
human_in_the_loop=False, # retry_attempts=3,
temperature=0.5, # retry_interval=1,
# interactive=False, # Set to 'True' for interactive mode.
# dynamic_temperature=False, # Set to 'True' for dynamic temperature handling.
) )
task = "Locate 5 trending topics on healthy living, locate a website like NYTimes, and then generate an image of people doing those topics." # out = flow.load_state("flow_state.json")
response = node.run(task) # temp = flow.dynamic_temperature()
print(response) # filter = flow.add_response_filter("Trump")
out = flow.run("Generate a 10,000 word blog on health and wellness.")
# out = flow.validate_response(out)
# out = flow.analyze_feedback(out)
# out = flow.print_history_and_memory()
# out = flow.save_state("flow_state.json")
print(out)

@ -1,34 +0,0 @@
from swarms.models import OpenAIChat
from swarms.structs import Flow
api_key = ""
# Initialize the language model, this model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC
llm = OpenAIChat(
openai_api_key=api_key,
temperature=0.5,
max_tokens=3000,
)
## Initialize the workflow
flow = Flow(
llm=llm,
max_loops=1,
dashboard=True,
# stopping_condition=None, # You can define a stopping condition as needed.
# loop_interval=1,
# retry_attempts=3,
# retry_interval=1,
# interactive=False, # Set to 'True' for interactive mode.
# dynamic_temperature=False, # Set to 'True' for dynamic temperature handling.
)
# 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.validate_response(out)
# out = flow.analyze_feedback(out)
# out = flow.print_history_and_memory()
# out = flow.save_state("flow_state.json")
print(out)
Loading…
Cancel
Save