Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jaime Collado
/
socialfairness-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
227a17ae
authored
Dec 14, 2023
by
Jaime Collado
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added toxicity and constructiveness models
parent
c31e087e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
app/api.py
app/schemas.py
app/api.py
View file @
227a17ae
...
...
@@ -6,6 +6,7 @@ from fastapi import FastAPI, HTTPException, status
from
fastapi.middleware.cors
import
CORSMiddleware
import
schemas
import
classifiers
from
ScraperNoticias.globalScraper
import
GlobalScraper
# APP
...
...
@@ -63,8 +64,24 @@ async def predict_toxicity(
Returns:
The toxicity of the text."""
# TODO: Aquí invocamos al modelo de toxicidad y devolvemos la predicción.
return
{
"prediction"
:
0.0
}
pred
=
classifiers
.
predict_toxicity
(
text
.
text
)
print
(
pred
,
type
(
pred
))
return
pred
[
0
]
@app.post
(
"/constructividad"
,
response_model
=
schemas
.
OutputPrediction
,
tags
=
[
"Prediction"
])
async
def
predict_constructiveness
(
text
:
schemas
.
InputText
):
"""Predicts constructiveness based on a given input text.
Args:
text: String containing news.
Returns:
The constructiveness of the text."""
pred
=
classifiers
.
predict_constructiveness
(
text
.
text
)
return
pred
[
0
]
@app.post
(
"/scrap"
,
response_model
=
schemas
.
ScrapedComments
,
tags
=
[
"Scraper"
])
async
def
scrap_url
(
...
...
app/schemas.py
View file @
227a17ae
...
...
@@ -8,7 +8,8 @@ class InputText(BaseModel):
class
OutputPrediction
(
BaseModel
):
"""Schema to define the output predictions' structure."""
prediction
:
float
label
:
str
score
:
float
class
InputURL
(
BaseModel
):
url
:
HttpUrl
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment