# coding:utf-8

"""
通用配置文件，存储共享的配置项
"""

import random

XUEQIU_HEADERS = {
    'Accept': 'application/json, text/plain, */*',
    'Accept-Encoding': 'gzip, deflate, br, zstd',
    'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
    'Client-Version': 'v2.44.75',
    'Cookie': 'cookiesu=811743062689927; device_id=33fa3c7fca4a65f8f4354e10ed6b7470; HMACCOUNT=8B64A2E3C307C8C0; s=c611ttmqlj; xq_is_login=1; u=8493411634; bid=4065a77ca57a69c83405d6e591ab5449_m8r2nhs8; snbim_minify=true; _c_WBKFRo=dsWgHR8i8KGPbIyhFlN51PHOzVuuNytvUAFppfkD; _nb_ioWEgULi=; xq_a_token=ad294f938ec0f4739cf2240e92a5af63fe65cb92; xqat=ad294f938ec0f4739cf2240e92a5af63fe65cb92; xq_id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1aWQiOjg0OTM0MTE2MzQsImlzcyI6InVjIiwiZXhwIjoxNzY0MjI1NDgwLCJjdG0iOjE3NjE2MzM0ODA1MzksImNpZCI6ImQ5ZDBuNEFadXAifQ.QqKHMHHgh3_dcAjowcKT8GGsT-BC-GIidxMHoIQy_B7SlpX9LtkekXnUcc0mZkXk3TxLzs8F9MDfEIwpt55f_6-KQaNvXFOfkCdwIyWCyL5ZFA2gE_Dq0-3SoUf-TsYrCQ8TlBzBFojBgOIXFQrO_NBjXrqlIzSHVTtaAB0L9eUacvNGz8FHjhlgUh94nbOD5Y8kGoBG82AWlOkTtgPAQMyEWfrSc_IoJZ6lFehNKEfb3nDJoPUKAIBehoBhKUW7EqPfCeTPiZR9Oi48kliIbgXxYBaCO00L9B22f1WmtQsMvqI_0d5DSTvEd8J41IUKD6HSkOu5gG9qofUkLq_pvg; xq_r_token=bbc04b7f580b6a117c028e2b94470e868df34c17; acw_tc=1a0c640317627700667987423e7e8ee1ddcd7f4497028b2e109476f97be4b9; Hm_lvt_1db88642e346389874251b5a1eded6e3=; Hm_lp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Dq7xav83jqWdD',
    'Referer': 'https://weibo.com/u/7735765253',
    'Sec-Ch-Ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
    'Sec-Ch-Ua-Mobile': '?0',
    'Sec-Ch-Ua-Platform': '"Windows"',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'Server-Version': 'v2024.03.19.2',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
    'X-Requested-With': 'XMLHttpRequest',
    'X-Xsrf-Token': 'spbnXpnWWKiHZFvOqW4rIejO'
}

# 火山引擎API密钥列表
VOLC_API_KEYS = [
    "28cfe71a-c6fa-4c5d-9b4e-d8474f0d3b93",  # 测试密钥1
    "28cfe71a-c6fa-4c5d-9b4e-d8474f0d3b93",  # 可添加更多密钥
]

# 获取随机API密钥
def get_random_api_key():
    return random.choice(VOLC_API_KEYS)

# 火山引擎模型配置
VOLC_MODELS = {
    # 在线智能体模型
    "online_bot": "bot-20250325102825-h9kpq",      # 联网智能体ID
    
    # 离线模型
    "offline_model": "ep-20250326090920-v7wns",    # 免费推理50W

    "deepseek-private": "mlx-community/DeepSeek-R1-4bit",
    
    # 其他可用模型
    "doubao": "doubao-1-5-pro-32k-250115",         # 豆包模型
    "deepseek": "deepseek-r1-250120",              # Deepseek模型
}

# 获取指定类型的模型
def get_model(model_type):
    return VOLC_MODELS.get(model_type, VOLC_MODELS["offline_model"])

# 模型配置字典
MODEL_CONFIGS = {
    # 火山引擎配置
    "volc": {
        "base_url": "https://ark.cn-beijing.volces.com/api/v3/",
        "api_key": "28cfe71a-c6fa-4c5d-9b4e-d8474f0d3b93",
        "models": {
            "offline_model": "ep-20250326090920-v7wns",
            "online_bot": "bot-20250325102825-h9kpq",
            "doubao": "doubao-1-5-pro-32k-250115",
            "ds3_2": "ep-20260104113811-m2h2f"
        }
    },
    # 谷歌Gemini
    "Gemini": {
        "base_url": "https://generativelanguage.googleapis.com/v1beta/openai/",
        "api_key": "AIzaSyAVE8yTaPtN-TxCCHTc9Jb-aCV-Xo1EFuU",
        "models": {
            "offline_model": "gemini-2.0-flash"
        }
    },
    # 天链苹果
    "tl_private": {
        "base_url": "http://192.168.16.174:1234/v1/",
        "api_key": "none",
        "models": {
            "GLM": "glm-4-32b-0414-abliterated",
            "qwen3": "qwen3-235b-a22b",
        }
    },
    # 天链-千问
    "tl_qw_private": {
        "base_url": "http://192.168.16.178:11434/v1",
        "api_key": "sk-WaVRJKkyhrFlH4ZV35B9Aa61759b400c9cA002D00f3f1019",
        "models": {
            "qwq": "qwq:32b",
            "GLM": "hf-mirror.com/Cobra4687/GLM-4-32B-0414-abliterated-Q4_K_M-GGUF:Q4_K_M"
        }
    },
    # Deepseek配置
    "deepseek": {
        "base_url": "https://api.deepseek.com/v1/",
        "api_key": "your_deepseek_api_key",
        "models": {
            "deepseek": "deepseek-r1-250120",
            "deepseek-private": "mlx-community/DeepSeek-R1-4bit"
        }
    }
}

# 获取指定平台和模型的配置
def get_model_config(platform: str, model_type: str) -> dict:
    """获取指定平台和模型的配置
    
    Args:
        platform: 平台名称（volc/doubao/deepseek）
        model_type: 模型类型
        
    Returns:
        dict: 包含base_url、api_key和model的配置字典
    """
    if platform not in MODEL_CONFIGS:
        raise ValueError(f"不支持的平台: {platform}")
    
    platform_config = MODEL_CONFIGS[platform]
    if model_type not in platform_config["models"]:
        raise ValueError(f"平台 {platform} 不支持模型类型: {model_type}")
    
    return {
        "base_url": platform_config["base_url"],
        "api_key": platform_config["api_key"],
        "model": platform_config["models"][model_type]
    }

# Tushare配置
TUSHARE_TOKEN = 'ecac9722ee695a9f67a1dfb98e0ba71c72f088714795b7609f0e9390'  # 请替换为您的实际Tushare Token