fixed missing up updates

This commit is contained in:
OwusuBlessing
2025-04-09 00:53:16 +01:00
parent d1ed8b9e3f
commit d34e304017
5 changed files with 248 additions and 137 deletions
+56 -23
View File
@@ -1,28 +1,61 @@
import os
import requests
import json
from typing import List
from dotenv import load_dotenv
load_dotenv()
import subprocess
import re
# List of packages you want to include
packages = [
"openai",
"pandas",
"python-dotenv",
"fastapi",
"uvicorn",
"langchain-community",
"langchain-openai",
"pydantic",
"pypdf",
"pypandoc",
"plum-dispatch==1.7.4", # You specified exact version here
"scikit-learn",
"werkzeug",
"python-multipart",
"langgraph",
"tiktoken",
"langchainhub",
"chromadb",
"langchain",
"langchain-text-splitters",
"beautifulsoup4",
"langchain-core",
"PyPDF2",
"reportlab",
"python-docx"
]
from src.llm import ai_chat
# Get all installed packages with versions
result = subprocess.run(["pip", "freeze"], capture_output=True, text=True)
installed_packages = result.stdout.strip().split('\n')
# Create a dictionary of package names to their full name with version
package_dict = {}
for pkg in installed_packages:
if '==' in pkg:
name = pkg.split('==')[0].lower()
package_dict[name] = pkg
#conversation_id = "12345" # Replace with the actual conversation ID
query = "Hello let us continue"
theme_id = 1
resume = "Emergency Response Specialist"
conversation_id = 1
response = ai_chat(query, conversation_id, theme_id, resume)
print(response)
"""
with open(file_path, 'rb') as file:
files = {'file': file}
response = requests.post(upload_url, files=files)
response.raise_for_status() # Ensure we raise an error for bad responses
response_data = response.json() # Get the response in JSON format
print(response_data)
"""
# Write only the requested packages to requirements.txt
with open('requirements.txt', 'w') as f:
for package in packages:
# Handle cases where version is already specifixed
if '==' in package:
f.write(f"{package}\n")
continue
# Try to find the package in installed packages
pkg_name = package.lower()
if pkg_name in package_dict:
f.write(f"{package_dict[pkg_name]}\n")
else:
# If not found, just write the package name
f.write(f"{package}\n")
print(f"Warning: {package} not found in installed packages")
print("requirements.txt has been generated.")