# 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; smidV2=20250327160437f244626e8b47ca2a7992f30f389e4e790074ae48656a22f10; HMACCOUNT=8B64A2E3C307C8C0; s=c611ttmqlj; xq_is_login=1; u=8493411634; bid=4065a77ca57a69c83405d6e591ab5449_m8r2nhs8; __utma=1.434320573.1747189698.1747189698.1747189698.1; __utmc=1; __utmz=1.1747189698.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); snbim_minify=true; _c_WBKFRo=dsWgHR8i8KGPbIyhFlN51PHOzVuuNytvUAFppfkD; _nb_ioWEgULi=; Hm_lvt_1db88642e346389874251b5a1eded6e3=1751936369; xq_a_token=ada154d4707b8d3f8aa521ff0c960aa7f81cbf9e; xqat=ada154d4707b8d3f8aa521ff0c960aa7f81cbf9e; xq_id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1aWQiOjg0OTM0MTE2MzQsImlzcyI6InVjIiwiZXhwIjoxNzU2MDAyNjgyLCJjdG0iOjE3NTM0MTA2ODI0MTQsImNpZCI6ImQ5ZDBuNEFadXAifQ.AlnzQSY7oGKGABfaQcFLg0lAJsDdvBMiwUbgpCMCBlbx6VZPKhzERxWiylQb4dFIyyECvRRJ73SbO9cD46fAqgzOgTxArNHtTKD4lQapTnyb11diDADnpb_nzzaRr4k_BYQRKXWtcJxdUMzde2WLy-eAkSf76QkXmKrwS3kvRm5gfqhdye44whw5XMEGoZ_lXHzGLWGz_PludHZp6W3v-wwZc_0wLU6cTb_KdrwWUWT_8jw5JHXnJEmuZmQI8QWf60DtiHIYCYXarxv8XtyHK7lLKhIAa3C2QmGWw5wv2HGz4I5DPqm2uMPKumgkQxycfAk56-RWviLZ8LAPF-XcbA; xq_r_token=92527e51353f90ba14d5fd16581e5a7a2780baa2; acw_tc=ac11000117534287625894768e00740076244cbad53d8039638dfe8ed0f4b1; is_overseas=1; .thumbcache_f24b8bbe5a5934237bbc0eda20c1b6e7=VRmy+KD3dGV+blntY70z3I+WQFcq8+JM1SqrC6E5295b/kwc4W5RkB+oXprCzEylFSeHXru7sQJDLmMr0mBJ+g%3D%3D; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1753429267; ssxmod_itna=eqGxBDnGKYuxcD4kDRgxYq7ueYKS8DBP01Dp2xQyP08D60DB40Q0KHhqDylYw0i2YwjCo0ZD5D/KCeGzDiLPGhDBWAFdYGdTt4NFtiowCWKGwktpe9flQbeeYGlcD0aK7G=x3EujH5Zn7iIiRoeDU4GnD0=O7YmKqxGGI4GwDGoD34DiDDpED03Db4D+4=bD7rTiocW=EjeDQ4GyDitDKLe=xi3DA4Djnl=qYiTdwDDBDGtON9aDG4GfSmDD0qtBeqT4DYP=5Pr8d29mpOWSneDMixGXz71+NI1yoYcrdvU6r+bOpPGuDG6CP3POd7nEaafY66i0DeGmKK+j0DrlDpYwMihyYwQGGiBqqQGo3qqCexhGC0G4ixqQARmPHK4vP2OIPeDEZgXDfExF0iY+K+mdFrKGmQGvwBP40PpFDC7KzBqG7W4QGt/D3ixt+R5BYobxxD; ssxmod_itna2=eqGxBDnGKYuxcD4kDRgxYq7ueYKS8DBP01Dp2xQyP08D60DB40Q0KHhqDylYw0i2YwjCo0ZYeDA4rYnRItORCDU1Z/PnDhxYG9pGD',
    '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"
        }
    },
    # 谷歌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]
    } 