rerun4
This commit is contained in:
parent
d655d0e141
commit
b9b76445fc
1 changed files with 1 additions and 48 deletions
|
|
@ -480,7 +480,6 @@ async def get_access_token(currentUser: Dict[str, Any] = Depends(getCurrentActiv
|
||||||
detail=f"Error getting access token: {str(e)}"
|
detail=f"Error getting access token: {str(e)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/token")
|
@router.post("/token")
|
||||||
async def get_backend_token(request: Request):
|
async def get_backend_token(request: Request):
|
||||||
"""Convert MSAL token to backend token"""
|
"""Convert MSAL token to backend token"""
|
||||||
|
|
@ -543,7 +542,7 @@ async def get_backend_token(request: Request):
|
||||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
detail=f"Error processing MSAL token: {str(e)}"
|
detail=f"Error processing MSAL token: {str(e)}"
|
||||||
)
|
)
|
||||||
=======
|
|
||||||
@router.post("/save-token")
|
@router.post("/save-token")
|
||||||
async def save_token(token_data: Dict[str, Any], currentUser: Dict[str, Any] = Depends(getCurrentActiveUser)):
|
async def save_token(token_data: Dict[str, Any], currentUser: Dict[str, Any] = Depends(getCurrentActiveUser)):
|
||||||
"""Save Microsoft token data from frontend"""
|
"""Save Microsoft token data from frontend"""
|
||||||
|
|
@ -568,49 +567,3 @@ async def save_token(token_data: Dict[str, Any], currentUser: Dict[str, Any] = D
|
||||||
"success": False,
|
"success": False,
|
||||||
"message": f"Error saving token: {str(e)}"
|
"message": f"Error saving token: {str(e)}"
|
||||||
})
|
})
|
||||||
|
|
||||||
async def generateFinalMessage(self, objUserResponse: str, objFinalDocuments: List[str], objResults: List[Dict[str, Any]]) -> Dict[str, Any]:
|
|
||||||
"""Generate the final message for the workflow"""
|
|
||||||
try:
|
|
||||||
# Get list of delivered documents
|
|
||||||
matchingDocuments = []
|
|
||||||
for result in objResults:
|
|
||||||
if "documents" in result:
|
|
||||||
for doc in result["documents"]:
|
|
||||||
if doc.get("label") in objFinalDocuments:
|
|
||||||
matchingDocuments.append(doc.get("label"))
|
|
||||||
|
|
||||||
# Use the mydom for language-aware AI calls
|
|
||||||
finalPrompt = await self.mydom.callAi([
|
|
||||||
{"role": "system", "content": "You are a project manager, who delivers results to a user."},
|
|
||||||
{"role": "user", "content": f"""
|
|
||||||
Give a brief summary of what has been accomplished, referencing the initial request (objUserResponse). List only the files that have been successfully delivered (filesDelivered). Keep the message concise and professional.
|
|
||||||
|
|
||||||
Here the data:
|
|
||||||
objUserResponse = {self.parseJson2text(objUserResponse)}
|
|
||||||
filesDelivered = {self.parseJson2text(matchingDocuments)}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
], produceUserAnswer=True)
|
|
||||||
|
|
||||||
# Create basic message structure with proper fields
|
|
||||||
logger.debug(f"FINAL PROMPT = {self.parseJson2text(finalPrompt)}.")
|
|
||||||
finalMessage = {
|
|
||||||
"role": "assistant",
|
|
||||||
"agentName": "Project Manager",
|
|
||||||
"content": finalPrompt,
|
|
||||||
"documents": [] # DO NOT include the results documents, already with agents
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug(f"FINAL MESSAGE = {self.parseJson2text(finalMessage)}.")
|
|
||||||
return finalMessage
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error generating final message: {str(e)}")
|
|
||||||
return {
|
|
||||||
"role": "assistant",
|
|
||||||
"agentName": "Project Manager",
|
|
||||||
"content": "I apologize, but there was an error generating the final message. Please check the logs for more details.",
|
|
||||||
"documents": []
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue