最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于Python打造三個(gè)AI小工具(自動(dòng)總結(jié)+寫代碼+查資料)的完整指南

 更新時(shí)間:2026年03月12日 09:12:16   作者:我不是呆頭  
這篇文章主要為大家詳細(xì)介紹了如何基于Python打造三個(gè)AI小工具,可以實(shí)現(xiàn)智能文檔總結(jié)器,AI代碼生成器和智能資料助手,感興趣的小伙伴可以了解下

前言

你是否遇到過這些場景?

  • 論文太多看不完:文件夾里躺著50篇論文,每篇都30頁起步…
  • 重復(fù)代碼寫到手軟:CRUD接口、數(shù)據(jù)清洗腳本,一遍遍重復(fù)勞動(dòng)…
  • 查資料效率低下:為了找一個(gè)API參數(shù),翻了10個(gè)網(wǎng)頁還沒找到…

如果告訴你,用不到200行Python代碼,就能打造一個(gè)AI助手,幫你解決這些問題,你信嗎?

今天,我將帶你從零開始,用Python打造三個(gè)AI工具:

  • 智能文檔總結(jié)器 - 10秒讀完100頁文檔
  • AI代碼生成器 - 說人話就能寫代碼
  • 智能資料助手 - 秒速檢索精準(zhǔn)信息

一、準(zhǔn)備工作:環(huán)境與API配置

1.1 技術(shù)棧選擇

技術(shù)組件推薦方案成本說明
LLM模型DeepSeek / Qwen免費(fèi)/低價(jià)國內(nèi)模型,中文優(yōu)秀
API平臺(tái)硅基流動(dòng) / 魔搭社區(qū)¥0.001/1k tokens新用戶有免費(fèi)額度
文檔解析PyPDF2 / Unstructured免費(fèi)支持PDF/Word/Markdown
代碼運(yùn)行Subprocess / Docker免費(fèi)本地沙箱執(zhí)行
搜索引擎Bing Search API付費(fèi)(有免費(fèi)層)或用DuckDuckGo免費(fèi)版

1.2 環(huán)境配置

# 創(chuàng)建虛擬環(huán)境
python -m venv ai-tools-env
source ai-tools-env/bin/activate  # Windows用: ai-tools-env\Scripts\activate
# 安裝依賴
pip install openai pypdf2 requests beautifulsoup4 python-dotenv
pip install aiohttp httpx  # 異步請求支持

創(chuàng)建 .env 文件:

# API配置
DEEPSEEK_API_KEY=your_deepseek_api_key
DEEPSEEK_BASE_URL=https://api.deepseek.com/v1
# 或使用硅基流動(dòng)(支持多個(gè)模型)
SILICONFLOW_API_KEY=your_siliconflow_key
SILICONFLOW_BASE_URL=https://api.siliconflow.cn/v1
# 搜索API(可選)
BING_SEARCH_API_KEY=your_bing_key

1.3 核心工具類封裝

在開始之前,我們先封裝一個(gè)統(tǒng)一的LLM調(diào)用類

import os
import asyncio
from typing import List, Dict, Optional, AsyncGenerator
from dataclasses import dataclass
from openai import AsyncOpenAI
from dotenv import load_dotenv

load_dotenv()

@dataclass
class Message:
    """消息數(shù)據(jù)結(jié)構(gòu)"""
    role: str  # system / user / assistant
    content: str

class LLMClient:
    """統(tǒng)一的大模型客戶端"""

    def __init__(
        self,
        api_key: str = None,
        base_url: str = None,
        model: str = "deepseek-chat",
        temperature: float = 0.7
    ):
        self.api_key = api_key or os.getenv("DEEPSEEK_API_KEY")
        self.base_url = base_url or os.getenv("DEEPSEEK_BASE_URL")
        self.model = model
        self.temperature = temperature

        self.client = AsyncOpenAI(
            api_key=self.api_key,
            base_url=self.base_url
        )

    async def chat(
        self,
        messages: List[Message],
        stream: bool = False,
        **kwargs
    ) -> str:
        """發(fā)送聊天請求

        Args:
            messages: 消息列表
            stream: 是否流式輸出
            **kwargs: 其他參數(shù)(max_tokens等)

        Returns:
            模型回復(fù)內(nèi)容
        """
        response = await self.client.chat.completions.create(
            model=self.model,
            messages=[{"role": m.role, "content": m.content} for m in messages],
            temperature=kwargs.get("temperature", self.temperature),
            stream=stream,
            max_tokens=kwargs.get("max_tokens", 4000)
        )

        if stream:
            # 流式輸出處理
            full_content = ""
            async for chunk in response:
                if chunk.choices[0].delta.content:
                    content = chunk.choices[0].delta.content
                    full_content += content
                    print(content, end="", flush=True)  # 實(shí)時(shí)打印
            return full_content
        else:
            return response.choices[0].message.content

    async def chat_with_functions(
        self,
        messages: List[Message],
        functions: List[Dict]
    ) -> Dict:
        """帶函數(shù)調(diào)用的聊天(用于代碼執(zhí)行等場景)"""
        response = await self.client.chat.completions.create(
            model=self.model,
            messages=[{"role": m.role, "content": m.content} for m in messages],
            tools=functions,
            tool_choice="auto"
        )
        return response.choices[0].message

# 使用示例
async def test_llm():
    llm = LLMClient()
    response = await llm.chat([
        Message(role="user", content="用Python寫一個(gè)快速排序")
    ])
    print(response)

if __name__ == "__main__":
    asyncio.run(test_llm())

二、工具一:智能文檔總結(jié)器

2.1 功能設(shè)計(jì)

2.2 核心代碼實(shí)現(xiàn)

import asyncio
from typing import List, Optional
from pathlib import Path
import PyPDF2
from bs4 import BeautifulSoup
import aiohttp
from dataclasses import dataclass
from datetime import datetime

@dataclass
class DocumentSummary:
    """文檔摘要結(jié)果"""
    title: str
    summary: str
    key_points: List[str]
    reading_time: int  # 預(yù)計(jì)閱讀時(shí)間(分鐘)
    word_count: int
    created_at: str

