fix: use VERCEL_AI_GATEWAY_KEY, fix infisical_fetch call in deploy
This commit is contained in:
parent
2555d9a17e
commit
92ae862c2d
3 changed files with 15 additions and 9 deletions
|
|
@ -1,4 +1,4 @@
|
|||
TG_BOT_TOKEN=CHANGE_ME
|
||||
OPENAI_API_KEY=CHANGE_ME
|
||||
OPENAI_BASE_URL=https://api.openai.com/v1
|
||||
MODEL=gpt-4.1
|
||||
VERCEL_AI_GATEWAY_KEY=CHANGE_ME
|
||||
OPENAI_BASE_URL=https://ai-gateway.vercel.sh/v1
|
||||
MODEL=anthropic/claude-sonnet-4
|
||||
|
|
|
|||
14
main.py
14
main.py
|
|
@ -17,14 +17,16 @@ from telegram.ext import (
|
|||
filters,
|
||||
)
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(levelname)s %(message)s")
|
||||
logging.basicConfig(
|
||||
level=logging.INFO, format="%(asctime)s %(name)s %(levelname)s %(message)s"
|
||||
)
|
||||
log = logging.getLogger("betterbot")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Config
|
||||
# ---------------------------------------------------------------------------
|
||||
TG_BOT_TOKEN = os.environ["TG_BOT_TOKEN"]
|
||||
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
|
||||
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY") or os.environ["VERCEL_AI_GATEWAY_KEY"]
|
||||
OPENAI_BASE_URL = os.environ.get("OPENAI_BASE_URL", "https://api.openai.com/v1")
|
||||
MODEL = os.environ.get("MODEL", "gpt-4.1")
|
||||
SITE_DIR = pathlib.Path(os.environ.get("SITE_DIR", "/site"))
|
||||
|
|
@ -209,7 +211,9 @@ async def handle_message(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None
|
|||
for tc in msg.tool_calls:
|
||||
import json
|
||||
|
||||
args = json.loads(tc.function.arguments) if tc.function.arguments else {}
|
||||
args = (
|
||||
json.loads(tc.function.arguments) if tc.function.arguments else {}
|
||||
)
|
||||
log.info("Tool call: %s(%s)", tc.function.name, list(args.keys()))
|
||||
try:
|
||||
result = handle_tool_call(tc.function.name, args)
|
||||
|
|
@ -235,7 +239,9 @@ async def handle_message(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None
|
|||
await update.message.reply_text(msg.content)
|
||||
return
|
||||
|
||||
await update.message.reply_text("I ran out of steps — please try again with a simpler request.")
|
||||
await update.message.reply_text(
|
||||
"I ran out of steps — please try again with a simpler request."
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ fi
|
|||
|
||||
# Fetch secrets from Infisical if available
|
||||
if [ -f /opt/config/infisical-agent.env ] && [ -f /opt/src/self_hosting/infra/scripts/infisical-env.sh ]; then
|
||||
source /opt/config/infisical-agent.env
|
||||
bash /opt/src/self_hosting/infra/scripts/infisical-env.sh racknerd-betterbot prod "$STACK_DIR/.env"
|
||||
source /opt/src/self_hosting/infra/scripts/infisical-env.sh
|
||||
infisical_fetch racknerd-betterbot "$STACK_DIR/.env"
|
||||
fi
|
||||
|
||||
cd "$STACK_DIR"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue