Spaces:
Running
Running
Add feedback API endpoint
Browse files- services.py +36 -0
services.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import os
|
2 |
|
3 |
try:
|
@@ -23,6 +24,41 @@ class RfpRecommend(BaseAPI):
|
|
23 |
return results
|
24 |
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
class Inferencing(BaseAsyncAPI):
|
27 |
|
28 |
def __init__(self):
|
|
|
1 |
+
from typing import List, Dict, Optional, Any
|
2 |
import os
|
3 |
|
4 |
try:
|
|
|
24 |
return results
|
25 |
|
26 |
|
27 |
+
class RfpFeedback(BaseAPI):
|
28 |
+
|
29 |
+
def __init__(self):
|
30 |
+
super().__init__(
|
31 |
+
url=f'{os.getenv("RFP_RECOMMENDATION_URL")}/feedback',
|
32 |
+
headers={"x-api-key": os.getenv("RFP_RECOMMENDATION_API_KEY")},
|
33 |
+
total_retries=2,
|
34 |
+
backoff_factor=5
|
35 |
+
)
|
36 |
+
|
37 |
+
def __call__(
|
38 |
+
self,
|
39 |
+
recommendation_data: Dict[str, Any],
|
40 |
+
ratings: List[str],
|
41 |
+
info_is_correct: Optional[bool] = None,
|
42 |
+
info_is_sufficient: Optional[bool] = None,
|
43 |
+
comments: Optional[str] = None,
|
44 |
+
email: Optional[str] = None,
|
45 |
+
):
|
46 |
+
data = {
|
47 |
+
"recommendations": recommendation_data,
|
48 |
+
"ratings": ratings,
|
49 |
+
"correct_info": info_is_correct,
|
50 |
+
"sufficient_info": info_is_sufficient
|
51 |
+
}
|
52 |
+
|
53 |
+
if comments:
|
54 |
+
data["comments"] = comments
|
55 |
+
if email:
|
56 |
+
data["email"] = email
|
57 |
+
|
58 |
+
results = self.post(payload=data)
|
59 |
+
return results
|
60 |
+
|
61 |
+
|
62 |
class Inferencing(BaseAsyncAPI):
|
63 |
|
64 |
def __init__(self):
|