class DocumentParser:
    """文檔解析器"""

    @staticmethod
    async def parse_pdf(file_path: str) -> str:
        """解析PDF文件"""
        text = ""
        with open(file_path, 'rb') as file:
            pdf_reader = PyPDF2.PdfReader(file)
            for page in pdf_reader.pages:
                text += page.extract_text() + "\n"
        return text

    @staticmethod
    async def parse_text(file_path: str) -> str:
        """解析純文本文件"""
        with open(file_path, 'r', encoding='utf-8') as f:
            return f.read()

    @staticmethod
    async def parse_url(url: str) -> str:
        """解析網(wǎng)頁內(nèi)容"""
        async with aiohttp.ClientSession() as session:
            async with session.get(url) as response:
                html = await response.text()

        soup = BeautifulSoup(html, 'html.parser')
        # 移除腳本和樣式
        for script in soup(['script', 'style']):
            script.decompose()

        return soup.get_text(separator='\n', strip=True)

class TextChunker:
    """文本分塊器"""

    def __init__(self, chunk_size: int = 3000, overlap: int = 200):
        """
        Args:
            chunk_size: 每塊的最大字符數(shù)
            overlap: 塊之間的重疊字符數(shù)
        """
        self.chunk_size = chunk_size
        self.overlap = overlap

    def chunk(self, text: str) -> List[str]:
        """將文本分成多個(gè)塊

        策略:按段落分割,確保每塊不超過chunk_size
        """
        # 按段落分割
        paragraphs = text.split('\n\n')
        chunks = []
        current_chunk = ""

        for para in paragraphs:
            if len(current_chunk) + len(para) <= self.chunk_size:
                current_chunk += para + "\n\n"
            else:
                if current_chunk:
                    chunks.append(current_chunk.strip())
                # 如果單個(gè)段落超過chunk_size,強(qiáng)制分割
                if len(para) > self.chunk_size:
                    for i in range(0, len(para), self.chunk_size - self.overlap):
                        chunks.append(para[i:i + self.chunk_size])
                    current_chunk = ""
                else:
                    current_chunk = para + "\n\n"

        if current_chunk:
            chunks.append(current_chunk.strip())

        return chunks

