updated fireconfig
This commit is contained in:
@@ -26,6 +26,7 @@ import requests
|
||||
import os
|
||||
from PyPDF2 import PdfReader
|
||||
from config import QUIZ_TYPES
|
||||
from config import Config
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
API_KEY = os.getenv("API_KEY_ACCESS")
|
||||
@@ -33,7 +34,7 @@ API_KEY = os.getenv("API_KEY_ACCESS")
|
||||
base_path = os.path.join("data", "config_files")
|
||||
QUESTIONS_PATH = os.path.join(base_path, "questions.json")
|
||||
THEME_CONTEXT_PATH = os.path.join(base_path, "theme_context.json")
|
||||
|
||||
backend_base_url = Config.BACKEND_BASE_URL
|
||||
|
||||
|
||||
with open(THEME_CONTEXT_PATH, "r", encoding="utf-8") as f:
|
||||
@@ -175,7 +176,7 @@ async def chat_endpoint(
|
||||
detail="Invalid resume URL: Unable to fetch document"
|
||||
)
|
||||
resume_docs = "\n".join(f"- {doc.page_content}" for doc in docs)
|
||||
print(f"Loaded resume documents: {resume_docs}") # Debugging print
|
||||
print(f"Loaded resume documents: {resume_docs[:100]}") # Debugging print
|
||||
|
||||
full_history_docs = ""
|
||||
if request.full_history_url:
|
||||
@@ -188,14 +189,14 @@ async def chat_endpoint(
|
||||
detail="Invalid full history URL: Unable to fetch document"
|
||||
)
|
||||
full_history_docs = "\n".join(f"- {doc.page_content}" for doc in docs)
|
||||
print(f"Loaded full history documents: {full_history_docs}") # Debugging print
|
||||
print(f"Loaded full history documents: {full_history_docs[:100]}") # Debugging print
|
||||
|
||||
form_response_docs = ""
|
||||
if request.form_id:
|
||||
print(f"Fetching form response for form_id: {request.form_id}") # Debugging print
|
||||
try:
|
||||
x_api_key = os.getenv("BACKEND_XAPI_KEY")
|
||||
url = f"{os.getenv('BACKEND_BASE_URL')}/v3/api/custom/theme-document/answer/{request.form_id}?x-project={x_api_key}"
|
||||
url = f"{backend_base_url}/v3/api/custom/theme-document/answer/{request.form_id}?x-project={x_api_key}"
|
||||
result = requests.get(url)
|
||||
result.raise_for_status() # Ensure we raise an error for bad responses
|
||||
form_response = result.json()["data"] # Return response in JSON format
|
||||
@@ -268,7 +269,7 @@ async def generate_pdf_endpoint(
|
||||
detail="Invalid resume URL: Unable to fetch document"
|
||||
)
|
||||
resume_docs = "\n".join(f"- {doc.page_content}" for doc in docs)
|
||||
print(f"Loaded resume documents: {resume_docs}") # Debugging print
|
||||
print(f"Loaded resume documents: {resume_docs[:100]}") # Debugging print
|
||||
|
||||
full_history_docs = ""
|
||||
if request.full_history_url:
|
||||
@@ -281,14 +282,14 @@ async def generate_pdf_endpoint(
|
||||
detail="Invalid full history URL: Unable to fetch document"
|
||||
)
|
||||
full_history_docs = "\n".join(f"- {doc.page_content}" for doc in docs)
|
||||
print(f"Loaded full history documents: {full_history_docs}") # Debugging print
|
||||
print(f"Loaded full history documents: {full_history_docs[:100]}") # Debugging print
|
||||
|
||||
form_response_docs = ""
|
||||
if request.form_id:
|
||||
print(f"Fetching form response for form_id: {request.form_id}") # Debugging print
|
||||
try:
|
||||
x_api_key = os.getenv("BACKEND_XAPI_KEY")
|
||||
url = f"{os.getenv('BACKEND_BASE_URL')}/v3/api/custom/theme-document/answer/{request.form_id}?x-project={x_api_key}"
|
||||
url = f"{backend_base_url}/v3/api/custom/theme-document/answer/{request.form_id}?x-project={x_api_key}"
|
||||
result = requests.get(url)
|
||||
result.raise_for_status() # Ensure we raise an error for bad responses
|
||||
form_response = result.json()["data"] # Return response in JSON format
|
||||
@@ -331,7 +332,7 @@ async def generate_pdf_endpoint(
|
||||
file.write(pdf_content)
|
||||
|
||||
# Upload the PDF to S3 using the API
|
||||
upload_url = f"{os.getenv('BACKEND_BASE_URL')}/v3/api/custom/theme/doc-upload?x-project={x_api_key}"
|
||||
upload_url = f"{backend_base_url}/v3/api/custom/theme/doc-upload?x-project={x_api_key}"
|
||||
with open(file_path, 'rb') as file:
|
||||
files = {'file': file}
|
||||
upload_response = requests.post(upload_url, files=files)
|
||||
@@ -411,21 +412,6 @@ async def generate_quiz_endpoint(
|
||||
)
|
||||
|
||||
|
||||
|
||||
async def get_conversation_data(conversation_id: str) -> dict:
|
||||
"""
|
||||
Fetch conversation data using the conversation ID.
|
||||
Replace this with your actual implementation to fetch conversation data.
|
||||
"""
|
||||
try:
|
||||
storage_path = "conversations.json"
|
||||
with open(storage_path, 'r') as f:
|
||||
convs = json.load(f)
|
||||
convs_id = convs[conversation_id]
|
||||
return convs_id
|
||||
except Exception as e:
|
||||
print(f"Error fetching conversation data: {e}")
|
||||
return None
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
|
||||
Reference in New Issue
Block a user