muhammadmaazuddin commited on
Commit
2853705
·
1 Parent(s): 2eaa145

feat: updated the prompt

Browse files
Files changed (3) hide show
  1. src/_agents.py +22 -14
  2. src/main.py +5 -10
  3. src/model.py +5 -0
src/_agents.py CHANGED
@@ -21,10 +21,16 @@ from io import BytesIO
21
  from IPython.display import display
22
  from google import genai
23
  import logging
 
24
 
25
 
 
 
 
26
 
27
- logging.basicConfig(level=logging.INFO)
 
 
28
 
29
 
30
  aspect_ratios = {
@@ -38,6 +44,8 @@ client = genai.Client(
38
  )
39
 
40
 
 
 
41
  #----------------------- content agent ----------------------------------
42
 
43
  def content_prompt(context: RunContextWrapper, agent: Agent):
@@ -194,7 +202,7 @@ Your goal is to generate attention-grabbing, brand-aligned images that clearly c
194
  Design Brief:
195
  {design_brief}
196
 
197
- JSON Schema:
198
  {designSpec}
199
 
200
  Design Guidelines:
@@ -290,7 +298,7 @@ You are Media Agent, a professional and specialized in creating social media for
290
  Your task:
291
  1. Receive a high-level user brief describing a social media post idea.
292
  2. Generate a detailed DesignSpec (JSON structured specification) from the brief using 'generate_designSpec_from_brief', including platform, style, content, visuals, colors, typography, composition, lighting, mood, and finishing details.
293
- 3. Using the generated DesignSpec, create a high-quality, brand-aligned social media image using 'generate_post_image' tool.
294
 
295
  Be concise, professional, and strictly follow the structured DesignSpec and design guidelines provided.
296
  """
@@ -383,7 +391,7 @@ def collect_theme_data(url: str) -> dict:
383
  return {"error": str(e)}
384
 
385
 
386
- @function_tool
387
  async def extract_text_tool(url: str) -> str:
388
  """Visits a webpage at the given URL and returns its content as a markdown string.
389
 
@@ -405,7 +413,7 @@ async def extract_text_tool(url: str) -> str:
405
  markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)
406
  print(markdown_content)
407
  return markdown_content
408
-
409
  except RequestException as e:
410
  return f"Error fetching the webpage: {str(e)}"
411
  except Exception as e:
@@ -477,15 +485,15 @@ if __name__ == "__main__":
477
  # )
478
  # print(result)
479
 
480
- result = Runner.run_sync(media_agent,
481
- input="""
482
- Create a media for posting on linkedin plateform, make it modren and professional.
483
 
484
- companydetails:
485
- Design Atom is a subscription-based design service tailored for AI and tech startups, offering comprehensive product design, branding, and web development solutions. With a fixed monthly rate, dedicated designers, and fast 4-hour average turnaround times, they have completed over 200 projects, helped clients raise $45M+, and reached 100M+ users with their designs. Trusted by 45+ global companies, including Y Combinator-backed startups, Design Atom delivers startup-proven results, streamlining UX, boosting retention, and enhancing conversions. Their free design trial eliminates bottlenecks, supporting startups in building investor-ready, user-friendly products.
486
- """ ,
487
- )
488
- print(result)
489
 
490
- # asyncio.run(collect_theme_data("https://www.denovers.com/"))
491
  print('_agents file')
 
21
  from IPython.display import display
22
  from google import genai
23
  import logging
24
+ import asyncio
25
 
26
 
27
+ # anchor_client = Anchorbrowser(
28
+ # api_key=os.getenv("ANCHOR_API_KEY")
29
+ # )
30
 
31
+
32
+
33
+ # logging.basicConfig(level=logging.INFO)
34
 
35
 
36
  aspect_ratios = {
 
44
  )
45
 
46
 
47
+
48
+
49
  #----------------------- content agent ----------------------------------
50
 
51
  def content_prompt(context: RunContextWrapper, agent: Agent):
 
202
  Design Brief:
203
  {design_brief}
204
 
205
+ Design Specification:
206
  {designSpec}
207
 
208
  Design Guidelines:
 
298
  Your task:
299
  1. Receive a high-level user brief describing a social media post idea.
