Fix dependency conflicts and improve path handling

- Update OpenAI version to >=1.6.1 to resolve LangChain conflict
- Remove LangChain dependencies (not needed for this implementation)
- Fix OpenAI imports to use newer v1+ API format
- Make database and storage paths flexible for different environments
- Update Alembic configuration to use dynamic database paths
- Ensure compatibility across different deployment environments

🤖 Generated with BackendIM

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Automated Action 2025-06-27 15:01:50 +00:00
parent 3d6b44a6e6
commit 0a1b22da00
6 changed files with 22 additions and 10 deletions

View File

@ -53,7 +53,7 @@ version_path_separator = os
# are written from script.py.mako
# output_encoding = utf-8
sqlalchemy.url = sqlite:////app/storage/db/db.sqlite
sqlalchemy.url = sqlite:///storage/db/db.sqlite
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run

View File

@ -4,16 +4,27 @@ from sqlalchemy import pool
from alembic import context
import os
import sys
from pathlib import Path
# Add the project root to the Python path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Import your models here
from app.db.base import Base
from app.models import user, resume, job, match, analytics
# this is the Alembic Config object
config = context.config
# Use the same database path logic as the main app
base_path = Path("/app") if Path("/app").exists() else Path.cwd()
db_dir = base_path / "storage" / "db"
db_dir.mkdir(parents=True, exist_ok=True)
database_url = f"sqlite:///{db_dir}/db.sqlite"
# Set the database URL for alembic
config.set_main_option("sqlalchemy.url", database_url)
# Interpret the config file for Python logging.
if config.config_file_name is not None:
fileConfig(config.config_file_name)

View File

@ -1,8 +1,11 @@
import os
from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
DB_DIR = Path("/app") / "storage" / "db"
# Use current working directory if /app doesn't exist
base_path = Path("/app") if Path("/app").exists() else Path.cwd()
DB_DIR = base_path / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"

View File

@ -1,14 +1,12 @@
import openai
from openai import OpenAI
from typing import Dict, List, Any
from app.core.config import settings
import json
openai.api_key = settings.OPENAI_API_KEY
class AIService:
def __init__(self):
self.client = openai.OpenAI(api_key=settings.OPENAI_API_KEY)
self.client = OpenAI(api_key=settings.OPENAI_API_KEY)
async def analyze_resume(self, resume_text: str) -> Dict[str, Any]:
"""Extract structured data from resume text using AI"""

View File

@ -7,7 +7,9 @@ from app.core.config import settings
class FileService:
def __init__(self):
self.upload_dir = Path("/app/storage/uploads")
# Use current working directory if /app doesn't exist
base_path = Path("/app") if Path("/app").exists() else Path.cwd()
self.upload_dir = base_path / "storage" / "uploads"
self.upload_dir.mkdir(parents=True, exist_ok=True)
def validate_file(self, file: UploadFile) -> bool:

View File

@ -8,9 +8,7 @@ python-multipart==0.0.6
python-jose[cryptography]==3.3.0
passlib[bcrypt]==1.7.4
httpx==0.25.2
openai==1.3.5
langchain==0.0.350
langchain-openai==0.0.2
openai>=1.6.1
PyPDF2==3.0.1
python-docx==1.1.0
ruff==0.1.6