Skip to content

Add Digital Twins Specialist Role#51

Open
GYFX35 wants to merge 1 commit intomainfrom
add-digital-twins-role-14907178079021782652
Open

Add Digital Twins Specialist Role#51
GYFX35 wants to merge 1 commit intomainfrom
add-digital-twins-role-14907178079021782652

Conversation

@GYFX35
Copy link
Copy Markdown
Owner

@GYFX35 GYFX35 commented Feb 12, 2026

This PR adds a new 'Digital Twins Specialist' AI role to the platform.

Key changes:

  • AI Logic: Implemented provide_digital_twins_assistance in google_ai.py using the Gemini 1.5 Flash model.
  • Backend: Created a new POST endpoint /api/v1/digital-twins/assistance in app.py, protected by API key authentication.
  • Frontend: Added a service card and a dedicated interaction section to the main landing page (index.html).
  • Client-side: Updated script.js to manage the UI state and API communication for the new role.
  • Localization: Extracted new strings and provided Spanish translations. Compiled the message catalogs.

Verified the changes visually and functionally using Playwright.


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

Summary by Sourcery

Add a new Digital Twins Specialist AI capability exposed via a secured backend endpoint and integrated into the main landing page UI.

New Features:

  • Introduce a Digital Twins Specialist AI role powered by a dedicated assistance function in the AI service layer.
  • Expose a POST /api/v1/digital-twins/assistance API endpoint secured with API key authentication for digital twin assistance requests.
  • Add a Digital Twins Specialist section to the landing page with input, submission, and response display for interactive assistance.

Enhancements:

  • Extend the frontend script to handle UI state and API communication for the Digital Twins Specialist workflow.
  • Update localization catalogs to include strings for the new Digital Twins Specialist role and UI copy.

- Added `provide_digital_twins_assistance` to `google_ai.py` with specialized prompt.
- Added `/api/v1/digital-twins/assistance` endpoint to `app.py`.
- Updated `index.html` with a new service card and interaction section for Digital Twins.
- Updated `script.js` to handle the new service interactions.
- Updated translation files (POT, PO, MO) for English and Spanish.

Co-authored-by: GYFX35 <134739293+GYFX35@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Feb 12, 2026

Deploying ai-services with  Cloudflare Pages  Cloudflare Pages

Latest commit: 647ec44
Status: ✅  Deploy successful!
Preview URL: https://d5bf82c4.ai-services-36y.pages.dev
Branch Preview URL: https://add-digital-twins-role-14907.ai-services-36y.pages.dev

View logs

@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 12, 2026

Reviewer's Guide

Implements a new Digital Twins Specialist role end-to-end by wiring a Gemini-based backend helper through a secured Flask API endpoint to new UI components on the landing page, with supporting JavaScript and localization updates.

Sequence diagram for Digital Twins Specialist assistance flow

sequenceDiagram
  actor User
  participant Browser
  participant FlaskApp
  participant GoogleAIModule
  participant VertexAIGemini

  User->>Browser: Click digital-twins-assistance-btn
  Browser->>User: Prompt for API key via getApiKey
  User-->>Browser: Enter API key
  Browser->>FlaskApp: POST /api/v1/digital-twins/assistance
  activate FlaskApp
  FlaskApp->>FlaskApp: require_api_key validation
  FlaskApp->>FlaskApp: Parse JSON and validate prompt
  FlaskApp->>GoogleAIModule: provide_digital_twins_assistance(prompt)
  activate GoogleAIModule
  GoogleAIModule->>VertexAIGemini: generate_content(generation_prompt)
  activate VertexAIGemini
  VertexAIGemini-->>GoogleAIModule: Response with text
  deactivate VertexAIGemini
  GoogleAIModule-->>FlaskApp: message
  deactivate GoogleAIModule
  FlaskApp-->>Browser: JSON { status, message }
  deactivate FlaskApp
  Browser->>Browser: Update digital-twins-assistance-response
  Browser-->>User: Display assistant response
Loading

Class-style diagram for Digital Twins Specialist backend components

classDiagram
  class GoogleAIModule {
    +str provide_digital_twins_assistance(prompt)
  }

  class FlaskApp {
    +digital_twins_assistance_endpoint()
  }

  class VertexAIGemini {
    +generate_content(generation_prompt)
  }

  class RequireApiKeyDecorator {
    +wrap(view_function)
  }

  FlaskApp ..> RequireApiKeyDecorator : uses
  FlaskApp ..> GoogleAIModule : calls
  GoogleAIModule ..> VertexAIGemini : uses model

  note for GoogleAIModule "Encapsulates Gemini 1.5 Flash prompt construction and response handling for digital twins assistance"
Loading

File-Level Changes

Change Details Files
Add backend AI helper for Digital Twins using Gemini 1.5 Flash and expose it via a secured Flask endpoint.
  • Implemented provide_digital_twins_assistance to construct a role-specific prompt and call the Vertex AI GenerativeModel, returning cleaned text or an error message.
  • Added a new Flask route /api/v1/digital-twins/assistance that validates the JSON payload, enforces API-key auth, invokes the digital twins helper, and wraps the result in a standard JSON response.
google_ai.py
app.py
Extend the frontend UI to surface the Digital Twins Specialist as a new service and provide an interaction area for user prompts and responses.
  • Added a new service card listing the Digital Twins Specialist capability alongside existing roles.
  • Introduced a dedicated Digital Twins Specialist section with textarea input, submit button, and preformatted response container, all wired to localization keys.
frontend/templates/index.html
Wire client-side behavior for the Digital Twins Specialist UI, including API key prompting and POSTing user prompts to the new backend endpoint.
  • Registered a click handler on the Digital Twins assistance button that collects user input, prompts for an API key, and sends a JSON POST to the new endpoint with appropriate headers.
  • Implemented error handling that surfaces API validation errors or network failures in the response container, and renders successful responses from the backend message field.
frontend/static/js/script.js
Update localization resources to cover new Digital Twins Specialist copy in multiple languages.
  • Extracted new translatable strings for the Digital Twins Specialist UI text and validation error message.
  • Updated English and Spanish message catalogs and recompiled them to keep translations in sync with the new feature.
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 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 647ec44 Feb 12 2026, 08:34 AM

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:

  • In the digital twins fetch handler, you assume all non-OK responses are JSON with an error field; consider guarding with a content-type check or falling back to response.text() to avoid additional errors when the backend returns non-JSON bodies.
  • Before sending the prompt in script.js, consider trimming and validating the textarea value client-side (e.g., empty or whitespace-only checks) to avoid unnecessary 400s from the /digital-twins/assistance endpoint and to give faster feedback to users.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the digital twins fetch handler, you assume all non-OK responses are JSON with an `error` field; consider guarding with a content-type check or falling back to `response.text()` to avoid additional errors when the backend returns non-JSON bodies.
- Before sending the prompt in `script.js`, consider trimming and validating the textarea value client-side (e.g., empty or whitespace-only checks) to avoid unnecessary 400s from the `/digital-twins/assistance` endpoint and to give faster feedback to users.

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.

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