File size: 764 Bytes
7e2754c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from ask_candid.base.api_base import BaseAPI
from ask_candid.base.config.rest import Api, _load_value

ASSISTANT_API = Api(
    url=_load_value("ASSISTANT_API_URL"),
    key=_load_value("ASSISTANT_API_KEY")
)


class FeedbackApi(BaseAPI):

    def __init__(self):
        super().__init__(
            url=f"{ASSISTANT_API['url']}/feedback",
            headers={"x-api-key": ASSISTANT_API["key"]}
        )

    def __call__(self, context, found_helpful, will_recommend, comments, email):
        data = {
            "context": context,
            "found_helpful": found_helpful,
            "will_recommend": will_recommend,
            "comments": comments,
            "email": email
        }

        result = self.post(payload=data)
        return result