You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/playground/agents/meta_prompter.py

25 lines
547 B

1 year ago
from swarms.workers import Worker
1 year ago
from swarms.agents.meta_prompter import MetaPrompterAgent
from swarms.models import OpenAI
1 year ago
1 year ago
# init llm
1 year ago
llm = OpenAI()
1 year ago
# init the meta prompter agent that optimized prompts
1 year ago
meta_optimizer = MetaPrompterAgent(llm=llm)
1 year ago
1 year ago
# init the worker agent
1 year ago
worker = Worker(llm)
1 year ago
1 year ago
# broad task to complete
1 year ago
task = "Create a feedforward in pytorch"
1 year ago
# optimize the prompt
optimized_prompt = meta_optimizer.run(task)
1 year ago
1 year ago
# run the optimized prompt with detailed instructions
1 year ago
result = worker.run(optimized_prompt)
1 year ago
# print
print(result)