300
  2. Generate a detailed DesignSpec (JSON structured specification) from the brief using 'generate_designSpec_from_brief', including platform, style, content, visuals, colors, typography, composition, lighting, mood, and finishing details.
301
+ 3. Using the generated DesignSpec, create a high-quality, brand-aligned social media image using 'generate_post_image' tool, (Don't change the schema use same as generated)
302
 
303
  Be concise, professional, and strictly follow the structured DesignSpec and design guidelines provided.
304
  """
 
391
  return {"error": str(e)}
392
 
393
 
394
+ # @function_tool
395
  async def extract_text_tool(url: str) -> str:
396
  """Visits a webpage at the given URL and returns its content as a markdown string.
397
 
 
413
  markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)
414
  print(markdown_content)
415
  return markdown_content
416
+
417
  except RequestException as e:
418
  return f"Error fetching the webpage: {str(e)}"
419
  except Exception as e:
 
485
  # )
486
  # print(result)
487
 
488
+ # result = Runner.run_sync(media_agent,
489
+ # input="""
490
+ # Create a media for posting on linkedin plateform, make it modren and professional.
491
 
492
+ # companydetails:
493
+ # Design Atom is a subscription-based design service tailored for AI and tech startups, offering comprehensive product design, branding, and web development solutions. With a fixed monthly rate, dedicated designers, and fast 4-hour average turnaround times, they have completed over 200 projects, helped clients raise $45M+, and reached 100M+ users with their designs. Trusted by 45+ global companies, including Y Combinator-backed startups, Design Atom delivers startup-proven results, streamlining UX, boosting retention, and enhancing conversions. Their free design trial eliminates bottlenecks, supporting startups in building investor-ready, user-friendly products.
494
+ # """ ,
495
+ # )
496
+ # print(result)
497
 
498
+ # asyncio.run(extract_text_tool("https://www.denovers.com/"))
499
  print('_agents file')
src/main.py CHANGED
@@ -69,7 +69,7 @@ Steps for Generating Content:
69
 
70
  Steps for Generating Media:
71
  1. Extract key text and theme colors from the website.
72
- 2. Provide the extracted website content, the user's brief, and the design brief to the Media Tool.
73
 
74
  Final Step:
75
  - Combine all outputs into a coherent, platform-ready social media post.
@@ -88,9 +88,7 @@ async def main():
88
 
89
  session = SQLiteSession("conversation_123")
90
 
91
- agent_context = AgentContext(
92
- user_input="Write a LinkedIn post about the importance of AI in modern business strategies."
93
- )
94
 
95
 
96
 