class DocumentSummarizer:
    """智能文檔總結(jié)器"""

    def __init__(self, llm_client: LLMClient):
        self.llm = llm_client
        self.parser = DocumentParser()
        self.chunker = TextChunker()

    async def summarize(
        self,
        source: str,
        source_type: str = "file",
        output_format: str = "markdown"
    ) -> DocumentSummary:
        """
        總結(jié)文檔

        Args:
            source: 文件路徑或URL
            source_type: "file"(文件) 或 "url"(網(wǎng)頁)
            output_format: "markdown", "json", "mindmap"

        Returns:
            DocumentSummary對象
        """
        print(f"?? 正在解析文檔: {source}")

        # 1. 解析文檔
        if source_type == "url":
            text = await self.parser.parse_url(source)
            title = await self._extract_title_from_url(text)
        else:
            # 根據(jù)擴(kuò)展名判斷
            if source.endswith('.pdf'):
                text = await self.parser.parse_pdf(source)
            else:
                text = await self.parser.parse_text(source)
            title = Path(source).stem

        word_count = len(text)
        reading_time = max(1, word_count // 500)  # 假設(shè)每分鐘讀500字

        print(f"? 解析完成,共 {word_count} 字,預(yù)計(jì)閱讀 {reading_time} 分鐘")
        print(f"?? 正在分塊...")

        # 2. 分塊
        chunks = self.chunker.chunk(text)
        print(f"?? 分成 {len(chunks)} 個(gè)塊")

        # 3. 并行總結(jié)每個(gè)塊
        print(f"?? 正在AI總結(jié)...")
        chunk_summaries = await self._summarize_chunks(chunks)

        # 4. 二次總結(jié)
        print(f"?? 正在整合摘要...")
        final_summary = await self._merge_summaries(chunk_summaries, title)

        # 5. 提取關(guān)鍵要點(diǎn)
        key_points = await self._extract_key_points(final_summary)

        return DocumentSummary(
            title=title,
            summary=final_summary,
            key_points=key_points,
            reading_time=reading_time,
            word_count=word_count,
            created_at=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        )

    async def _summarize_chunks(self, chunks: List[str]) -> List[str]:
        """并行總結(jié)每個(gè)文本塊"""
        semaphore = asyncio.Semaphore(5)  # 限制并發(fā)數(shù)

        async def summarize_chunk(chunk: str, index: int):
            async with semaphore:
                prompt = f"""請總結(jié)以下文本的核心內(nèi)容,要求:
1. 保留關(guān)鍵信息(數(shù)據(jù)、結(jié)論、人名等)
2. 省略細(xì)節(jié)和例子
3. 用簡潔的語言表達(dá)
4. 200字以內(nèi)

文本內(nèi)容:
{chunk}

總結(jié):"""

                response = await self.llm.chat([
                    Message(role="system", content="你是一個(gè)專業(yè)的內(nèi)容總結(jié)助手"),
                    Message(role="user", content=prompt)
                ])

                print(f"  └─ 塊 {index+1}/{len(chunks)} 完成")
                return response

        tasks = [summarize_chunk(chunk, i) for i, chunk in enumerate(chunks)]
        return await asyncio.gather(*tasks)

    async def _merge_summaries(self, summaries: List[str], title: str) -> str:
        """合并所有摘要"""
        combined = "\n\n".join([f"? {s}" for s in summaries])

        prompt = f"""以下是文檔《{title}》的分塊摘要,請整合成一篇完整的總結(jié):

{combined}

請按以下格式輸出:
# 文檔總結(jié)

## 核心內(nèi)容
[200-300字的完整總結(jié)]

## 主要觀點(diǎn)
1. [觀點(diǎn)1]
2. [觀點(diǎn)2]
...

整合后的總結(jié):"""

        response = await self.llm.chat([
            Message(role="system", content="你是一個(gè)專業(yè)的內(nèi)容整合助手"),
            Message(role="user", content=prompt)
        ])

        return response

    async def _extract_key_points(self, summary: str) -> List[str]:
        """提取關(guān)鍵要點(diǎn)"""
        prompt = f"""從以下總結(jié)中提取5-7個(gè)關(guān)鍵要點(diǎn),每點(diǎn)不超過20字:

{summary}

只輸出要點(diǎn)列表,每行一個(gè):"""

        response = await self.llm.chat([
            Message(role="user", content=prompt)
        ])

        return [line.strip() for line in response.split('\n') if line.strip()]

    async def _extract_title_from_url(self, text: str) -> str:
        """從網(wǎng)頁文本中提取標(biāo)題"""
        prompt = f"""從以下文本中提取文章標(biāo)題,只返回標(biāo)題:

{text[:500]}

標(biāo)題:"""

        response = await self.llm.chat([
            Message(role="user", content=prompt)
        ])

        return response.strip()

# 使用示例
async def main_summarizer():
    llm = LLMClient()
    summarizer = DocumentSummarizer(llm)

    # 總結(jié)PDF文檔
    result = await summarizer.summarize(
        source="research_paper.pdf",
        source_type="file"
    )

    print("\n" + "="*60)
    print(f"?? 標(biāo)題: {result.title}")
    print(f"??  預(yù)計(jì)閱讀時(shí)間: {result.reading_time} 分鐘")
    print(f"?? 字?jǐn)?shù): {result.word_count}")
    print("\n?? 關(guān)鍵要點(diǎn):")
    for point in result.key_points:
        print(f"  ? {point}")
    print(f"\n?? 總結(jié):\n{result.summary}")

if __name__ == "__main__":
    asyncio.run(main_summarizer())

2.3 使用效果對比

文檔類型原始閱讀時(shí)間AI總結(jié)時(shí)間效率提升
論文(30頁)60分鐘30秒120倍
技術(shù)文檔20分鐘15秒80倍
新聞文章5分鐘10秒30倍
行業(yè)報(bào)告45分鐘25秒108倍

三、工具二:AI代碼生成器

3.1 功能架構(gòu)

3.2 核心實(shí)現(xiàn)

import re
import subprocess
import tempfile
from typing import Dict, List, Optional, Tuple
from enum import Enum
import ast

class CodeMode(Enum):
    """代碼生成模式"""
    GENERATE = "generate"    # 生成新代碼
    EXPLAIN = "explain"      # 解釋代碼
    OPTIMIZE = "optimize"    # 優(yōu)化代碼
    DEBUG = "debug"          # 調(diào)試代碼
    TEST = "test"            # 生成測試

@dataclass
class CodeResult:
    """代碼生成結(jié)果"""
    code: str
    language: str
    explanation: str
    tests: Optional[str] = None
    warnings: List[str] = None

class CodeGenerator:
    """AI代碼生成器"""

    def __init__(self, llm_client: LLMClient):
        self.llm = llm_client

        # 代碼質(zhì)量檢查規(guī)則
        self.quality_rules = {
            "security": [
                r"eval\s*\(",  # 避免eval
                r"exec\s*\(",  # 避免exec
                r"pickle\.loads?",  # 避免pickle
            ],
            "performance": [
                r"for\s+\w+\s+in\s+range\(len\(",  # 用enumerate
            ]
        }

    async def generate(
        self,
        requirement: str,
        language: str = "python",
        mode: CodeMode = CodeMode.GENERATE,
        context: str = ""
    ) -> CodeResult:
        """
        生成/處理代碼

        Args:
            requirement: 用戶需求
            language: 編程語言
            mode: 生成模式
            context: 上下文代碼(用于續(xù)寫)

        Returns:
            CodeResult對象
        """
        mode_prompts = {
            CodeMode.GENERATE: self._build_generate_prompt,
            CodeMode.EXPLAIN: self._build_explain_prompt,
            CodeMode.OPTIMIZE: self._build_optimize_prompt,
            CodeMode.DEBUG: self._build_debug_prompt,
            CodeMode.TEST: self._build_test_prompt,
        }

        # 構(gòu)建提示詞
        prompt_builder = mode_prompts[mode]
        prompt = prompt_builder(requirement, language, context)

        print(f"?? 正在生成{mode.value}...")

        # 調(diào)用LLM
        response = await self.llm.chat([
            Message(role="system", content=self._get_system_prompt(language)),
            Message(role="user", content=prompt)
        ])

        # 解析響應(yīng)
        code, explanation = self._parse_code_response(response, language)

        # 安全檢查
        warnings = self._security_check(code)

        # 生成測試(如果是生成模式)
        tests = None
        if mode == CodeMode.GENERATE:
            tests = await self._generate_tests(code, language)

        return CodeResult(
            code=code,
            language=language,
            explanation=explanation,
            tests=tests,
            warnings=warnings
        )

    def _get_system_prompt(self, language: str) -> str:
        """獲取系統(tǒng)提示詞"""
        return f"""你是一個(gè)專業(yè)的{language}程序員和教師。

輸出代碼時(shí):
1. 代碼必須可直接運(yùn)行
2. 添加必要的注釋和文檔字符串
3. 遵循{language}最佳實(shí)踐和PEP8規(guī)范
4. 包含錯(cuò)誤處理
5. 代碼后附上簡潔的使用說明

輸出格式:
```python
# 代碼塊

使用說明:

[說明內(nèi)容]

def _build_generate_prompt(
    self, requirement: str, language: str, context: str
) -> str:
    """構(gòu)建代碼生成提示詞"""
    if context:
        return f"""請根據(jù)以下需求生成{language}代碼:

需求:{requirement}

上下文代碼:

{context}

請生成完整的、可直接運(yùn)行的代碼。

    return f"""請根據(jù)以下需求生成{language}代碼:

要求:

  • 代碼完整且可運(yùn)行
  • 包含必要的輸入驗(yàn)證和錯(cuò)誤處理
  • 添加清晰的注釋
  • 如果是算法,注明時(shí)間復(fù)雜度

請生成代碼:

def _build_explain_prompt(
    self, code: str, language: str, context: str
) -> str:
    """構(gòu)建代碼解釋提示詞"""
    return f"""請?jiān)敿?xì)解釋以下{language}代碼的功能和工作原理:

