PyGai Connector UI Interaction Guide
This guide demonstrates how to configure and manage data through the PyGai connector's web administration interface, without requiring any programming. These configurations will synergize with Gai application's scheduled tasks (Cron Jobs) to achieve automated data ingestion and processing workflows.
Workflow: PyGai --1--> Gai --2--> PyGai --3--> Page
| stage | description |
|---|---|
| PyGai -> Gai | Prompt Output |
| Gai -> PyGai | Content Return |
| PyGai -> Page | Data Post-processing |
T1-Content Generation Strategies
The PyGai connector supports the following two primary content generation strategies to accommodate diverse business requirements:
-
Batch Content Generation
- Characteristics: Focuses on producing a large volume of content for single or similar prompts under a unified theme, emphasizing efficiency and quantity.
- Scenario Examples:
- Standardized text generation: e.g., large-scale student essay evaluations, bulk product review generation.
- Repetitive content population: e.g., generating descriptions for individual product variants, or mass-producing supportive comments for specific viewpoints.
-
Diverse Content Expansion
- Characteristics: Focuses on multi-dimensional content creation for various prompts under a unified theme, emphasizing content breadth, diversity of perspectives, or thematic segmentation.
- Scenario Examples:
- Multi-perspective marketing campaigns: generating social media posts for the same product from different user personas, feature advantages, and other angles.
- Opinion shaping and bias correction: designing comments or replies from diverse perspectives for specific issues to guide public opinion or rectify misunderstandings.
- Series content creation: generating a series of articles based on different sub-propositions under a unified theme (e.g., a "Plum, Orchid, Chrysanthemum, Bamboo" series).
T3-Core Concepts and Terminology
The core concepts and terminology within the PyGai connector are outlined below, each corresponding to a specific management module in the UI interaction:
Core Entities and UI Path Overview
| alias | page |
|---|---|
| Topic | /admin/topic/ |
| Prompt | /admin/prompt/ |
| Content | /admin/contenet/ |
| Directory | /admin/directory/ |
UI Operation Shorthand
These shorthand examples simplify UI operation descriptions within the documentation; users should perform actual operations via the web administration interface.
- Configure Prompt:
new, /admin/prompt/; genTxt:yes, quota: 10, text: hello. - Create Topic:
new, /admin/topic/; name: ai demo. - Create System Instruction:
new, /admin/instruct/; name: Role Play - High School Teacher..., instruction: You are a Chinese language teacher...
UI Operation Screenshot Examples

