form id added for generating theme

This commit is contained in:
2025-02-06 21:01:22 +00:00
parent 142640325a
commit ed55e5e48e
5 changed files with 148 additions and 351 deletions
+16 -1
View File
@@ -95,6 +95,7 @@ class GeneratePDFRequest(BaseModel):
previous_results: Optional[Dict[str, Any]] = None
resume_url: Optional[str] = None
full_history_url: Optional[str] = None
form_id:Optional[int] = None
class QuizRequest(BaseModel):
pdf_url: str
@@ -200,7 +201,6 @@ async def chat_endpoint(
)
@app.post("/rescue-career/generate-theme")
async def generate_pdf_endpoint(
request: GeneratePDFRequest,
@@ -238,12 +238,27 @@ 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)
form_response_docs = ""
if request.form_id:
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}"
result = requests.get(url)
form_response = result.json() # Return response in JSON format
form_response_docs = "\n".join(f"- {form_response}")
except:
raise HTTPException(
status_code=400,
detail="Unable to fetch onborading data"
)
# Generate theme data using the generate_theme function
theme_data = generate_theme(
conversation_data=conversation_data,
feedback=request.feedback,
previous_result=request.previous_results,
resume = resume_docs,
form_response=form_response_docs,
full_history = full_history_docs
)