RozzaCreat commited on
Commit
9a810c7
·
verified ·
1 Parent(s): 2c232d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +90 -29
app.py CHANGED
@@ -8,42 +8,103 @@ from tools.final_answer import FinalAnswerTool
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
- @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
- Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
- """
19
- # return "What magic will you build uu?"
20
  # @tool
21
- # def literature_review_query(topic: str) -> str: # it's important to specify the return type
22
- # """A tool to generate an optimized query for finding the best research articles on Google Scholar.
23
-
24
  # Args:
25
- # topic: The topic of the literature review.
26
-
27
- # Returns:
28
- # A well-structured search query to use in Google Scholar.
29
  # """
30
- # query = f'"{topic}" OR "{topic} review" OR "latest research on {topic}" site:scholar.google.com'
31
- # return query
32
-
33
  @tool
34
- def generate_tshirt_image(word: str, style: str) -> str:
35
- """Generates an image of a plain white T-shirt with the given word printed in a specified style.
36
 
37
  Args:
38
- word: The word to be displayed on the T-shirt.
39
- style: The text style or color (e.g., 'bold black', 'red cursive', 'blue graffiti').
40
-
41
- Returns:
42
- A URL or image file of the generated T-shirt.
43
  """
44
- prompt = f"A plain white T-shirt with the word '{word}' printed in {style} font on the front."
45
- image = image_generation_tool(prompt)
46
- return image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  @tool
49
  def get_current_time_in_timezone(timezone: str) -> str:
 
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
 
 
 
 
 
 
 
 
11
  # @tool
12
+ # def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
+ # #Keep this format for the description / args / args description but feel free to modify the tool
14
+ # """A tool that does nothing yet
15
  # Args:
16
+ # arg1: the first argument
17
+ # arg2: the second argument
 
 
18
  # """
19
+ # return "What magic will you build ?"
 
 
20
  @tool
21
+ def generate_coloring_pages(age: int, gender: str) -> str:
22
+ """A tool that generates age and gender-appropriate coloring page suggestions for kids.
23
 
24
  Args:
25
+ age: The age of the child (1-12)
26
+ gender: The gender of the child ('boy', 'girl', or 'neutral')
 
 
 
27
  """
28
+ # Validate inputs
29
+ if not isinstance(age, int) or age < 1 or age > 12:
30
+ return "Please provide a valid age between 1 and 12."
31
+
32
+ if gender.lower() not in ['boy', 'girl', 'neutral']:
33
+ return "Please specify gender as 'boy', 'girl', or 'neutral'."
34
+
35
+ gender = gender.lower()
36
+
37
+ # Age-appropriate themes dictionary
38
+ coloring_themes = {
39
+ # Ages 1-3: Simple, large shapes with thick lines
40
+ (1, 3): {
41
+ 'boy': ['Farm animals', 'Simple dinosaurs', 'Cars and trucks', 'Balls and blocks'],
42
+ 'girl': ['Farm animals', 'Butterflies', 'Flowers', 'Simple princesses'],
43
+ 'neutral': ['Farm animals', 'Shapes', 'Fruits', 'Weather', 'Ocean creatures']
44
+ },
45
+ # Ages 4-6: More detailed but still simple
46
+ (4, 6): {
47
+ 'boy': ['Superheroes', 'Dinosaurs', 'Construction vehicles', 'Space and planets', 'Dragons'],
48
+ 'girl': ['Mermaids', 'Fairies', 'Unicorns', 'Princesses', 'Butterflies'],
49
+ 'neutral': ['Animals', 'Sea creatures', 'Insects', 'Nature scenes', 'Food items']
50
+ },
51
+ # Ages 7-9: More detailed with medium complexity
52
+ (7, 9): {
53
+ 'boy': ['Action heroes', 'Sports', 'Robots', 'Monsters', 'Video game characters'],
54
+ 'girl': ['Fashion', 'Pets', 'Magical creatures', 'Dance', 'Gardens'],
55
+ 'neutral': ['Landscapes', 'Famous landmarks', 'Patterns', 'Wildlife', 'Under the sea']
56
+ },
57
+ # Ages 10-12: Complex designs, fine details
58
+ (10, 12): {
59
+ 'boy': ['Detailed dragons', 'Comic book heroes', 'Historical scenes', 'Sci-fi', 'Adventure scenes'],
60
+ 'girl': ['Intricate patterns', 'Fashion design', 'Fantasy scenes', 'Famous art recreations', 'Elegant animals'],
61
+ 'neutral': ['Mandalas', 'Abstract patterns', 'Optical illusions', 'World cultures', 'Detailed landscapes']
62
+ }
63
+ }
64
+
65
+ # Find the appropriate age range
66
+ age_range = None
67
+ for age_range_key in coloring_themes.keys():
68
+ min_age, max_age = age_range_key
69
+ if min_age <= age <= max_age:
70
+ age_range = age_range_key
71
+ break
72
+
73
+ # Prepare response
74
+ themes = coloring_themes[age_range][gender]
75
+
76
+ # Recommendations for specific age characteristics
77
+ age_specific_tips = {
78
+ (1, 3): "Use very simple, bold outlines with minimal details. Larger pictures work best.",
79
+ (4, 6): "Include some basic details but keep designs uncomplicated. Medium-sized pictures work well.",
80
+ (7, 9): "Add more details and slightly more complex scenes. Standard-sized coloring pages are appropriate.",
81
+ (10, 12): "Incorporate fine details, more realistic proportions, and complex scenes. Intricate designs will be appreciated."
82
+ }
83
+
84
+ # Educational benefits by age
85
+ educational_benefits = {
86
+ (1, 3): "Helps develop fine motor skills and color recognition.",
87
+ (4, 6): "Enhances hand-eye coordination and introduces basic concepts like shapes and patterns.",
88
+ (7, 9): "Improves concentration and artistic expression while reinforcing learned concepts.",
89
+ (10, 12): "Develops patience, attention to detail, and artistic techniques while providing stress relief."
90
+ }
91
+
92
+ response = f"Coloring Page Suggestions for a {age}-year-old {gender}:\n\n"
93
+ response += "Recommended themes:\n"
94
+ for theme in themes:
95
+ response += f"- {theme}\n"
96
+
97
+ response += f"\nAge-appropriate tip: {age_specific_tips[age_range]}\n"
98
+ response += f"\nEducational benefit: {educational_benefits[age_range]}\n"
99
+
100
+ # Add suggestion for where to find these coloring pages
101
+ response += "\nWhere to find these coloring pages:\n"
102
+ response += "1. Free printable websites like Education.com, Crayola.com, or ColoringPages101.com\n"
103
+ response += "2. Coloring books specifically designed for this age group at bookstores\n"
104
+ response += "3. Downloadable PDF collections on craft websites\n"
105
+ response += "4. Educational websites that focus on childhood development\n"
106
+
107
+ return response
108
 
109
  @tool
110
  def get_current_time_in_timezone(timezone: str) -> str: