Skip to content

Add NLP Specialist role#67

Open
GYFX35 wants to merge 1 commit intomainfrom
add-nlp-specialist-role-10186011041746294436
Open

Add NLP Specialist role#67
GYFX35 wants to merge 1 commit intomainfrom
add-nlp-specialist-role-10186011041746294436

Conversation

@GYFX35
Copy link
Copy Markdown
Owner

@GYFX35 GYFX35 commented Feb 25, 2026

This change adds a new 'Natural Language Processing (NLP) Specialist' role to the application. The new role is integrated into the backend (Vertex AI prompt and Flask endpoint) and the frontend (UI section, navigation, and JS handling). I also ensured that translations are updated and existing translations are preserved.


PR created automatically by Jules for task 10186011041746294436 started by @GYFX35

Summary by Sourcery

Add a new NLP Specialist capability across the backend API and frontend UI to provide NLP-focused assistance to users.

New Features:

  • Expose an authenticated NLP assistance API endpoint that delegates to a Vertex AI-powered NLP specialist model.
  • Add an NLP Specialist section to the main UI, including navigation, input, and display of NLP assistance responses.
  • Implement client-side handling for submitting NLP requests and rendering responses from the new NLP assistance endpoint.

Documentation:

  • Update localized UI strings to cover the new NLP Specialist section and prompts in supported languages.

- Added `provide_nlp_assistance` function in `google_ai.py` with a detailed NLP persona.
- Added `/api/v1/nlp/assistance` API endpoint in `app.py`.
- Added NLP Specialist section and navigation link in `frontend/templates/index.html`.
- Implemented frontend logic for the NLP role in `frontend/static/js/script.js`.
- Updated Spanish translations for the new role.

Co-authored-by: GYFX35 <134739293+GYFX35@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 25, 2026

Reviewer's Guide

Adds a new NLP Specialist role end-to-end: frontend UI section and navigation, client-side JS handler, backend Flask API endpoint, Vertex AI integration, and translation strings for i18n.

Sequence diagram for the new NLP Specialist assistance flow

sequenceDiagram
    actor User
    participant Browser
    participant FlaskApp
    participant GoogleAIModule
    participant VertexAI

    User->>Browser: Click nlp_btn
    Browser->>Browser: Read nlp_input
    Browser->>User: Prompt for API key
    User-->>Browser: Enter API key
    Browser->>FlaskApp: POST /api/v1/nlp/assistance
    activate FlaskApp
    FlaskApp->>FlaskApp: require_api_key validation
    FlaskApp->>FlaskApp: Parse JSON, get prompt
    FlaskApp->>GoogleAIModule: provide_nlp_assistance(prompt)
    activate GoogleAIModule
    GoogleAIModule->>VertexAI: generate_content(generation_prompt)
    activate VertexAI
    VertexAI-->>GoogleAIModule: NLP response text
    deactivate VertexAI
    GoogleAIModule-->>FlaskApp: message
    deactivate GoogleAIModule
    FlaskApp-->>Browser: 200 JSON {status, message}
    deactivate FlaskApp
    Browser->>Browser: Parse JSON
    Browser-->>User: Render message in nlp_response

    alt Missing prompt
        FlaskApp-->>Browser: 400 JSON {error Prompt_is_required}
        Browser-->>User: Show error in nlp_response
    end

    alt Non_ok_response
        FlaskApp-->>Browser: Error JSON {error}
        Browser->>Browser: Throw Error
        Browser-->>User: Show Error in nlp_response
    end
Loading

Class diagram for NLP Specialist backend components

classDiagram
    class FlaskApp {
        +nlp_assistance_endpoint()
    }

    class GoogleAIModule {
        +provide_nlp_assistance(prompt)
    }

    class VertexAIModel {
        +generate_content(prompt)
    }

    FlaskApp --> GoogleAIModule : uses
    GoogleAIModule --> VertexAIModel : calls
Loading

File-Level Changes

Change Details Files
Add NLP Specialist assistance flow in frontend JavaScript
  • Registers click handler for NLP Specialist button that collects user input and API key
  • Sends POST request with prompt to new /api/v1/nlp/assistance endpoint including X-API-Key header
  • Displays successful NLP response message or error message in dedicated response container
frontend/static/js/script.js
Introduce NLP assistance service using Vertex AI in backend
  • Implements provide_nlp_assistance helper that builds an NLP-specialist system prompt and calls Gemini 1.5 Flash
  • Handles errors by logging and returning a user-visible error string
google_ai.py
Expose NLP Specialist functionality via Flask API and integrate into UI
  • Adds /api/v1/nlp/assistance POST endpoint protected by require_api_key that validates input and delegates to provide_nlp_assistance
  • Extends main page navigation with an NLP section link
  • Adds NLP Specialist service section with textarea input, submit button, and response display, all wired to existing i18n mechanisms
app.py
frontend/templates/index.html
Update i18n catalogs for new NLP Specialist strings
  • Regenerates base messages catalog with new NLP-related message IDs
  • Adds English translations for the new strings while preserving existing entries
  • Adds Spanish translations for the new strings while preserving existing entries
messages.pot
translations/en/LC_MESSAGES/messages.po
translations/es/LC_MESSAGES/messages.po

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying ai-services with  Cloudflare Pages  Cloudflare Pages

Latest commit: 99a57c4
Status: ✅  Deploy successful!
Preview URL: https://f461cdc7.ai-services-36y.pages.dev
Branch Preview URL: https://add-nlp-specialist-role-1018.ai-services-36y.pages.dev

View logs

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The new NLP JS flow introduces hard-coded user-facing strings (e.g., the API key prompt and 'API key is required.') that bypass the existing i18n system; consider moving these into translatable resources to keep localization consistent with the rest of the app.
  • In the NLP assistance endpoint, you return a localized error message when the prompt is missing but the frontend assumes a JSON body with an 'error' field for non-OK responses; it may be safer to standardize the error response shape (status/error/message) across endpoints to simplify client handling.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new NLP JS flow introduces hard-coded user-facing strings (e.g., the API key prompt and 'API key is required.') that bypass the existing i18n system; consider moving these into translatable resources to keep localization consistent with the rest of the app.
- In the NLP assistance endpoint, you return a localized error message when the prompt is missing but the frontend assumes a JSON body with an 'error' field for non-OK responses; it may be safer to standardize the error response shape (status/error/message) across endpoints to simplify client handling.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
aiservices 99a57c4 Feb 25 2026, 07:35 AM

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.

1 participant