# es-text-generation

Part of **ES**

# Elasticsearch AI and RAG Console Guide

## Operations Overview

| Operation | Console Entry Path | Prerequisites | Description |
|----------|-------------------|--------------|-------------|
| Activate AI Search Service | Console > AI Search Open Platform > Service Plaza | Valid Alibaba Cloud account with appropriate permissions | Enable the AI Search Open Platform and create isolated workspaces for RAG development |
| Create Knowledge Base | Console > OpenSearch-LLM-based Agentic Search > Knowledge Base > Create Knowledge Base | Region set to China (Shanghai); Elasticsearch/OpenSearch instance with public access; IP 47.100.254.67 in allowlist | Connect external data sources to build a retrievable knowledge repository |
| Split Document into Chunks | Console > AI Search Open Platform > Document Splitting Service | Activated AI Search Open Platform; API key for authentication | Configure document preprocessing for RAG via the document splitting service |
| Build Knowledge Base Q&A System | Console > AI Search Open Platform > RAG > Scenario Center > Create RAG Pipeline | AI Search activated; ES 8.9+ cluster; IP whitelisted; Python 3.7+ with required packages | Assemble modular algorithm services into an end-to-end RAG pipeline |
| Generate Text | Console > AI Search Open Platform > API Keys Management | Activated AI Search Open Platform; API key for authentication | Obtain API credentials needed to call text generation models like ops-qwen-turbo |
| Create Evaluation Task | Console > AI Search Open Platform > Effect Evaluation > Create Evaluation Task | AI Search Open Platform service activated | Upload datasets to evaluate RAG performance using metrics like Faithfulness and Context Recall |
| Create Enterprise Chatbot in Group Chat | Console > OpenSearch > LLM-Based Conversational Search > Create Chatbot | Data imported into OpenSearch LLM-Based Conversational Search Edition; DingTalk/Lark admin access | Deploy no-code conversational bots into enterprise group chats |

## Operation Steps

### Activate AI Search Service

**Navigation**: Console > AI Search Open Platform > Service Plaza

**Prerequisites**:
- Valid Alibaba Cloud account with appropriate permissions

1. Log in to the AI Search Open Platform console  
   - Element: **AI Search Open Platform** (link) — top navigation bar  
   - Notes: Ensure you are in the correct region (China (Shanghai) recommended)

2. Click the activation button in the Activation Reminder banner  
   - Element: **Activate** (button) — top of Service Plaza page  

3. Read the Search Development Service Platform Agreement  
   - Element: **Search Development Service Platform Agreement** (link) — in the agreement signing dialog box  

4. Confirm the agreement by clicking the Activate button  
   - Element: **Activate** (button) — agreement signing dialog box  

5. Navigate to workspace management  
   - Element: **Manage Workspaces** (button) — upper-right corner of Service Plaza page  

6. Create a new workspace  
   - Element: **Create Workspace** (button) — workspace management panel  
   - Notes: The system automatically creates a "Default" workspace on first activation

7. Confirm workspace creation  
   - Element: **Confirm** (button) — create workspace dialog  
   - Notes: After creation, assign RAM user permissions for enhanced security

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Workspace Name | text_input | Yes | — | The name of the new workspace to be created. Must be unique within the account. |

### Create Knowledge Base

**Navigation**: Console > OpenSearch-LLM-based Agentic Search > Knowledge Base > Create Knowledge Base

**Prerequisites**:
- Region set to China (Shanghai)
- Target workspace selected
- Elasticsearch or OpenSearch instance with public access enabled
- IP address 47.100.254.67 added to the public allowlist of the source instance

1. Log on to the OpenSearch-LLM-based Agentic Search console  
   - Element: **OpenSearch-LLM-based Agentic Search console** (link) — top navigation bar  

2. Select the China (Shanghai) region  
   - Element: **China (Shanghai)** (dropdown) — top-right corner  

3. Select the target workspace  
   - Element: **workspace** (dropdown) — left-side navigation pane  

4. Open the Knowledge Base section  
   - Element: **Knowledge Base** (menu) — left-side navigation panel  

5. Start knowledge base creation  
   - Element: **Create Knowledge Base** (button) — main content area  

6. Enter a unique name  
   - Element: **Name** (text_input) — form fields  
   - Notes: Must be unique within the workspace

7. Choose the source type  
   - Element: **Source Type** (dropdown) — form fields  
   - Options: Alibaba Cloud Elasticsearch, OpenSearch Vector Search Edition, OpenSearch Conversational Search Edition

