Naveen671 commited on
Commit
53a552a
·
verified ·
1 Parent(s): 8b8e734

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -6,10 +6,10 @@ import yaml
6
  from tools.final_answer import FinalAnswerTool
7
  from Gradio_UI import GradioUI
8
 
9
- # Enhanced custom tool for anime image generation
10
  @tool
11
- def anime_image_generator(description: str, style: str = "anime") -> str:
12
- """A tool that generates anime-style images based on user descriptions.
13
 
14
  Args:
15
  description: Detailed description of the anime image to generate
@@ -18,18 +18,19 @@ def anime_image_generator(description: str, style: str = "anime") -> str:
18
  try:
19
  # Enhance the prompt with anime-specific keywords
20
  anime_keywords = {
21
- "anime": "anime style, high quality, detailed, vibrant colors, japanese animation style",
22
- "manga": "manga style, black and white, detailed lineart, dramatic shading",
23
- "kawaii": "kawaii style, cute, adorable, pastel colors, chibi proportions",
24
- "realistic_anime": "realistic anime style, detailed face, expressive eyes, high resolution"
25
  }
26
 
27
  style_prompt = anime_keywords.get(style, anime_keywords["anime"])
28
- enhanced_description = f"{description}, {style_prompt}, masterpiece, best quality"
29
 
30
- return f"Generated anime image with description: '{enhanced_description}' in {style} style"
 
31
  except Exception as e:
32
- return f"Error generating anime image: {str(e)}"
33
 
34
  @tool
35
  def analyze_image_description(user_input: str) -> str:
@@ -129,15 +130,18 @@ with open("prompts.yaml", 'r') as stream:
129
  # Create the agent with anime-focused tools
130
  tools_list = [
131
  final_answer,
132
- anime_image_generator,
133
  analyze_image_description,
134
  enhance_anime_prompt,
135
  get_current_time_in_timezone
136
  ]
137
 
138
- # Add the image generation tool if it loaded successfully
139
  if image_generation_tool:
140
  tools_list.append(image_generation_tool)
 
 
 
141
 
142
  agent = CodeAgent(
143
  model=model,
 
6
  from tools.final_answer import FinalAnswerTool
7
  from Gradio_UI import GradioUI
8
 
9
+ # Enhanced custom tool for anime image generation using the actual image generation tool
10
  @tool
11
+ def generate_anime_image(description: str, style: str = "anime") -> str:
12
+ """A tool that generates actual anime-style images based on user descriptions.
13
 
14
  Args:
15
  description: Detailed description of the anime image to generate
 
18
  try:
19
  # Enhance the prompt with anime-specific keywords
20
  anime_keywords = {
21
+ "anime": "anime style, high quality, detailed, vibrant colors, japanese animation style, 2d animation",
22
+ "manga": "manga style, black and white, detailed lineart, dramatic shading, monochrome",
23
+ "kawaii": "kawaii style, cute, adorable, pastel colors, chibi proportions, moe",
24
+ "realistic_anime": "realistic anime style, detailed face, expressive eyes, high resolution, semi-realistic"
25
  }
26
 
27
  style_prompt = anime_keywords.get(style, anime_keywords["anime"])
28
+ enhanced_description = f"{description}, {style_prompt}, masterpiece, best quality, detailed artwork"
29
 
30
+ # This will be used with the actual image generation tool in the agent workflow
31
+ return enhanced_description
32
  except Exception as e:
33
+ return f"Error preparing anime image prompt: {str(e)}"
34
 
35
  @tool
36
  def analyze_image_description(user_input: str) -> str:
 
130
  # Create the agent with anime-focused tools
131
  tools_list = [
132
  final_answer,
133
+ generate_anime_image,
134
  analyze_image_description,
135
  enhance_anime_prompt,
136
  get_current_time_in_timezone
137
  ]
138
 
139
+ # Add the image generation tool if it loaded successfully - this is the key tool for actual image generation
140
  if image_generation_tool:
141
  tools_list.append(image_generation_tool)
142
+ print("Image generation tool loaded successfully!")
143
+ else:
144
+ print("Warning: Image generation tool not available - only text descriptions will be provided")
145
 
146
  agent = CodeAgent(
147
  model=model,