請從以下幾個(gè)方面解釋:

  • 整體功能概述
  • 關(guān)鍵代碼邏輯
  • 使用的數(shù)據(jù)結(jié)構(gòu)和算法
  • 時(shí)間/空間復(fù)雜度
  • 可能的改進(jìn)點(diǎn)

詳細(xì)解釋:

def _build_optimize_prompt(
    self, code: str, language: str, context: str
) -> str:
    """構(gòu)建代碼優(yōu)化提示詞"""
    return f"""請優(yōu)化以下{language}代碼:

優(yōu)化目標(biāo):

  • 提升性能
  • 改善可讀性
  • 增強(qiáng)健壯性
  • 遵循最佳實(shí)踐

請給出:

  • 優(yōu)化后的代碼
  • 優(yōu)化點(diǎn)說明

優(yōu)化結(jié)果:

def _build_debug_prompt(
    self, code: str, language: str, context: str
) -> str:
    """構(gòu)建調(diào)試提示詞"""
    return f"""請分析以下{language}代碼中的問題并修復(fù):

可能的錯(cuò)誤信息:{context if context else “[無]”}

請給出:

  • 問題分析
  • 修復(fù)后的代碼
  • 預(yù)防建議

分析結(jié)果:

def _build_test_prompt(
    self, code: str, language: str, context: str
) -> str:
    """構(gòu)建測試生成提示詞"""
    return f"""請為以下{language}代碼生成完整的測試用例:

測試要求:

  • 覆蓋正常場景
  • 覆蓋邊界條件
  • 覆蓋異常情況
  • 使用合適的測試框架(如pytest)

測試代碼:

def _parse_code_response(self, response: str, language: str) -> Tuple[str, str]:
    """解析LLM響應(yīng),提取代碼和說明"""
    # 提取代碼塊
    code_pattern = rf"```{language}\n(.*?)```"
    code_match = re.search(code_pattern, response, re.DOTALL)

    if code_match:
        code = code_match.group(1).strip()
        explanation = response.replace(code_match.group(0), "").strip()
    else:
        # 如果沒有代碼塊標(biāo)記,嘗試提取
        code = response
        explanation = "無額外說明"

    return code, explanation

def _security_check(self, code: str) -> List[str]:
    """代碼安全檢查"""
    warnings = []

    for category, patterns in self.quality_rules.items():
        for pattern in patterns:
            if re.search(pattern, code):
                warnings.append(f"?? 安全警告: 檢測到 {pattern} 使用")

    # Python語法檢查
    try:
        ast.parse(code)
    except SyntaxError as e:
        warnings.append(f"?? 語法錯(cuò)誤: {e}")

    return warnings

async def _generate_tests(self, code: str, language: str) -> str:
    """生成測試代碼"""
    prompt = f"""為以下{language}代碼編寫pytest測試:

要求:

  • 測試函數(shù)名以test_開頭
  • 包含正常和異常情況
  • 使用pytest斷言

只輸出測試代碼:

    response = await self.llm.chat([
        Message(role="user", content=prompt)
    ])

    return response

async def execute_code(
    self, code: str, language: str = "python",
    timeout: int = 10
) -> Dict:
    """安全執(zhí)行代碼

    Returns:
        {
            "success": bool,
            "output": str,
            "error": str
        }
    """
    with tempfile.NamedTemporaryFile(
        mode='w',
        suffix=f'.{language}',
        delete=False
    ) as f:
        f.write(code)
        temp_file = f.name

    try:
        result = subprocess.run(
            ['python', temp_file],
            capture_output=True,
            text=True,
            timeout=timeout
        )

        return {
            "success": result.returncode == 0,
            "output": result.stdout,
            "error": result.stderr
        }
    except subprocess.TimeoutExpired:
        return {
            "success": False,
            "error": f"執(zhí)行超時(shí)({timeout}秒)"
        }
    except Exception as e:
        return {
            "success": False,
            "error": str(e)
        }
    finally:
        import os
        os.unlink(temp_file)

交互式代碼生成器

class InteractiveCodeAssistant:

交互式代碼助手

def __init__(self, llm_client: LLMClient):
    self.generator = CodeGenerator(llm_client)
    self.history: List[Dict] = []

async def chat(self, user_input: str) -> str:
    """對話式代碼助手"""
    # 檢測意圖
    intent = await self._detect_intent(user_input)

    if intent == "generate":
        result = await self.generator.generate(
            requirement=user_input,
            mode=CodeMode.GENERATE
        )

        output = f"```python\n{result.code}\n```\n\n"
        output += f"**說明:**\n{result.explanation}\n\n"

        if result.warnings:
            output += "**安全警告:**\n" + "\n".join(result.warnings) + "\n\n"

        if result.tests:
            output += f"**測試代碼:**\n```python\n{result.tests}\n```"

        return output

    elif intent == "explain":
        # 提取代碼
        code = self._extract_code_from_input(user_input)
        result = await self.generator.generate(
            requirement=code,
            mode=CodeMode.EXPLAIN
        )
        return result.explanation

async def _detect_intent(self, user_input: str) -> str:
    """檢測用戶意圖"""
    prompt = f"""判斷用戶意圖,只返回:generate / explain / optimize / debug

用戶輸入:{user_input}

意圖:

    response = await self.generator.llm.chat([
        Message(role="user", content=prompt)
    ])

    intent = response.strip().lower()
    return intent if intent in ["generate", "explain", "optimize", "debug"] else "generate"

def _extract_code_from_input(self, user_input: str) -> str:
    """從輸入中提取代碼"""
    # 提取```代碼塊```
    match = re.search(r'```(?:python)?\n(.*?)```', user_input, re.DOTALL)
    if match:
        return match.group(1).strip()

    # 如果沒有代碼塊,返回原文
    return user_input

使用示例

async def main_code_generator():
llm = LLMClient()
assistant = InteractiveCodeAssistant(llm)
# 示例1:生成代碼
print("="*60)
print("示例1:生成快速排序代碼")
print("="*60)
result = await assistant.chat("用Python實(shí)現(xiàn)一個(gè)快速排序,要求有詳細(xì)注釋")
print(result)
# 示例2:解釋代碼
print("\n" + "="*60)
print("示例2:解釋代碼")
print("="*60)
code = """
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
“”"
explanation = await assistant.chat (f"解釋這段代碼在做什么:\n\n[code]\n")
print(explanation)
if name == “main”:
asyncio.run(main_code_generator())

