Fix Occasional Long Operations (#84)

* Upgrade Packages and Change Connection Engine Settings

* fix (anthropic): use new sdk syntax
This commit is contained in:
Vineeth Voruganti 2024-12-27 15:03:45 -05:00 committed by GitHub
parent 08133a582f
commit 079084e67c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 633 additions and 693 deletions

View File

@ -13,7 +13,7 @@ dependencies = [
"sqlalchemy>=2.0.30",
"fastapi-pagination>=0.12.24",
"pgvector>=0.2.5",
"sentry-sdk[fastapi,sqlalchemy,anthropic]>=2.3.1",
"sentry-sdk[anthropic,fastapi,sqlalchemy]>=2.3.1",
"greenlet>=3.0.3",
"psycopg[binary]>=3.1.19",
"httpx>=0.27.0",

View File

@ -23,8 +23,11 @@ engine = create_async_engine(
connect_args=connect_args,
echo=True,
pool_pre_ping=True,
pool_size=20,
max_overflow=50,
pool_size=10,
max_overflow=20,
pool_timeout=30,
pool_recycle=300, # Recycle connections after 5 minutes
pool_use_lifo=True, # Use last-in-first-out (LIFO) to prevent connection spread
)
SessionLocal = async_sessionmaker(

View File

@ -9,6 +9,9 @@ async def get_db():
db: AsyncSession = SessionLocal()
try:
yield db
except Exception:
await db.rollback()
raise
finally:
await db.close()

View File

@ -71,7 +71,7 @@ async def tom_inference(
langfuse_context.update_current_observation(
input=messages, model="claude-3-5-sonnet-20240620"
)
message = anthropic.beta.prompt_caching.messages.create(
message = anthropic.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=1000,
temperature=0,
@ -142,7 +142,7 @@ async def user_representation(
langfuse_context.update_current_observation(
input=messages, model="claude-3-5-sonnet-20240620"
)
message = anthropic.beta.prompt_caching.messages.create(
message = anthropic.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=1000,
temperature=0,

1310
uv.lock

File diff suppressed because it is too large Load Diff