-
Notifications
You must be signed in to change notification settings - Fork 0
Fixes for Chatqna on EMT #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
1ec4d57
cb55e64
4079477
ffbcd7b
92b0bb2
932afcf
d034c2f
9d5cacb
d87479c
ed73472
689ada8
58a63d9
1a78679
f289930
bb22029
fef7e5d
fbf9a1a
74e87ae
fa1a526
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.venv/ | ||
__pycache__/ | ||
.vscode |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,19 +47,31 @@ def rerank_tei(self, retrieved_docs: Dict[str, Any]) -> Dict[str, Any]: | |
"raw_scores": False, | ||
} | ||
|
||
response = requests.post( | ||
url=f"{self.reranking_endpoint}", | ||
json=request_body, | ||
headers={"Content-Type": "application/json"}, | ||
) | ||
if response.status_code == 200: | ||
logging.info(response.json()) | ||
try: | ||
response = requests.post( | ||
url=f"{self.reranking_endpoint}", | ||
json=request_body, | ||
headers={"Content-Type": "application/json"}, | ||
timeout=30 # Add timeout to prevent hanging | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded timeout? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted! Can add this along with the reranker flag |
||
) | ||
if response.status_code == 200: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to check thread safety in concurrent usage of the application. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't see issue during benchmark testing where we did concurrent runs and multiple requests. |
||
logging.info(response.json()) | ||
|
||
res = response.json() | ||
maxRank = max(res, key=lambda x: x["score"]) | ||
return { | ||
"question": retrieved_docs["question"], | ||
"context": [retrieved_docs["context"][maxRank["index"]]], | ||
} | ||
else: | ||
raise Exception(f"Error: {response.status_code}, {response.text}") | ||
res = response.json() | ||
maxRank = max(res, key=lambda x: x["score"]) | ||
return { | ||
"question": retrieved_docs["question"], | ||
"context": [retrieved_docs["context"][maxRank["index"]]], | ||
} | ||
else: | ||
logging.error(f"Reranker error: {response.status_code}, {response.text}") | ||
# Return original context if reranking fails | ||
return retrieved_docs | ||
except requests.exceptions.RequestException as e: | ||
logging.error(f"Reranker request failed: {str(e)}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specific exception handling? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted the change for specific exceptions. |
||
# Return original context if reranking fails | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a log / flag or some information to indicate results are without reranker. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This we should add, also to allow users to select whether to enable re-ranker as per the use case. Can we take this as enhancement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
return retrieved_docs | ||
except Exception as e: | ||
logging.error(f"Unexpected error in reranker: {str(e)}") | ||
# Return original context if reranking fails | ||
return retrieved_docs |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,4 +96,3 @@ chatqnaui: | |
|
||
nginxService: | ||
annotations: {} | ||
|
Uh oh!
There was an error while loading. Please reload this page.