Skip to content

Conversation

@NayanUnni95
Copy link
Contributor

@NayanUnni95 NayanUnni95 commented Nov 27, 2025

Summary

This PR replaces two separate LLM prompts with one unified prompt that generates both the about section and SEO data in a single JSON response. This cuts token usage, removes duplication, and simplifies the workflow.
Closes #114

Description

The previous setup made two LLM calls using the same input data. This update combines them into one structured prompt that returns the summary and SEO fields together. The new prompt is cleaner, consistent, and handles missing fields safely.

Motivation and Context

The old approach wasted tokens and added unnecessary complexity. Unifying the prompts reduces cost, speeds up execution, and keeps the codebase easier to maintain.

How has this been tested?

  • Tested with multiple usernames
  • JSON structure validated across edge cases
  • Confirmed summary + SEO generation works as expected
  • Ensured no downstream breakages after switching to single-call mode

Screenshots:

Screenshot from 2025-11-27 11-22-19 Screenshot from 2025-11-27 11-24-19 Screenshot from 2025-11-27 11-25-10

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@vercel
Copy link

vercel bot commented Nov 27, 2025

@NayanUnni95 is attempting to deploy a commit to the lamsta Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link

Summary of Changes

Hello @NayanUnni95, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the AI-driven content generation for user profiles. It consolidates the separate calls for generating profile summaries and SEO content into a single, more efficient process. The AI generator now produces a unified JSON object containing both types of information, simplifying the integration and ensuring consistency across generated content.

Highlights

  • Consolidated AI Content Generation: The process for generating both user profile summaries and SEO content has been streamlined into a single AI call, improving efficiency and consistency.
  • Refactored AIDescriptionGenerator: The generate_seo_contents method was removed, and the generate_profile_summary method now returns a unified JSON object containing both the 'about' summary and 'seo' details.
  • Enhanced AI Prompting: The AI prompt for profile summary generation was updated to explicitly define the required JSON output structure and content rules, ensuring a predictable and comprehensive response.
  • API Integration Update: The api/main.py file was modified to utilize the new single generate_profile_summary call and correctly extract both 'about' and 'seo' data from its combined JSON response.
  • Data Extraction Adjustment: The utils/user.py file was updated to correctly access the 'about' field from the new JSON structure returned by the AI generator for the user's profile summary.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the AI content generation by merging the profile summary and SEO content generation into a single method, which is a good simplification. However, I've identified a few critical issues with the implementation. The parsing of the JSON response from the AI is not handled safely, which could lead to application crashes. Additionally, error handling for the new data structure in utils/user.py is incomplete, which could cause TypeError exceptions. I've also noted a minor issue with an outdated docstring. My review includes specific suggestions to address these points.

raise Exception("No response from AI model")

return response.choices[0].message.content
return json.loads(response.choices[0].message.content)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The call to json.loads() is not wrapped in a try...except block. If the AI model returns a response that is not valid JSON, this will raise a json.JSONDecodeError and crash the application. It's crucial to handle this potential error gracefully, similar to how it was handled in the removed generate_seo_contents method.

        try:
            return json.loads(response.choices[0].message.content)
        except json.JSONDecodeError as e:
            raise Exception(f"AI response was not valid JSON. Content: {response.choices[0].message.content}") from e


# Add summaries to profile data
profile_data['profile_summary'] = profile_summary
profile_data['profile_summary'] = profile_summary['about']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

profile_summary can be None if an exception occurs in ai_generator.generate_profile_summary. Accessing profile_summary['about'] will then raise a TypeError. You should add a check to handle the case where profile_summary is None.

Additionally, the SEO data returned from generate_profile_summary is being discarded. My suggestion includes storing this data in profile_data as well.

Suggested change
profile_data['profile_summary'] = profile_summary['about']
if profile_summary:
profile_data['profile_summary'] = profile_summary.get('about')
profile_data['seo'] = profile_summary.get('seo')
else:
profile_data['profile_summary'] = None
profile_data['seo'] = None

profile_data (dict): GitHub user profile data
Returns:
str: AI-generated profile summary

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The docstring's Returns section is outdated. The function now returns a dictionary containing the profile summary and SEO content, not a string. Please update the docstring to accurately reflect the new return type.

Suggested change
str: AI-generated profile summary
dict: AI-generated profile summary and SEO data

@NayanUnni95 NayanUnni95 changed the title refactor(ai_generator): streamline profile summary generation and remove SEO content method Unify Dual LLM Calls into One Structured Prompt Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor profile & SEO creation to a single LLM pipeline

1 participant