T4-Website Assistant Practical Guide
This section guides users through setting up and managing an AI-driven static website using the PyGai UI in conjunction with MkDocs.
Prerequisites
- PyGai Administration Panel: Access
http://127.0.0.1:5050/login/to log in; default account and password can be found inconfig\setting.iniunder[USER]. - MkDocs Installation: Please ensure MkDocs is installed in your environment.
shell pip install mkdocs-publisher pip install mkdocs mkdir -p ~/Documents/sites mkdocs new ~/Documents/sites/MyWebSite
Basic Configuration
- Create Publishing Directory (Directory): Configure the directory for static website files within the PyGai UI.
new, /admin/directory/; name: MyWebSite, Directory: ~/Documents/sites/MyWebSite/docs/ - Create Content Topic (Topic): Define content categories for organizing related AI generation tasks.
new, /admin/topic/; name: Wordsmith
T4.1- Example Task 1: Batch Writing Test
Writing test, 30 students, all writing a propositional essay on "Tomorrow, and Tomorrow, and Tomorrow..."
-
Strategy Outline
- Scenario: Batch content generation, unified theme, identical prompt, quantity-focused.
- Topic: Propositional Essay Test (Wordsmith)
- Prompt Content: People say, "Tomorrow, and Tomorrow, and Tomorrow...", as a middle school student, how would you approach this? Write an essay based on this topic, choosing your own perspective, devising your own title, with no genre restrictions, and no less than 500 words.
- Generation Quantity: 30 essays
-
Operational Procedure
-
Configure Prompt
new, /admin/prompt/; quota: 30, genTxt:yes, enabled:yes, intervalName:hourly, topic: Wordsmith, directory: MyWebSite,
text: People say, "Tomorrow, and Tomorrow, and Tomorrow...", as a middle school student, how would you approach this? Write an essay based on this topic, choosing your own perspective, devising your own title, with no genre restrictions, and no less than 500 words.
-
Gai Cron Job Integration
-
Define Global Variables
scope: global name: _G_APISRV value: http://127.0.0.1:5050 name: _G_APIJWT value: eyJhbGciOiJIUzUxMiIsIn... -
Configure HTTP Request for Prompt Retrieval
name: _HTTP_MyWebSite_GetPrompt method: get url: {{_G_APISRV}}/aiprompt/output/ header: Authorization: Bearer {{_G_APIJWT}} param: dirId=1&dirName=MyWebSite -
Configure HTTP Request for Content Submission
name: _HTTP_MyWebSite_PostContent method: post url: {{_G_APISRV}}/aicontent/input/ header: Authorization: Bearer {{_G_APIJWT}} -
Create Scheduled Job (Cron Job)
name: _CRON_MyWebSite_HourlyWordsmith time: 0 * * * * input: http; _HTTP_MyWebSite_GetPrompt output: http; _HTTP_MyWebSite_PostContent empty input Silenced: Yes
-
-
T4.2- Example Task 2: Diverse Writing Test
Writing test, 4 students, with 4 types of plants: "Plum, Orchid, Chrysanthemum, Bamboo". Please choose one plant each for an essay.
-
Strategy Outline
- Scenario: Diverse content expansion, unified theme, distinct prompts, focusing on prompt diversity.
- Topic: Propositional Essay Test (DailyWordsmith)
- Prompt Content: Design an essay topic for each of the four plants – Plum, Orchid, Chrysanthemum, Bamboo – and generate one essay for each.
-
Operational Procedure
-
Configure Prompt (Plum)
new, /admin/prompt/; quota: 1, genTxt:yes, enabled:yes, intervalName:hourly, topic: DailyWordsmith, directory: MyWebSite,
text: The Plum Blossom's Fragrance: My Journey Through Academic Challenges. Write a narrative or argumentative essay (minimum 500 words) using the plum blossom's spirit as a central theme. Describe the hardships and rewards of your learning experience, or explore the essence of academic perseverance.
-
Configure Prompt (Orchid)
new, /admin/prompt/; quota: 1, genTxt:yes, enabled:yes, intervalName:hourly, topic: DailyWordsmith, directory: MyWebSite,
text: Early Summer Orchids. Write a narrative or descriptive essay (minimum 500 words) portraying the blooming of orchids in early summer. Focus on a detailed description of their form, color, unique delicate fragrance, and the emotions they evoke.
-
Configure Prompt (Chrysanthemum)
new, /admin/prompt/; quota: 1, genTxt:yes, enabled:yes, intervalName:hourly, topic: DailyWordsmith, directory: MyWebSite,
text: Chrysanthemums: Autumn's Harbingers. Write a narrative essay (minimum 500 words) about an experience observing chrysanthemums, conveying the joy and tranquility they inspire.
-
Configure Prompt (Bamboo)
new, /admin/prompt/; quota: 1, genTxt:yes, enabled:yes, intervalName:hourly, topic: DailyWordsmith, directory: MyWebSite,
text: The Upright Bamboo, My Ambition. Write an argumentative essay or prose (minimum 500 words) exploring the bamboo's spirit of upward growth and resilience in adversity, connecting it to your personal ideals and pursuits. Include reflections on concepts like setting goals and striving.
-
Gai Cron Job Integration
-
Define Global Variables
text scope: global name: _G_APISRV value: http://127.0.0.1:5050 name: _G_APIJWT value: eyJhbGciOiJIUzUxMiIsIn...` -
Configure HTTP Request for Prompt Retrieval
text name: _HTTP_MyWebSite_GetPrompt method: get url: {{_G_APISRV}}/aiprompt/output/ header: Authorization: Bearer {{_G_APIJWT}} param: dirId=1&dirName=MyWebSite -
Configure HTTP Request for Content Submission
text name: _HTTP_MyWebSite_PostContent method: post url: {{_G_APISRV}}/aicontent/input/ header: Authorization: Bearer {{_G_APIJWT}} -
Create Scheduled Job (Cron Job)
text name: _CRON_MyWebSite_DailyWordsmith time: 0 0 * * * input: http; _HTTP_MyWebSite_GetPrompt output: http; _HTTP_MyWebSite_PostContent empty input Silenced: Yes
-
-