Create result.py
Browse files- reranker/result.py +29 -0
reranker/result.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, List, Dict, Any
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class RankingExecInfo:
|
| 5 |
+
def __init__(
|
| 6 |
+
self, prompt, response: str, input_token_count: int, output_token_count: int
|
| 7 |
+
):
|
| 8 |
+
self.prompt = prompt
|
| 9 |
+
self.response = response
|
| 10 |
+
self.input_token_count = input_token_count
|
| 11 |
+
self.output_token_count = output_token_count
|
| 12 |
+
|
| 13 |
+
def __repr__(self):
|
| 14 |
+
return str(self.__dict__)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class Result:
|
| 18 |
+
def __init__(
|
| 19 |
+
self,
|
| 20 |
+
query: str,
|
| 21 |
+
hits: List[Dict[str, Any]],
|
| 22 |
+
ranking_exec_summary: Optional[List[RankingExecInfo]] = None,
|
| 23 |
+
):
|
| 24 |
+
self.query = query
|
| 25 |
+
self.hits = hits
|
| 26 |
+
self.ranking_exec_summary = ranking_exec_summary
|
| 27 |
+
|
| 28 |
+
def __repr__(self):
|
| 29 |
+
return str(self.__dict__)
|