André Oriani commited on
Commit
26b3170
·
1 Parent(s): 9799a54

Move to dalle3

Browse files
Files changed (1) hide show
  1. main.py +13 -3
main.py CHANGED
@@ -3,9 +3,18 @@ from textwrap import dedent
3
  from crewai import Agent, Task, Crew, Process
4
  from typing import List
5
  from pydantic import BaseModel, Field
6
- from langchain.agents import load_tools
7
  import asyncio
8
  from concurrent.futures import ThreadPoolExecutor
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  class Step(BaseModel):
@@ -46,7 +55,7 @@ illustrator = Agent(
46
  backstory=dedent(""" You are a really capable artist that can draw very photo-realistic illustration
47
  for each step of a recipe.
48
  """),
49
- tools=load_tools(["dalle-image-generator"]),
50
  verbose=True,
51
  memory=True
52
  )
@@ -69,7 +78,8 @@ rewrite_task = Task(
69
  )
70
 
71
  illustrate_task = Task(
72
- description=dedent("""For each step the recipe create a photo-realistic illustration. Please keep the full URL for images as they were provided by the tool"""),
 
73
  context=[recipe_task],
74
  expected_output="The list of ingredients and a list containing each step of recipe along with the link to the its respective illustration. Please keep the entire url for the images, do not short them.",
75
  agent=illustrator
 
3
  from crewai import Agent, Task, Crew, Process
4
  from typing import List
5
  from pydantic import BaseModel, Field
 
6
  import asyncio
7
  from concurrent.futures import ThreadPoolExecutor
8
+ from langchain_community.utilities.dalle_image_generator import DallEAPIWrapper
9
+
10
+ from langchain_core.tools import Tool
11
+
12
+ dalle3 = Tool(
13
+ "Dall-E-Image-Generator",
14
+ DallEAPIWrapper(model="dall-e-3").run,
15
+ "A wrapper around OpenAI DALL-E API. Useful for when you need to generate images from a text description. Input "
16
+ "should be an image description.",
17
+ )
18
 
19
 
20
  class Step(BaseModel):
 
55
  backstory=dedent(""" You are a really capable artist that can draw very photo-realistic illustration
56
  for each step of a recipe.
57
  """),
58
+ tools=[dalle3],
59
  verbose=True,
60
  memory=True
61
  )
 
78
  )
79
 
80
  illustrate_task = Task(
81
+ description=dedent(
82
+ """For each step the recipe create a photo-realistic illustration. Please keep the full URL for images as they were provided by the tool"""),
83
  context=[recipe_task],
84
  expected_output="The list of ingredients and a list containing each step of recipe along with the link to the its respective illustration. Please keep the entire url for the images, do not short them.",
85
  agent=illustrator