mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
changes for lorenze
This commit is contained in:
@@ -34,7 +34,7 @@ from crewai import Pipeline
|
||||
# Uncomment the crews you need for your chosen example
|
||||
from .crews.research_crew.research_crew import ResearchCrew
|
||||
from .crews.write_x_crew.write_x_crew import WriteXCrew
|
||||
# from .crews.write_linkedin_crew import WriteLinkedInCrew # Uncomment for Example 2
|
||||
# from .crews.write_linkedin_crew.write_linkedin_crew import WriteLinkedInCrew # Uncomment for Example 2
|
||||
|
||||
# EXAMPLE 1: Two-Stage Pipeline
|
||||
# -----------------------------
|
||||
@@ -53,7 +53,7 @@ class {{pipeline_name}}Pipeline:
|
||||
self.write_x_crew
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
async def kickoff(self, inputs):
|
||||
pipeline = self.create_pipeline()
|
||||
results = await pipeline.kickoff(inputs)
|
||||
|
||||
@@ -1,17 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
import asyncio
|
||||
from {{folder_name}}.src.{{folder_name}}.pipeline import {{pipeline_name}}Pipeline
|
||||
from {
|
||||
|
||||
from crewai.routers.router import Route{folder_name}}.pipeline import {{pipeline_name}}Pipeline
|
||||
|
||||
async def run():
|
||||
"""
|
||||
Run the pipeline.
|
||||
"""
|
||||
inputs = [
|
||||
{"topic": "AI LLMs"},
|
||||
{"topic": "AI wearables"},
|
||||
]
|
||||
await {{pipeline_name}}Pipeline().pipeline().kickoff(inputs=inputs)
|
||||
|
||||
# TODO: Pull all of these out dynamically from the /pipelines folder
|
||||
pipeline_categorzie = {{pipeline_name}}Pipeline()
|
||||
pipeline_high_priority = {{pipeline_name}}Pipeline()
|
||||
pipeline_low_priority = {{pipeline_name}}Pipeline()
|
||||
|
||||
router = Router(
|
||||
routes={
|
||||
"high_urgency": Route(
|
||||
condition=lambda x: x.get("urgency_score", 0) > 7,
|
||||
pipeline=pipeline_high_priority
|
||||
),
|
||||
"low_urgency": Route(
|
||||
condition=lambda x: x.get("urgency_score", 0) <= 7,
|
||||
pipeline=pipeline_low_priority
|
||||
)
|
||||
},
|
||||
default=Pipeline(stages=[pipeline_low_priority])
|
||||
)
|
||||
|
||||
pipeline = pipeline_categorzie >> router
|
||||
|
||||
results = await pipeline.kickoff(inputs)
|
||||
|
||||
# Process and print results
|
||||
for result in results:
|
||||
print(f"Raw output: {result.raw}")
|
||||
if result.json_dict:
|
||||
print(f"JSON output: {result.json_dict}")
|
||||
print("\n")
|
||||
|
||||
def main():
|
||||
asyncio.run(run())
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run())
|
||||
main()
|
||||
Reference in New Issue
Block a user