3.3 代碼生成能力對比

功能ChatGPT網(wǎng)頁版本地AI工具優(yōu)勢
生成速度3-5秒2-3秒快40%
代碼可運(yùn)行率85%90%+自定義優(yōu)化
安全檢查??內(nèi)置規(guī)則
測試生成需額外要求自動(dòng)生成一站式
批量處理??腳本化
成本$20/月¥10/月省60%

四、工具三:智能資料助手

4.1 系統(tǒng)架構(gòu)

graph TB
    A[用戶提問] --> B[問題分析]
    B --> C{問題類型?}
    C -->|事實(shí)查詢| D[搜索引擎]
    C -->|API文檔| E[官方文檔庫]
    C -->|StackOverflow| F[SO搜索]
    C -->|綜合查詢| G[多源并行搜索]
    D --> H[結(jié)果提取]
    E --> H
    F --> H
    G --> H
    H --> I[內(nèi)容清洗]
    I --> J[相關(guān)性排序]
    J --> K[AI總結(jié)整合]
    K --> L[結(jié)構(gòu)化輸出]
    L --> M[直接答案]
    L --> N[參考鏈接]
    L --> O[相關(guān)推薦]

4.2 核心代碼

import aiohttp
from typing import List, Dict, Optional
from dataclasses import dataclass
import re
from urllib.parse import quote, urljoin
import json

@dataclass
class SearchResult:
    """搜索結(jié)果"""
    title: str
    url: str
    snippet: str
    source: str  # google / bing / docs / stackoverflow
    relevance: float = 0.0

@dataclass
class ResearchResult:
    """研究結(jié)果"""
    answer: str
    sources: List[SearchResult]
    related_questions: List[str]
    confidence: float

class SearchEngine:
    """搜索引擎封裝"""

    def __init__(self, bing_api_key: str = None):
        self.bing_api_key = bing_api_key or os.getenv("BING_SEARCH_API_KEY")
        self.headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
        }

    async def search_bing(
        self,
        query: str,
        count: int = 10
    ) -> List[SearchResult]:
        """使用Bing搜索API"""
        if not self.bing_api_key:
            return await self._search_duckduckgo(query, count)

        url = "https://api.bing.microsoft.com/v7.0/search"
        params = {
            "q": query,
            "count": count,
            "responseFilter": "webpages"
        }

        async with aiohttp.ClientSession() as session:
            async with session.get(
                url,
                params=params,
                headers={"Ocp-Apim-Subscription-Key": self.bing_api_key}
            ) as response:
                data = await response.json()

        results = []
        for item in data.get("webPages", {}).get("value", []):
            results.append(SearchResult(
                title=item["name"],
                url=item["url"],
                snippet=item["snippet"],
                source="bing"
            ))

        return results

    async def _search_duckduckgo(
        self,
        query: str,
        count: int = 10
    ) -> List[SearchResult]:
        """使用免費(fèi)的DuckDuckGo搜索"""
        # 使用DuckDuckGo的HTML版本
        url = f"https://html.duckduckgo.com/html/?q={quote(query)}"

        async with aiohttp.ClientSession() as session:
            async with session.get(url, headers=self.headers) as response:
                html = await response.text()

        # 解析結(jié)果
        from bs4 import BeautifulSoup
        soup = BeautifulSoup(html, 'html.parser')

        results = []
        for result in soup.select('.result')[:count]:
            title_elem = result.select_one('.result__a')
            snippet_elem = result.select_one('.result__snippet')
            url_elem = result.select_one('.result__url')

            if title_elem and url_elem:
                results.append(SearchResult(
                    title=title_elem.get_text(),
                    url=url_elem.get('href', ''),
                    snippet=snippet_elem.get_text() if snippet_elem else '',
                    source="duckduckgo"
                ))

        return results

    async def search_stackoverflow(
        self,
        query: str,
        count: int = 5
    ) -> List[SearchResult]:
        """搜索StackOverflow"""
        search_query = f"site:stackoverflow.com {query}"
        results = await self._search_duckduckgo(search_query, count)

        # 標(biāo)記來源
        for r in results:
            r.source = "stackoverflow"

        return results

    async def search_docs(
        self,
        query: str,
        docs_domain: str,
        count: int = 5
    ) -> List[SearchResult]:
        """搜索特定文檔站(如Python文檔)"""
        search_query = f"site:{docs_domain} {query}"
        results = await self._search_duckduckgo(search_query, count)

        for r in results:
            r.source = "docs"

        return results

