-
Notifications
You must be signed in to change notification settings - Fork 2k
Add profile generation use case #508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
"user": ModelFactory.create( | ||
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, | ||
model_type="gpt-4.1", | ||
api_key=os.getenv("OPENAI_API_KEY"), | ||
model_config_dict={"temperature": 0.4}, | ||
), | ||
"assistant": ModelFactory.create( | ||
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, | ||
model_type="gpt-4.1", | ||
api_key=os.getenv("OPENAI_API_KEY"), | ||
model_config_dict={"temperature": 0.4}, | ||
), | ||
"content_researcher": ModelFactory.create( | ||
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, | ||
model_type="gpt-4.1", | ||
api_key=os.getenv("OPENAI_API_KEY"), | ||
model_config_dict={"temperature": 0.2}, | ||
), | ||
"planning": ModelFactory.create( | ||
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, | ||
model_type="gpt-4.1", | ||
api_key=os.getenv("OPENAI_API_KEY"), | ||
model_config_dict={"temperature": 0.3}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use openai model platform instead?
html_prompt = """ | ||
Generate a professional and natural-looking personal profile HTML page based | ||
on the provided information, following these detailed requirements: | ||
|
||
Use standard HTML5 structure. | ||
|
||
Layout should be clearly organized using <h1> for the main title, <h2> for | ||
section headings, and <p> for paragraph text. | ||
|
||
Use proper <a href> hyperlinks for any external links (e.g., LinkedIn, | ||
ResearchGate, Google Scholar). | ||
|
||
Write in a natural, flowing narrative style suitable for introducing the | ||
person to a broad audience (no bullet points). | ||
|
||
Strictly follow the given content structure: | ||
|
||
Personal Information (Name, Positions, Contact( include social media), | ||
Research Keywords) | ||
|
||
Summary (Short description of expertise and overall role) | ||
|
||
Biography (Detailed career history (can be found in Linkedin) and research | ||
focus) | ||
|
||
Research Interests (Areas of active research) | ||
|
||
Awards and Distinctions (Honors and recognitions) | ||
|
||
Education (Academic degrees in order) | ||
|
||
Engage / Related Links (Professional profiles and external resources) | ||
|
||
The final HTML should look clean, modern, and ready to be used as a complete | ||
professional personal page. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use response_format
in ChatAgent
to generate a pydantic object with required fields and use exact the same html template as https://cemse.kaust.edu.sa/profiles/ahmed-eltawil to render the information? Please do not use prompt to generate html.
html_user_prompt = f""" | ||
Using the following JSON, build a complete HTML5 profile page. | ||
|
||
• Sections: Personal Information, Biography, Research Interests, Awards | ||
and Distinctions, Education. | ||
Generate a professional and natural-looking personal profile HTML page | ||
based | ||
on the provided information, following these detailed requirements: | ||
Using standard HTML5 + simple inline CSS, beautiful but not complicated. | ||
Layout should be clearly organized using <h1> for the main title, <h2> for | ||
section headings, and <p> for paragraph text. | ||
Use proper <a href> hyperlinks for any external links (e.g., LinkedIn, | ||
ResearchGate, Google Scholar). | ||
Write in a natural, flowing narrative style suitable for introducing the | ||
person to a broad audience. | ||
|
||
Please write ALL the input content to the webpage. | ||
JSON: | ||
{profile.model_dump_json(indent=2)} | ||
""" | ||
|
||
html_response = html_agent.step(html_user_prompt) | ||
html_code = html_response.msgs[0].content | ||
html_code_block = re.search(r"```html(.*?)```", html_code, re.DOTALL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not use agent for generating HTML? Just use a pre-defined template for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the updated generated example?
agent = ChatAgent( | ||
system_message="""Reformat awards as HTML list items using the | ||
structure, Like: | ||
<li class="field__item"><strong>The | ||
NSF CAREER grant in low-power computing and | ||
communication systems</strong>, 2024</li>.""") | ||
for award in awards: | ||
response = agent.step(f"Reformat this: {award}") | ||
formatted_awards.append(response.msgs[0].content.strip()) | ||
return "\n".join(formatted_awards) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not do it in multiple steps. Use response format to format the awards in one shot. Otherwise, it is too exspensive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format problem can be solve by adding examples in the Field
description
.
items = [] | ||
for degree in degrees: | ||
response = agent.step(f"Reformat this: {degree}") | ||
items.append(response.msgs[0].content.strip()) | ||
return "\n".join(items) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not do it in multiple steps. Use response format to format the awards in one shot. Otherwise, it is too exspensive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format problem can be solve by adding examples in the Field
description
.
class AwardsAndDistinctions(BaseModel): | ||
honors: list[str] = Field( | ||
description="List of awards, honors, and professional distinctions " | ||
"received") | ||
|
||
|
||
class Education(BaseModel): | ||
degrees: list[str] = Field( | ||
description="Academic degrees in reverse chronological order, " | ||
"including institution and year") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format problem can be solve by adding examples in the Field
description
.
def format_links(links: list[str], html_template: str) -> str: | ||
agent = ChatAgent( | ||
system_message="Reformat link into this html structure: %s ." % | ||
html_template) | ||
items = [] | ||
for link in links: | ||
response = agent.step(f"Reformat this: {link}") | ||
items.append(response.msgs[0].content.strip()) | ||
return "\n".join(items) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not do it in multiple steps. Use response format to format the awards in one shot. Otherwise, it is too exspensive
9700b6e
to
df1ee1c
Compare
Search a person's social media, Google Scholar, and other information to automatically build a profile webpage.