34 lines
955 B
Python
34 lines
955 B
Python
|
|
import os
|
|
import sys
|
|
from sqlalchemy import text
|
|
|
|
# Add backend directory to path
|
|
sys.path.append(os.path.join(os.getcwd(), 'backend'))
|
|
|
|
from app import create_app, db
|
|
from app.models import Agent
|
|
|
|
app = create_app()
|
|
|
|
with app.app_context():
|
|
try:
|
|
# Check DB connection
|
|
db.session.execute(text('SELECT 1'))
|
|
print("Database connection successful.")
|
|
|
|
# Update Agent
|
|
agent = Agent.query.filter_by(name='人事规章').first()
|
|
if agent:
|
|
print(f"Updating Agent: {agent.name}")
|
|
# Switch back to local mock server
|
|
agent.api_base_url = "http://127.0.0.1:5001/v1"
|
|
agent.dify_api_key = "app-xdiejQibWQy8ZQWXcdxJjS9I"
|
|
db.session.commit()
|
|
print("Agent updated to use Mock Server (127.0.0.1:5001).")
|
|
else:
|
|
print("Agent '人事规章' not found.")
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|