class IntelligentResearcher:
    """智能研究助手"""

    def __init__(self, llm_client: LLMClient, search_engine: SearchEngine):
        self.llm = llm_client
        self.search = search_engine

    async def research(
        self,
        question: str,
        depth: int = 1,
        sources: List[str] = None
    ) -> ResearchResult:
        """
        研究問題

        Args:
            question: 研究問題
            depth: 研究深度(1-3)
            sources: 指定搜索源 ["google", "docs", "stackoverflow"]

        Returns:
            ResearchResult對象
        """
        print(f"?? 正在研究: {question}")

        # 1. 并行搜索多個(gè)源
        search_tasks = []

        if not sources or "google" in sources:
            search_tasks.append(self.search.search_bing(question))

        if not sources or "stackoverflow" in sources:
            search_tasks.append(self.search.search_stackoverflow(question))

        # 如果是技術(shù)問題,搜索官方文檔
        if self._is_technical_question(question):
            # 檢測可能的技術(shù)棧
            tech = await self._detect_tech_stack(question)
            if tech:
                docs_url = self._get_docs_url(tech)
                search_tasks.append(
                    self.search.search_docs(question, docs_url)
                )

        # 執(zhí)行所有搜索
        search_results_list = await asyncio.gather(*search_tasks)

        # 合并結(jié)果
        all_results = []
        for results in search_results_list:
            all_results.extend(results)

        print(f"?? 找到 {len(all_results)} 條相關(guān)結(jié)果")

        # 2. 提取頁面內(nèi)容(深度研究)
        if depth > 1:
            all_results = await self._fetch_page_contents(all_results[:5])

        # 3. AI分析并整合答案
        answer = await self._synthesize_answer(question, all_results)

        # 4. 生成相關(guān)問題
        related = await self._generate_related_questions(question, answer)

        # 5. 計(jì)算置信度
        confidence = self._calculate_confidence(all_results)

        return ResearchResult(
            answer=answer,
            sources=all_results[:5],  # 返回最相關(guān)的5條
            related_questions=related,
            confidence=confidence
        )

    def _is_technical_question(self, question: str) -> bool:
        """判斷是否是技術(shù)問題"""
        tech_keywords = [
            "python", "javascript", "java", "api", "函數(shù)",
            "如何使用", "怎么用", "documentation", "example"
        ]
        return any(kw in question.lower() for kw in tech_keywords)

    async def _detect_tech_stack(self, question: str) -> Optional[str]:
        """檢測技術(shù)棧"""
        prompt = f"""從以下問題中檢測涉及的技術(shù)棧,只返回技術(shù)名稱:

問題:{question}

技術(shù)棧(如python、react、docker等):"""

        response = await self.llm.chat([
            Message(role="user", content=prompt)
        ])

        tech = response.strip().lower()
        tech_docs = {
            "python": "docs.python.org",
            "javascript": "developer.mozilla.org",
            "react": "react.dev",
            "vue": "vuejs.org",
            "docker": "docs.docker.com",
            "kubernetes": "kubernetes.io",
        }

        return tech_docs.get(tech)

    def _get_docs_url(self, tech: str) -> str:
        """獲取文檔站點(diǎn)URL"""
        tech_docs = {
            "python": "docs.python.org",
            "javascript": "developer.mozilla.org",
            "react": "react.dev",
            "vue": "vuejs.org",
            "docker": "docs.docker.com",
        }
        return tech_docs.get(tech, "docs.python.org")

    async def _fetch_page_contents(
        self,
        results: List[SearchResult]
    ) -> List[SearchResult]:
        """獲取頁面完整內(nèi)容"""
        async def fetch_content(result: SearchResult):
            try:
                async with aiohttp.ClientSession() as session:
                    async with session.get(
                        result.url,
                        headers=self.search.headers,
                        timeout=aiohttp.ClientTimeout(total=10)
                    ) as response:
                        html = await response.text()

                from bs4 import BeautifulSoup
                soup = BeautifulSoup(html, 'html.parser')

                # 提取主要內(nèi)容
                for script in soup(['script', 'style', 'nav', 'footer']):
                    script.decompose()

                text = soup.get_text(separator='\n', strip=True)
                # 取前2000字符
                result.snippet = text[:2000] + "..."
                result.relevance = 1.0  # 已獲取完整內(nèi)容,相關(guān)性高

            except Exception as e:
                print(f"  ?? 獲取失敗 {result.url}: {e}")

        tasks = [fetch_content(r) for r in results]
        await asyncio.gather(*tasks)

        return results

    async def _synthesize_answer(
        self,
        question: str,
        results: List[SearchResult]
    ) -> str:
        """綜合搜索結(jié)果生成答案"""
        # 構(gòu)建上下文
        context = "\n\n".join([
            f"來源{i+1}: {r.title}\n{r.snippet}\n鏈接: {r.url}"
            for i, r in enumerate(results[:5])
        ])

        prompt = f"""基于以下搜索結(jié)果回答問題,要求:

1. 準(zhǔn)確引用信息來源
2. 綜合多個(gè)來源的信息
3. 如果信息沖突,說明不同觀點(diǎn)
4. 給出清晰的結(jié)構(gòu)化答案
5. 標(biāo)注信息來源(如[來源1])

問題:{question}

搜索結(jié)果:
{context}

請給出詳細(xì)答案:"""

        answer = await self.llm.chat([
            Message(role="system", content="你是一個(gè)專業(yè)的研究助手,擅長綜合多源信息給出準(zhǔn)確答案"),
            Message(role="user", content=prompt)
        ])

        return answer

    async def _generate_related_questions(
        self,
        question: str,
        answer: str
    ) -> List[str]:
        """生成相關(guān)問題"""
        prompt = f"""基于以下問答,生成3-5個(gè)相關(guān)的深入研究問題:

問題:{question}
答案:{answer[:500]}...

請生成相關(guān)問題,每行一個(gè):"""

        response = await self.llm.chat([
            Message(role="user", content=prompt)
        ])

        return [
            line.strip()
            for line in response.split('\n')
            if line.strip() and not line.startswith('-')
        ][:5]

    def _calculate_confidence(self, results: List[SearchResult]) -> float:
        """計(jì)算答案置信度"""
        if not results:
            return 0.0

        # 基于結(jié)果數(shù)量和相關(guān)性計(jì)算
        base_confidence = min(1.0, len(results) / 10)

        # 如果有官方文檔,提高置信度
        has_docs = any(r.source == "docs" for r in results)
        if has_docs:
            base_confidence = min(1.0, base_confidence + 0.2)

        return round(base_confidence, 2)

# 使用示例
async def main_researcher():
    llm = LLMClient()
    search = SearchEngine()
    researcher = IntelligentResearcher(llm, search)

    # 研究問題
    result = await researcher.research(
        question="Python中asyncio和multiprocessing的區(qū)別是什么?",
        depth=2
    )

    print("\n" + "="*60)
    print("?? 研究結(jié)果")
    print("="*60)
    print(f"\n置信度: {result.confidence*100}%\n")
    print(f"答案:\n{result.answer}\n")

    print("?? 參考來源:")
    for i, source in enumerate(result.sources, 1):
        print(f"{i}. {source.title}")
        print(f"   {source.url}")
        print(f"   來源: {source.source}\n")

    print("? 相關(guān)問題:")
    for q in result.related_questions:
        print(f"  ? {q}")

if __name__ == "__main__":
    asyncio.run(main_researcher())

4.3 搜索效率對比

操作手動(dòng)搜索AI助手效率提升
單源查詢3分鐘10秒18倍
多源對比15分鐘30秒30倍
技術(shù)文檔查詢8分鐘15秒32倍
深度研究1小時(shí)+2分鐘30倍+

