# 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=; aliyungf_tc=00c6b999835b16cea9e4a6aab36cca373a0976bf55ee74770d11f421f7119ad8; Hm_lvt_1db88642e346389874251b5a1eded6e3=1757464900; xq_a_token=975ab9f15a4965b9e557b9bc6f33bc1da20a0f49; xqat=975ab9f15a4965b9e557b9bc6f33bc1da20a0f49; xq_id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1aWQiOjg0OTM0MTE2MzQsImlzcyI6InVjIiwiZXhwIjoxNzYwMjU2NzM4LCJjdG0iOjE3NTc2NjQ3Mzg4MjUsImNpZCI6ImQ5ZDBuNEFadXAifQ.TMx4-TjKx96j5h6-EGiRIM2WKtJm1xctZhYidc40Em0pRcr0UBHAKBGl3No5r1BElYa9qnEDgNYI0Zv137Inx-EMPqm5cd1Z_ZjLdWOSLzT9qqBj8zdfuqJwP2nCYvC6KLjd8BvykS0vSFKqwb-r0WhEA3OzbO8teVNsaemdKAhBoIyP3-RQCfRxJ9RLNha1ZMdg66iZvfz_SOsG41y8IA9yyl-FFFJOq4TnAiywY1yO1QIJJhkh8YQqfnDfQQdSIFgJGToU980Lw1dm4aCDY-kvn-t18KjrL_hZJ_UNN65bgZsSsuWf-VQ7wsjjczNrfBYAHdZ6kES0CGo9g8IZZw; xq_r_token=c209224335327f29fc555d9910b43c0df6d52d5a; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1757774901; .thumbcache_f24b8bbe5a5934237bbc0eda20c1b6e7=rJD0qKtipTMjRBkLBVEyXbl0CiVeY7y4AxEZC0Vf6Zkou9cxp0NPsxwSrnOyFyBMr+Ws5/nJDO1NUalRDyAPsA%3D%3D; acw_tc=3ccdc14717578973700474899e2dc1c35b6358f1af81617250f8f00b4cf31c; ssxmod_itna=1-eqGxBDnGKYuxcD4kDRgxYq7ueYKS8DBP01Dp2xQyP08D60DB40Q0qRHhqDylAkiETFN1t42Y5D/KlYeDZDGFdDqx0Ei6FiYHK1ezjCGbKSAQY5P53Niio89NQ7DEQm6fjL1S4K7s5h8KRDo9n4hiDB3DbqDymgY5qxGGA4GwDGoD34DiDDPDb8rDALeD7qDFnenropTDm4GWneGfDDoDYbT3xiUYDDUvbeG2iET4DDN4bIGYZ2G76=r1doBip29xKiTDjqPD/ShUoiuzZKC4icFL2/amAeGyC5GuY6mWHQ77SWcbscAV70i8hx_Bx3rKqB5YGDRYqK8o2xY9iKR0YRDxeEDW0DWnQ8EwhDDiP46iRiGDYZtgrNMhXiY4MQA7bAilP4nPkFGCmqzBqGYesQGQiT3ihKbm5CexbxxD; ssxmod_itna2=1-eqGxBDnGKYuxcD4kDRgxYq7ueYKS8DBP01Dp2xQyP08D60DB40Q0qRHhqDylAkiETFN1t42YeDA4rYnRItORCitz/D3nyGQigbiD',
    '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]
    } 