fix: 텔레그램 대화 Claude 클라이언트에 cliproxy base_url 적용
This commit is contained in:
+5
-1
@@ -51,6 +51,7 @@ logger = logging.getLogger(__name__)
|
|||||||
TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN', '')
|
TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN', '')
|
||||||
TELEGRAM_CHAT_ID = os.getenv('TELEGRAM_CHAT_ID', '')
|
TELEGRAM_CHAT_ID = os.getenv('TELEGRAM_CHAT_ID', '')
|
||||||
ANTHROPIC_API_KEY = os.getenv('ANTHROPIC_API_KEY', '')
|
ANTHROPIC_API_KEY = os.getenv('ANTHROPIC_API_KEY', '')
|
||||||
|
ANTHROPIC_BASE_URL = os.getenv('ANTHROPIC_BASE_URL', '')
|
||||||
|
|
||||||
_claude_client: anthropic.Anthropic | None = None
|
_claude_client: anthropic.Anthropic | None = None
|
||||||
_conversation_history: dict[int, list] = {}
|
_conversation_history: dict[int, list] = {}
|
||||||
@@ -1641,7 +1642,10 @@ async def handle_text(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||||||
|
|
||||||
global _claude_client
|
global _claude_client
|
||||||
if _claude_client is None:
|
if _claude_client is None:
|
||||||
_claude_client = anthropic.Anthropic(api_key=ANTHROPIC_API_KEY)
|
kwargs = {'api_key': ANTHROPIC_API_KEY}
|
||||||
|
if ANTHROPIC_BASE_URL:
|
||||||
|
kwargs['base_url'] = ANTHROPIC_BASE_URL
|
||||||
|
_claude_client = anthropic.Anthropic(**kwargs)
|
||||||
|
|
||||||
history = _conversation_history.setdefault(chat_id, [])
|
history = _conversation_history.setdefault(chat_id, [])
|
||||||
history.append({"role": "user", "content": text})
|
history.append({"role": "user", "content": text})
|
||||||
|
|||||||
Reference in New Issue
Block a user