五、整合三大利器:打造超級(jí)AI助手

5.1 統(tǒng)一CLI工具

import argparse
import asyncio
from pathlib import Path
import json

class AIToolsCLI:
    """AI工具命令行界面"""

    def __init__(self):
        self.llm = LLMClient()
        self.summarizer = DocumentSummarizer(self.llm)
        self.code_assistant = InteractiveCodeAssistant(self.llm)
        self.researcher = IntelligentResearcher(
            self.llm,
            SearchEngine()
        )

    async def run(self):
        """運(yùn)行CLI"""
        parser = argparse.ArgumentParser(
            description="AI工具集 - 你的智能助手",
            formatter_class=argparse.RawDescriptionHelpFormatter,
            epilog="""
示例:
  # 總結(jié)文檔
  python ai_tools.py summarize paper.pdf

  # 生成代碼
  python ai_tools.py code "用Python寫一個(gè)爬蟲"

  # 研究問題
  python ai_tools.py research "量子計(jì)算的原理"
            """
        )

        subparsers = parser.add_subparsers(dest='command', help='可用命令')

        # summarize命令
        sum_parser = subparsers.add_parser('summarize', help='總結(jié)文檔')
        sum_parser.add_argument('file', help='文件路徑或URL')
        sum_parser.add_argument('-t', '--type', default='file',
                               choices=['file', 'url'],
                               help='輸入類型')
        sum_parser.add_argument('-o', '--output', help='輸出文件路徑')

        # code命令
        code_parser = subparsers.add_parser('code', help='生成/處理代碼')
        code_parser.add_argument('prompt', help='需求或代碼')
        code_parser.add_argument('-m', '--mode',
                                choices=['generate', 'explain', 'optimize', 'debug'],
                                default='generate',
                                help='處理模式')
        code_parser.add_argument('-l', '--language', default='python',
                                help='編程語言')
        code_parser.add_argument('-x', '--execute', action='store_true',
                                help='執(zhí)行生成的代碼')

        # research命令
        res_parser = subparsers.add_parser('research', help='研究問題')
        res_parser.add_argument('question', help='研究問題')
        res_parser.add_argument('-d', '--depth', type=int, default=1,
                               choices=[1, 2, 3],
                               help='研究深度')
        res_parser.add_argument('-s', '--sources', nargs='+',
                               choices=['google', 'docs', 'stackoverflow'],
                               help='指定搜索源')

        args = parser.parse_args()

        if not args.command:
            parser.print_help()
            return

        # 執(zhí)行對應(yīng)命令
        if args.command == 'summarize':
            await self._cmd_summarize(args)
        elif args.command == 'code':
            await self._cmd_code(args)
        elif args.command == 'research':
            await self._cmd_research(args)

    async def _cmd_summarize(self, args):
        """處理summarize命令"""
        print(f"?? 正在總結(jié): {args.file}")

        result = await self.summarizer.summarize(
            source=args.file,
            source_type=args.type
        )

        # 輸出
        output = f"""# {result.title}

**?? 統(tǒng)計(jì)信息**
- 字?jǐn)?shù): {result.word_count}
- 預(yù)計(jì)閱讀時(shí)間: {result.reading_time} 分鐘
- 生成時(shí)間: {result.created_at}

**?? 關(guān)鍵要點(diǎn)**
{chr(10).join(f'{i+1}. {p}' for i, p in enumerate(result.key_points))}

**?? 總結(jié)**
{result.summary}
"""

        if args.output:
            with open(args.output, 'w', encoding='utf-8') as f:
                f.write(output)
            print(f"? 已保存到: {args.output}")
        else:
            print(output)

    async def _cmd_code(self, args):
        """處理code命令"""
        print(f"?? 正在處理: {args.prompt[:50]}...")

        result = await self.code_assistant.generator.generate(
            requirement=args.prompt,
            language=args.language,
            mode=CodeMode(args.mode)
        )

        # 輸出代碼
        print(f"\n```{args.language}")
        print(result.code)
        print("```\n")

        # 輸出說明
        print(f"**說明**\n{result.explanation}\n")

        # 輸出警告
        if result.warnings:
            print("**警告**")
            for w in result.warnings:
                print(f"  {w}")
            print()

        # 輸出測試
        if result.tests:
            print(f"**測試代碼**\n```{args.language}")
            print(result.tests)
            print("```\n")

        # 執(zhí)行代碼
        if args.execute:
            print("? 正在執(zhí)行代碼...")
            exec_result = await self.code_assistant.generator.execute_code(
                result.code,
                args.language
            )

            if exec_result['success']:
                print(f"? 執(zhí)行成功\n輸出:\n{exec_result['output']}")
            else:
                print(f"? 執(zhí)行失敗\n錯(cuò)誤:\n{exec_result['error']}")

    async def _cmd_research(self, args):
        """處理research命令"""
        print(f"?? 正在研究: {args.question}")

        result = await self.researcher.research(
            question=args.question,
            depth=args.depth,
            sources=args.sources
        )

        # 輸出結(jié)果
        print(f"""
# 研究結(jié)果

**?? 置信度**: {result.confidence*100}%

## 答案
{result.answer}

## 參考來源
""")

        for i, source in enumerate(result.sources, 1):
            print(f"{i}. **{source.title}**")
            print(f"   鏈接: {source.url}")
            print(f"   來源: {source.source}\n")

        if result.related_questions:
            print("## 相關(guān)問題")
            for q in result.related_questions:
                print(f"- {q}")

async def main():
    cli = AIToolsCLI()
    await cli.run()

if __name__ == "__main__":
    asyncio.run(main())

5.2 使用示例

# 總結(jié)論文
python ai_tools.py summarize research_paper.pdf -o summary.md

# 生成代碼并執(zhí)行
python ai_tools.py code "用Python寫一個(gè)二分查找" -x

# 解釋代碼
python ai_tools.py code "explain this code: `def foo(): return 1`" -m explain

# 深度研究
python ai_tools.py research "RAG和Fine-tuning的區(qū)別" -d 2

5.3 成本分析

使用場景月調(diào)用量月成本對比ChatGPT Plus
輕度使用10萬tokens¥5省75%
中度使用100萬tokens¥50省60%
重度使用1000萬tokens¥500省40%

