-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Detoxify Rest API Client #404
Conversation
[NEW] Constants module [FIX] Module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the Detoxify call & endpoint!
Requesting the following changes:
- use aiohttp
- store hf key in settings class instead of query-param
backend/oasst_backend/utils.py
Outdated
""" | ||
headers: Dict[str, str] = {"Authorization": f"Bearer {hf_token}"} | ||
payload: Dict[str, Any] = {"inputs": msg} | ||
response: Response = requests.post(HUGGINGFACE_TOXIC_ROBERTA_URL, headers=headers, json=payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use aiohttp
instead of requests
? see
session = aiohttp.ClientSession() |
|
||
Args: | ||
msg (str): the message that we want to analyze. | ||
hf_token (str): the token for the huggingface access. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HF token could better be stored in the backend configuration, e.g. as a member of our pydantic Settings classs.
backend/requirements.txt
Outdated
@@ -6,6 +6,7 @@ numpy==1.22.4 | |||
psycopg2-binary==2.9.5 | |||
pydantic==1.9.1 | |||
python-dotenv==0.21.0 | |||
requests==2.28.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget to remove...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, thanks. we probably should close the http session but I can add this later.
Added this in the PR. |
Create a REST API Client to get the Detoxify Classification from HuggingFace.