8. Enter the domain address  
   - Element: **Domain** (text_input) — form fields  
   - Notes: For Elasticsearch: use public address from console (e.g., http://es-xx-xxxxxxxxxxxxxxxxx.public.elasticsearch.aliyuncs.com:9200)

9. Provide authentication credentials  
   - Element: **Authentication Credentials** (text_input) — form fields  
   - Notes: Format: username:password; for Elasticsearch, username is always 'elastic'

10. Specify the index name  
    - Element: **Index Name** (text_input) — form fields  

11. Select query type  
    - Element: **Query Type** (radio) — form fields  
    - Options: Hybrid Search, Text Search  
    - Notes: Hybrid Search combines text and vector search; Text Search supports query_string, search_template, or DSL

12. Choose dense vectorization model  
    - Element: **Dense Vectorization Model** (dropdown) — form fields  
    - Notes: Refer to Model overview documentation for available models

13. Set model service endpoint  
    - Element: **Model Service Endpoint** (text_input) — form fields  
    - Notes: Use the endpoint in the current workspace

14. Enter API key  
    - Element: **API Key** (text_input) — form fields  
    - Notes: Used to authenticate when calling the model

15. Validate configuration  
    - Element: **Validate Configuration** (button) — right panel  
    - Notes: If successful, the system confirms the knowledge base data can be read

16. Save the configuration  
    - Element: **Confirm** (button) — right panel  

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Name | text | Yes | — | Unique name for the knowledge base within the workspace |
| Source Type | dropdown | Yes | Alibaba Cloud Elasticsearch, OpenSearch Vector Search Edition, OpenSearch Conversational Search Edition | The source system from which data will be ingested |
| Domain | text | Yes | — | Public address of the source instance (e.g., http://es-xx-xxxxxxxxxxxxxxxxx.public.elasticsearch.aliyuncs.com:9200) |
| Authentication Credentials | text | Yes | — | Username and password in format username:password |
| Index Name | text | Yes | — | Name of the index in the source system |
| Query Type | radio | Yes | Hybrid Search, Text Search | Method used to retrieve data from the knowledge base |
| Dense Vectorization Model | dropdown | Yes | — | Model used to generate dense vectors for semantic search |
| Sparse Vectorization Model | dropdown | Yes | — | Model used to generate sparse vectors for keyword-based search |
| Model Service Endpoint | text | Yes | — | Endpoint of the model service in the current workspace |
| API Key | text | Yes | — | API key used to authenticate calls to the model service |

### Split Document into Chunks

**Navigation**: Console > AI Search Open Platform > Document Splitting Service

**Prerequisites**:
- Activated AI Search Open Platform
- Completed authentication using an API key

1. Navigate to the AI Search Open Platform console  
   - Element: **AI Search Open Platform** (link) — main navigation panel  

2. Go to the Document Splitting Service page  
   - Element: **Document Splitting Service** (link) — left navigation panel  

### Build Knowledge Base Q&A System

**Navigation**: Console > AI Search Open Platform > RAG > Scenario Center > Create RAG Pipeline

**Prerequisites**:
- AI Search Open Platform is activated
- Service endpoint and authentication credentials are obtained
- Alibaba Cloud Elasticsearch cluster running ES 8.9 or later is created
- IP address of the device is added to the cluster's IP address whitelist

1. Log on to the AI Search Open Platform console  
   - Element: **AI Search Open Platform console** (link) — top navigation bar  

2. Select the China (Shanghai) region and switch to the RAG workspace  
   - Element: **RAG** (menu) — left-side navigation pane  

3. Enter the RAG scenario center  
   - Element: **RAG scenario center card** (panel) — main content area  

4. Select required algorithm services  
   - Element: **drop-down lists** (dropdown) — service selection section  
   - Notes: The service ID (e.g., ops-document-analyze-001) is automatically updated in the generated code

5. Proceed to code generation  
   - Element: **Next** (button) — bottom of the page  

6. Copy or download the implementation code  
   - Element: **Copy** (button) — code section  
   - Notes: Switch between offline and online tabs as needed

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| api_key | text | Yes | — | The API key for authentication |
| aisearch_endpoint | text | Yes | — | The API endpoint. Remove the http:// prefix |
| workspace_name | text | Yes | default | The name of your workspace in AI Search Open Platform |
| service_id | text | No | — | The service ID for each algorithm service |
| es_host | text | Yes | — | The endpoint of your Alibaba Cloud Elasticsearch cluster |
| es_auth | text | Yes | — | The username and password for accessing the Elasticsearch cluster (username: elastic) |

### Generate Text

**Navigation**: Console > AI Search Open Platform > API Keys Management

**Prerequisites**:
- Activated AI Search Open Platform
- An API key for authentication

1. Go to the API key management page  
   - Element: **Manage API key** (link) — top navigation panel  
   - Notes: Click to access the API key management page where you can create or manage your API keys.

2. Create or retrieve an API key  
   - Element: **Create API Key** (button) — main content area  
   - Notes: Ensure the API key is saved securely as it will be used for authentication in code.

### Create Evaluation Task

**Navigation**: Console > AI Search Open Platform > Effect Evaluation > Create Evaluation Task

**Prerequisites**:
- AI Search Open Platform service must be activated

1. Log on to the AI Search Open Platform console  
   - Element: **AI Search Open Platform console** (link) — top navigation  

2. Select the China (Shanghai) region  
   - Element: **China (Shanghai)** (dropdown) — top-right corner  
   - Notes: AI Search Open Platform is currently available only in China (Shanghai) and Germany (Frankfurt). Users in other Chinese regions can access via VPC.

3. Select the target workspace  
   - Element: **workspace** (dropdown) — main content area  
   - Notes: The system automatically creates a Default workspace after first activation.

4. Open Effect Evaluation  
   - Element: **Effect Evaluation** (menu) — left-side navigation panel  

5. Start task creation  
   - Element: **Create Evaluation Task** (button) — main content area  
   - Notes: Dataset must follow the provided template. Maximum of 200 valid records. Reference answer is optional but all questions in a dataset must be consistent (all have or none have a reference answer).

6. Confirm task creation  
   - Element: **Confirm** (button) — bottom of form  

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Task Name | text | Yes | — | A unique name for the evaluation task. |
| Evaluation Dataset | file | Yes | — | Upload a dataset file in the exact format of the sample template. Must contain 'question', 'standard_answer' (optional), 'recall_docs', and 'model_answer' fields. |

### Create Enterprise Chatbot in Group Chat

**Navigation**: Console > OpenSearch > LLM-Based Conversational Search > Create Chatbot

**Prerequisites**:
- Data imported into OpenSearch LLM-Based Conversational Search Edition
- Access to DingTalk or Lark workspace with admin privileges
- Enterprise account with sufficient permissions for bot creation

1. Navigate to the OpenSearch console and select the LLM-Based Conversational Search service  
   - Element: **OpenSearch** (menu) — left navigation panel  

2. Click on 'Create Chatbot'  
   - Element: **Create Chatbot** (button) — main content area  
   - Notes: The button is visible only after data import is complete.

3. Select the target platform  
   - Element: **Platform** (dropdown) — form fields  
   - Options: DingTalk, Lark  
   - Notes: Users must choose one platform at a time.

4. Configure chatbot details  
   - Element: **Next** (button) — bottom of form  
   - Notes: The wizard includes visual previews of the final chatbot behavior.

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Chatbot Name | text_input | Yes | — | The name displayed for the chatbot in group chats. |
| Description | text_input | No | — | A brief description of the chatbot's purpose. |
| Knowledge Base | dropdown | Yes | Internal Documents, Marketing Materials, Customer Support FAQ, Product Catalog | Select the data source that the chatbot will use for responses. |

## FAQ

Q: Where do I find my API key for AI Search Open Platform?
A: Navigate to Console > AI Search Open Platform > API Keys Management and click "Manage API key" in the top navigation panel. You can create or view existing keys there.

Q: Can I modify the knowledge base configuration after creation?
A: Yes, you can edit most settings by returning to the Knowledge Base list, selecting your knowledge base, and clicking "Edit Configuration". However, some fields like Source Type may be locked after initial setup.

Q: What happens if I leave the "Reference Answer" field empty in the evaluation dataset?
A: It is acceptable to omit reference answers, but all questions in the same dataset must be consistent—either all include a reference answer or none do. Mixed formats will cause validation errors.

Q: Do I need to add my local IP to the Elasticsearch allowlist when testing from the console?
A: Yes. The AI Search Open Platform backend accesses your Elasticsearch instance from specific IPs (e.g., 47.100.254.67). Add this IP to your instance’s public allowlist to enable connectivity.

Q: Is the Experience Center trial environment free to use?
A: Yes. The Experience Center allows free trial access without login. Uploaded files are automatically deleted after seven days, and there is no cost for using services in the trial environment.

## Pricing & Billing

### Billing Model
Billing is based on a per-request model across most AI Search Open Platform services, including text generation, document splitting, embedding, and chatbot queries. Async tasks are billed upon completion.

### Price Reference

| Service | Input Price | Output Price |
|--------|-------------|--------------|
| ops-qwen-turbo | 0.002 /tokens | 0.002 /tokens |
| ops-document-analyze-001 | 0.002 /tokens | 0.002 /tokens |
| ops-text-embedding-001 | 0.002 /tokens | 0.002 /tokens |
| Document Splitting Service | 0.0005 / | — |
| Enterprise Chatbot | 0.001 / | 0.002 / |

### Free Tier
- Text generation, embedding, and document analysis: 1,000,000 tokens free per month
- Document splitting: 10,000 free requests per month
- Enterprise chatbot: 500 free requests per month
- Experience Center: Free trial with no usage limits beyond file size and retention policies

### Billing Notes
- Single request payload must not exceed 8 MB
- Token-based services enforce a maximum of 8K tokens per request
- Async tasks are billed only when completed; minimum 1-hour charge applies for certain long-running jobs
- Effect Evaluation is billed based on computing resources consumed during evaluation, not per request
- File uploads in Experience Center are limited to 20 MB and auto-deleted after 7 days