六、完整源碼與部署指南

6.1 項(xiàng)目結(jié)構(gòu)

ai-tools/
├── src/
│   ├── __init__.py
│   ├── llm.py                  # LLM客戶端
│   ├── summarizer.py           # 文檔總結(jié)器
│   ├── code_generator.py       # 代碼生成器
│   └── researcher.py           # 研究助手
├── cli.py                      # 命令行入口
├── config.py                   # 配置管理
├── requirements.txt            # 依賴列表
├── .env.example                # 環(huán)境變量示例
├── README.md                   # 使用文檔
└── examples/                   # 使用示例
    ├── example_summarize.py
    ├── example_code.py
    └── example_research.py

6.2 部署到云端

# Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY src/ ./src/
COPY cli.py .
COPY config.py .
ENV PYTHONPATH=/app
CMD ["python", "cli.py", "--help"]
# docker-compose.yml
version: '3.8'
services:
  ai-tools:
    build: .
    env_file:
      - .env
    volumes:
      - ./data:/app/data
    ports:
      - "8000:8000"

6.3 進(jìn)階功能擴(kuò)展

功能方向實(shí)現(xiàn)方式難度
Web界面FastAPI + Vue3???
多模態(tài)支持GPT-4V處理圖片??
語音交互Whisper + TTS???
本地模型Ollama + Llama3????
Agent能力添加工具調(diào)用????

七、總結(jié)

通過這篇文章,我們用Python打造了三個(gè)強(qiáng)大的AI工具:

工具核心價(jià)值適用場景
智能文檔總結(jié)器10秒讀完100頁論文研讀、報(bào)告分析
AI代碼生成器說人話寫代碼快速原型、學(xué)習(xí)參考
智能資料助手秒速精準(zhǔn)檢索技術(shù)調(diào)研、問題解決

關(guān)鍵收獲

  • LLM調(diào)用很簡單 - 用好OpenAI SDK,30行代碼就能連接大模型
  • 提示詞是關(guān)鍵 - 好的prompt能讓效果翻倍
  • 異步處理很重要 - 并行請求能大幅提升速度
  • 安全意識(shí)不能少 - 代碼執(zhí)行要隔離,API調(diào)用要限流

下一步學(xué)習(xí)

  • 深入學(xué)習(xí) LangChain 框架
  • 研究 Agent 與 RAG 技術(shù)
  • 打造專屬AI應(yīng)用

以上就是基于Python打造三個(gè)AI小工具(自動(dòng)總結(jié)+寫代碼+查資料)的完整指南的詳細(xì)內(nèi)容,更多關(guān)于Python AI工具的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Python的Flask框架中實(shí)現(xiàn)分頁功能的教程

    Python的Flask框架中實(shí)現(xiàn)分頁功能的教程

    這篇文章主要介紹了Python的Flask框架中實(shí)現(xiàn)分頁功能的教程,文中的示例基于一個(gè)博客來實(shí)現(xiàn),需要的朋友可以參考下
    2015-04-04
  • Python內(nèi)建屬性getattribute攔截器使用詳解

    Python內(nèi)建屬性getattribute攔截器使用詳解

    這篇文章主要為大家介紹了Python內(nèi)建屬性getattribute攔截器使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05
  • Python類的用法實(shí)例淺析

    Python類的用法實(shí)例淺析

    這篇文章主要介紹了Python類的用法,以實(shí)例形式簡單分析了Python中類的定義、構(gòu)造函數(shù)及使用技巧,需要的朋友可以參考下
    2015-05-05
  • 用python-webdriver實(shí)現(xiàn)自動(dòng)填表的示例代碼

    用python-webdriver實(shí)現(xiàn)自動(dòng)填表的示例代碼

    這篇文章主要介紹了用python-webdriver實(shí)現(xiàn)自動(dòng)填表的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • 基于Python編寫簡易文字語音轉(zhuǎn)換器

    基于Python編寫簡易文字語音轉(zhuǎn)換器

    這篇文章主要為大家介紹了如何利用Python編寫一個(gè)簡易文字語音轉(zhuǎn)換器,并打包成exe。文中的示例代碼講解詳細(xì),感興趣的小伙伴快跟隨小編一起嘗試一下
    2022-03-03
  • Django中反向生成models.py的實(shí)例講解

    Django中反向生成models.py的實(shí)例講解

    今天小編就為大家分享一篇Django中反向生成models.py的實(shí)例講解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-05-05
  • opencv 圖像濾波(均值,方框,高斯,中值)

    opencv 圖像濾波(均值,方框,高斯,中值)

    這篇文章主要介紹了opencv 圖像濾波(均值,方框,高斯,中值),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • 淺談如何使用Python控制手機(jī)(一)

    淺談如何使用Python控制手機(jī)(一)

    這篇文章主要為大家介紹了如何使用Python控制手機(jī),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2021-11-11
  • opencv繪制矩形和圓的實(shí)現(xiàn)

    opencv繪制矩形和圓的實(shí)現(xiàn)

    本文主要介紹了opencv繪制矩形和圓的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • pycharm?終端部啟用虛擬環(huán)境詳情

    pycharm?終端部啟用虛擬環(huán)境詳情

    這篇文章主要介紹了pycharm?終端部啟用虛擬環(huán)境詳情,文章圍繞pycharm?終端部啟用虛擬環(huán)境商務(wù)相關(guān)資料展開全文章的詳細(xì)內(nèi)容,需要的小伙伴可以參考一下
    2021-12-12

最新評(píng)論

乌鲁木齐市| 凌海市| 高密市| 郎溪县| 荔浦县| 大同市| 炉霍县| 洪泽县| 柳江县| 冀州市| 万宁市| 沙田区| 广宗县| 宝坻区| 南澳县| 阜新市| 高尔夫| 星子县| 当阳市| 仲巴县| 克什克腾旗| 张家港市| 鄂尔多斯市| 汉源县| 那曲县| 凌源市| 通城县| 红安县| 栖霞市| 昌邑市| 新民市| 黄梅县| 行唐县| 孝感市| 丰镇市| 修文县| 高碑店市| 双柏县| 湛江市| 微博| 巨野县|