Spaces:
Running
Running
forgot to add feedback code
Browse files- feedback.py +28 -0
feedback.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ask_candid.base.api_base import BaseAPI
|
| 2 |
+
from ask_candid.base.config.rest import Api, _load_value
|
| 3 |
+
|
| 4 |
+
ASSISTANT_API = Api(
|
| 5 |
+
url=_load_value("ASSISTANT_API_URL"),
|
| 6 |
+
key=_load_value("ASSISTANT_API_KEY")
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class FeedbackApi(BaseAPI):
|
| 11 |
+
|
| 12 |
+
def __init__(self):
|
| 13 |
+
super().__init__(
|
| 14 |
+
url=f"{ASSISTANT_API['url']}/feedback",
|
| 15 |
+
headers={"x-api-key": ASSISTANT_API["key"]}
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
def __call__(self, context, found_helpful, will_recommend, comments, email):
|
| 19 |
+
data = {
|
| 20 |
+
"context": context,
|
| 21 |
+
"found_helpful": found_helpful,
|
| 22 |
+
"will_recommend": will_recommend,
|
| 23 |
+
"comments": comments,
|
| 24 |
+
"email": email
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
result = self.post(payload=data)
|
| 28 |
+
return result
|