feat(docker): containerize application and add TTS integration
This commit is contained in:
68
config/config.py
Normal file
68
config/config.py
Normal file
@ -0,0 +1,68 @@
|
||||
# config.py
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# --- OpenAI API Configuration ---
|
||||
|
||||
# !! 安全警告 !! 直接将 API 密钥写入代码风险很高。请优先考虑使用环境变量。
|
||||
# !! SECURITY WARNING !! Hardcoding API keys is highly discouraged due to security risks. Prefer environment variables.
|
||||
# 如果你确定要硬编码,请取消下一行的注释并填入你的密钥
|
||||
# OPENAI_API_KEY_CONFIG = "sk-YOUR_REAL_API_KEY_HERE" # <--- 在这里直接填入你的 OpenAI Key
|
||||
|
||||
# 如果 OPENAI_API_KEY_CONFIG 未定义 (被注释掉了), 则尝试从环境变量获取
|
||||
# This provides a fallback mechanism, but the primary request was to hardcode.
|
||||
# Uncomment the line above and fill it to hardcode the key.
|
||||
# OPENAI_API_KEY_FROM_CONFIG = os.getenv("OPENAI_API_KEY", "YOUR_API_KEY_PLACEHOLDER_IF_NOT_IN_ENV") # Fallback if not hardcoded above
|
||||
# If you absolutely want to force using only a hardcoded key from here, use:
|
||||
OPENAI_API_KEY_FROM_CONFIG = os.getenv("DOUBAO_API_KEY", "YOUR_API_KEY_PLACEHOLDER_IF_NOT_IN_ENV")
|
||||
|
||||
|
||||
# 直接在此处配置 API base URL
|
||||
# 设置为 None 使用官方地址, 或设置为你的代理/Azure 地址
|
||||
# Example for a proxy: "http://localhost:1234/v1"
|
||||
# Example for Azure: "https://YOUR_RESOURCE_NAME.openai.azure.com/"
|
||||
OPENAI_API_BASE_URL_CONFIG = (
|
||||
"https://ark.cn-beijing.volces.com/api/v3" # <--- 在这里直接填入你的 Base URL 或者 None
|
||||
)
|
||||
|
||||
# --- 选择模型和维度 ---
|
||||
OPENAI_EMBEDDING_MODEL = "doubao-embedding-large-text-250515"
|
||||
OPENAI_EMBEDDING_DIM = 2048
|
||||
OPENAI_EMBEDDING_KEY = os.getenv("DOUBAO_API_KEY", "YOUR_API_KEY_PLACEHOLDER_IF_NOT_IN_ENV")
|
||||
OPENAI_EMBEDDING_BASE = "https://ark.cn-beijing.volces.com/api/v3"
|
||||
OPENAI_LLM_MODEL = "doubao-seed-1-6-250615"
|
||||
|
||||
# ---huggingface模型---
|
||||
HUGGINGFACE_KEY = "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"
|
||||
HUGGINGFACE_EMBEDDING_MODEL = "BAAI/bge-m3"
|
||||
|
||||
# --- 豆包 TTS Configuration ---
|
||||
DOUBAO_TTS_API_URL = "https://openspeech.bytedance.com/api/v3/tts/unidirectional"
|
||||
DOUBAO_TTS_APP_ID = os.getenv("DOUBAO_TTS_APP_ID", "3842625790")
|
||||
DOUBAO_TTS_ACCESS_KEY = os.getenv("DOUBAO_TTS_KEY", "YOUR_ACCESS_KEY")
|
||||
DOUBAO_TTS_RESOURCE_ID = "seed-tts-1.0" # 豆包语音合成模型1.0 字符版
|
||||
DOUBAO_TTS_SPEAKER = "ICL_zh_female_aojiaonvyou_tob"
|
||||
DOUBAO_TTS_FORMAT = "mp3"
|
||||
DOUBAO_TTS_SAMPLE_RATE = 24000
|
||||
|
||||
# --- Milvus Lite Configuration (保持不变) ---
|
||||
USER_ID_PREFIX = "user"
|
||||
MILVUS_PERSIST_BASE_DIR = Path("./milvus_user_data_openai")
|
||||
MILVUS_INDEX_PARAMS = {"index_type": "FLAT", "metric_type": "L2", "params": {}}
|
||||
MILVUS_SEARCH_PARAMS = {"metric_type": "L2", "params": {}}
|
||||
MILVUS_STAND_URI = ""
|
||||
|
||||
# --- RAG Pipeline Configuration (保持不变) ---
|
||||
RETRIEVER_TOP_K = 3
|
||||
DEFAULT_PROMPT_TEMPLATE = """
|
||||
hello
|
||||
{% for doc in documents %}
|
||||
{{ doc.content }}
|
||||
{% endfor %}
|
||||
|
||||
问题: {{query}}
|
||||
答案:
|
||||
"""
|
||||
|
||||
# --- Application Settings (保持不变) ---
|
||||
DEFAULT_USER_ID = "user_openai"
|
Reference in New Issue
Block a user