# Usage Scenarios Guide

## Table of Contents

1. [Basic Information Query](#1-basic-information-query)
2. [Report Generation](#2-report-generation)
3. [Technical Optimization](#3-technical-optimization)
4. [Anomaly Handling](#4-anomaly-handling)
5. [Multi-turn Dialogue](#5-multi-turn-dialogue)
6. [Query Formulation Tips](#6-query-formulation-tips)
7. [API Interface Characteristics](#7-api-interface-characteristics)

## 1. Basic Information Query

For questions about carbon emission factors, definitions, calculation methods, or policies.

**Examples:**
- "请解释产品碳足迹的定义、计算方法和应用场景"
- "多晶硅生产的碳排放因子是多少？"
- "ISO 14067 标准的主要要求有哪些？"
- "最新的碳排放政策有哪些变化？"

The backend agent will:
- Query emission factor database when factor values are involved
- Provide answers from multiple policy perspectives when policies are involved
- Include standard definitions, formulas, industry benchmarks, and standard references

## 2. Report Generation

For generating carbon footprint report drafts or sections.

**Examples:**
- "帮我生成一份光伏组件碳足迹报告的草案"
- "请按照 ISO 14067 标准生成系统边界设定章节"

The backend agent will produce structured output with:
- System boundary rationale (citing technical standards)
- Data collection methods
- Emission factor selection logic
- Uncertainty analysis

## 3. Technical Optimization

For reducing carbon footprint in specific production processes.

**Examples:**
- "如何降低多晶硅生产碳足迹？"
- "针对电池片生产环节，提出减排方案"

The agent may ask clarifying questions (e.g., which process variant) before providing 3 improvement plans with:
- Technical feasibility
- Reduction potential estimates
- Cost impact analysis

## 4. Anomaly Handling

For investigating unusual data or contradictions in carbon footprint data.

**Examples:**
- "生产报告中的能耗数据与碳足迹报告不一致，如何处理？"
- "某批次碳排放数据异常偏高，请分析原因"

The agent performs:
- Cross-validation between data sources
- Standard compliance checks
- Sensitivity analysis with error models

## 5. Multi-turn Dialogue

Use `conversation_id` from previous responses to maintain context:

```bash
# First turn
python3 scripts/carbon_footprint_chat.py -q "多晶硅生产碳足迹如何计算？"
# Returns conversation_id: "abc-123-def"

# Follow-up turn
python3 scripts/carbon_footprint_chat.py -q "西门子法具体怎么算？" -c "abc-123-def"
```

## 6. Query Formulation Tips

For best results, include in your query:
- **Specific product/process**: e.g., "单晶硅" vs generic "硅"
- **System boundary**: e.g., "从硅料到组件的全生命周期"
- **Target standard**: e.g., "按照 ISO 14067" or "按照国标"
- **Geographic scope**: e.g., "中国市场" or "欧洲市场"
- **Specific request type**: e.g., "请给出计算公式" or "请生成报告章节"

## 7. API Interface Characteristics

### Streaming Response Mode
- The API uses **streaming SSE (Server-Sent Events)** response mode
- Responses are returned incrementally as partial answer chunks
- Final response includes complete answer with `conversation_id` and `message_id`

### Timeout Settings
- **Maximum waiting time**: 200 seconds (configured in the client)
- If the API doesn't complete within 200 seconds, the client should handle timeout gracefully
- For complex queries requiring longer processing, consider breaking them into smaller sub-queries

### Response Handling
- Monitor for `event: message` events containing partial answer chunks in the `answer` field
- Wait for `event: message_end` event to get final metadata
- Handle connection errors with retry logic (recommended: 3 retries with exponential backoff)

### Best Practices
- Always set appropriate timeout limits in your client implementation
- Implement proper error handling for network interruptions
- Cache `conversation_id` for multi-turn dialogues
- Validate response completeness before presenting to users