@@ -101,9 +99,7 @@ async def main():
101
  tools=[
102
  content_agent.as_tool(
103
  tool_name="content_agent",
104
- tool_description="""
105
- Generates engaging social media post content based on user input.
106
- """
107
  ),
108
  WebInspectorAgent.as_tool(
109
  tool_name="WebInspectorAgent",
@@ -111,8 +107,7 @@ Generates engaging social media post content based on user input.
111
  ),
112
  media_agent.as_tool(
113
  tool_name="media_agent",
114
- tool_description="""
115
- Generates high-quality, brand-aligned social media images based on the user's brief,
116
  design specifications, and extracted website content (text, colors, and theme).
117
  Follows design guidelines for style, composition, typography, colors, dark/light theme and platform-specific requirements.
118
  """
@@ -123,7 +118,7 @@ Follows design guidelines for style, composition, typography, colors, dark/light
123
  )
124
 
125
  result = await Runner.run(social_media_post_gen_agent,
126
- input="""Create a LinkedIn post this website https://denovers.com, Post related the services we provide""" ,
127
  session=session,
128
  context=agent_context,
129
  )
 
69
 
70
  Steps for Generating Media:
71
  1. Extract key text and theme colors from the website.
72
+ 2. Provide the generated post content (do not update use same as generated), the theme colors, user's brief, and the design brief to the Media Tool.
73
 
74
  Final Step:
75
  - Combine all outputs into a coherent, platform-ready social media post.
 
88
 
89
  session = SQLiteSession("conversation_123")
90
 
91
+ agent_context = AgentContext( user_input="Write a LinkedIn post about the importance of AI in modern business strategies." )
 
 
92
 
93
 
94
 
 
99
  tools=[
100
  content_agent.as_tool(
101
  tool_name="content_agent",
102
+ tool_description="""Generates engaging social media post content based on user input."""
 
 
103
  ),
104
  WebInspectorAgent.as_tool(
105
  tool_name="WebInspectorAgent",
 
107
  ),
108
  media_agent.as_tool(
109
  tool_name="media_agent",
110
+ tool_description="""Generates high-quality, brand-aligned social media images based on the user's brief,
 
111
  design specifications, and extracted website content (text, colors, and theme).
112
  Follows design guidelines for style, composition, typography, colors, dark/light theme and platform-specific requirements.
113
  """
 
118
  )
119
 
120
  result = await Runner.run(social_media_post_gen_agent,
121
+ input="""Create a LinkedIn post for website https://panaversity.org/, tell what they offer in service, can you give the stunning bento grids in middle with logos""" ,
122
  session=session,
123
  context=agent_context,
124
  )
src/model.py CHANGED
@@ -9,6 +9,7 @@ _: bool = load_dotenv(find_dotenv())
9
  google_api_key = os.getenv("GOOGLE_API_KEY")
10
  # grok_api_key = os.getenv("GROK_API_KEY")
11
  openrouter_api_key = os.getenv("OPENROUTER_API_KEY")
 
12
 
13
  DEEPSEEK_BASE_URL = "https://api.deepseek.com/v1"
14
  GROK_BASE_URL = "https://api.x.ai/v1"
@@ -21,6 +22,8 @@ openrouter_client = AsyncOpenAI(base_url=OPENROUTER_BASE_URL, api_key=openrouter
21
  # deepseek_client = AsyncOpenAI(base_url=DEEPSEEK_BASE_URL, api_key=deepseek_api_key)
22
  # grok_client = AsyncOpenAI(base_url=GROK_BASE_URL, api_key=grok_api_key)
23
  gemini_client = AsyncOpenAI(base_url=GEMINI_BASE_URL, api_key=google_api_key)
 
 
24
 
25
  def get_model(model_name: str):
26
  if "/" in model_name:
@@ -29,6 +32,8 @@ def get_model(model_name: str):
29
  # return OpenAIChatCompletionsModel(model=model_name, openai_client=deepseek_client)
30
  # elif "grok" in model_name:
31
  # return OpenAIChatCompletionsModel(model=model_name, openai_client=grok_client)
 
 
32
  elif "gemini" in model_name:
33
  return OpenAIChatCompletionsModel(model=model_name, openai_client=gemini_client)
34
  else:
 
9
  google_api_key = os.getenv("GOOGLE_API_KEY")
10
  # grok_api_key = os.getenv("GROK_API_KEY")
11
  openrouter_api_key = os.getenv("OPENROUTER_API_KEY")
12
+ openai_api_key = os.getenv("OPENAI_API_KEY")
13
 
14
  DEEPSEEK_BASE_URL = "https://api.deepseek.com/v1"
15
  GROK_BASE_URL = "https://api.x.ai/v1"
 
22
  # deepseek_client = AsyncOpenAI(base_url=DEEPSEEK_BASE_URL, api_key=deepseek_api_key)
23
  # grok_client = AsyncOpenAI(base_url=GROK_BASE_URL, api_key=grok_api_key)
24
  gemini_client = AsyncOpenAI(base_url=GEMINI_BASE_URL, api_key=google_api_key)
25
+ openai_client = AsyncOpenAI(api_key=openai_api_key)
26
+
27
 
28
  def get_model(model_name: str):
29
  if "/" in model_name:
 
32
  # return OpenAIChatCompletionsModel(model=model_name, openai_client=deepseek_client)
33
  # elif "grok" in model_name:
34
  # return OpenAIChatCompletionsModel(model=model_name, openai_client=grok_client)
35
+ elif "gpt" in model_name:
36
+ return OpenAIChatCompletionsModel(model=model_name, openai_client=openai_client)
37
  elif "gemini" in model_name:
38
  return OpenAIChatCompletionsModel(model=model_name, openai_client=gemini_client)
39
  else: