disable neural API
This commit is contained in:
parent
dd8f5aa764
commit
5b987e7f07
|
@ -184,11 +184,10 @@ object User extends LilaController {
|
|||
(!isGranted(_.SetEmail, user) ?? UserRepo.email(user.id)) zip
|
||||
(Env.security userSpy user.id) zip
|
||||
(Env.mod.assessApi.getPlayerAggregateAssessmentWithGames(user.id)) zip
|
||||
Env.mod.logApi.userHistory(user.id) zip
|
||||
Env.mod.callNeural(user) flatMap {
|
||||
case ((((email, spy), playerAggregateAssessment), history), neuralResult) =>
|
||||
Env.mod.logApi.userHistory(user.id) flatMap {
|
||||
case ((((email, spy), playerAggregateAssessment), history)) =>
|
||||
(Env.playban.api bans spy.usersSharingIp.map(_.id)) map { bans =>
|
||||
html.user.mod(user, email, spy, playerAggregateAssessment, bans, history, neuralResult)
|
||||
html.user.mod(user, email, spy, playerAggregateAssessment, bans, history)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(u: User, email: Option[String], spy: lila.security.UserSpy, optionAggregateAssessment: Option[lila.evaluation.PlayerAggregateAssessment.WithGames], bans: Map[String, Int], history: List[lila.mod.Modlog], neural: Option[lila.mod.NeuralApi.Result])(implicit ctx: Context)
|
||||
@(u: User, email: Option[String], spy: lila.security.UserSpy, optionAggregateAssessment: Option[lila.evaluation.PlayerAggregateAssessment.WithGames], bans: Map[String, Int], history: List[lila.mod.Modlog])(implicit ctx: Context)
|
||||
|
||||
@import lila.evaluation.Display
|
||||
|
||||
|
@ -226,13 +226,6 @@
|
|||
</table>
|
||||
</div>
|
||||
}
|
||||
@neural.map { n =>
|
||||
<div class="neural">
|
||||
[beta] Neural decision: <strong>@n.answer.decision</strong>.
|
||||
Cheating odds: @n.answer.cheatPercent% vs @n.answer.nonCheatPercent%.
|
||||
Took @n.millis ms.
|
||||
</div>
|
||||
}
|
||||
@if(isGranted(_.Admin) && u.roles.nonEmpty) {
|
||||
<div class="mod_roles">
|
||||
Mod permissions: @u.roles.mkString(", ")
|
||||
|
|
|
@ -292,11 +292,6 @@ mod {
|
|||
boosting.nb_games_to_mark = 5
|
||||
boosting.ratio_games_to_mark = 0.01
|
||||
actor.name = mod
|
||||
neural {
|
||||
api {
|
||||
endpoint = "http://104.155.38.137/NeuralCheatDetector.py"
|
||||
}
|
||||
}
|
||||
}
|
||||
report {
|
||||
collection.report = report
|
||||
|
|
|
@ -26,7 +26,6 @@ final class Env(
|
|||
val ActorName = config getString "actor.name"
|
||||
val NbGamesToMark = config getInt "boosting.nb_games_to_mark"
|
||||
val RatioGamesToMark = config getDouble "boosting.ratio_games_to_mark"
|
||||
val NeuralApiEndpoint = config getString "neural.api.endpoint"
|
||||
}
|
||||
import settings._
|
||||
|
||||
|
@ -65,12 +64,6 @@ final class Env(
|
|||
securityApi = securityApi,
|
||||
emailAddress = emailAddress)
|
||||
|
||||
private val neuralApi = new NeuralApi(
|
||||
endpoint = NeuralApiEndpoint,
|
||||
assessApi = assessApi)
|
||||
|
||||
def callNeural = neuralApi.apply _
|
||||
|
||||
// api actor
|
||||
private val actorApi = system.actorOf(Props(new Actor {
|
||||
def receive = {
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package lila.mod
|
||||
|
||||
import lila.common.Chronometer
|
||||
import lila.evaluation.PlayerAssessment
|
||||
import lila.user.User
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.ws.WS
|
||||
import play.api.Play.current
|
||||
|
||||
private final class NeuralApi(
|
||||
endpoint: String,
|
||||
assessApi: AssessApi) {
|
||||
|
||||
import NeuralApi._
|
||||
|
||||
def apply(user: User): Fu[Option[Result]] =
|
||||
assessApi.getPlayerAssessmentsByUserId(user.id, 200) flatMap {
|
||||
case pas if pas.size < 1 => fuccess(none)
|
||||
case pas => Chronometer.result {
|
||||
callEndpoint(toJson(pas))
|
||||
} map (_.tuple) map (Result.apply _).tupled map some
|
||||
} recover {
|
||||
case e: Exception =>
|
||||
play.api.Logger("neural").warn(e.toString)
|
||||
none
|
||||
}
|
||||
|
||||
private def toJson(pas: List[PlayerAssessment]) = JsArray {
|
||||
def bool2int(b: Boolean) = b.fold(1, 0)
|
||||
pas map { pa =>
|
||||
Json.obj(
|
||||
"ser" -> pa.flags.suspiciousErrorRate.|>(bool2int),
|
||||
"aha" -> pa.flags.alwaysHasAdvantage.|>(bool2int),
|
||||
"cmt" -> pa.flags.consistentMoveTimes.|>(bool2int),
|
||||
"nfm" -> pa.flags.noFastMoves.|>(bool2int),
|
||||
"sha" -> pa.flags.suspiciousHoldAlert.|>(bool2int),
|
||||
"sfAvg" -> pa.sfAvg,
|
||||
"sfSd" -> pa.sfSd,
|
||||
"mtAvg" -> pa.mtAvg,
|
||||
"mtSd" -> pa.mtSd,
|
||||
"blurs" -> pa.blurs
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private implicit val answerReads = Json.reads[Answer]
|
||||
|
||||
private def callEndpoint(input: JsValue): Fu[Answer] = WS.url(endpoint).post(Map(
|
||||
"input" -> Seq(Json stringify input)
|
||||
)) flatMap {
|
||||
case res if res.status == 200 => res.json.validate[Answer].fold(
|
||||
err => fufail(s"[neural] Can't parse answer ${res.body} $err"),
|
||||
fuccess _)
|
||||
case res => fufail(s"[neural] ${res.status} ${res.body}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
object NeuralApi {
|
||||
|
||||
case class Answer(decision: String, cheatPercent: Int, nonCheatPercent: Int)
|
||||
case class Result(answer: Answer, millis: Int)
|
||||
}
|
Loading…
Reference in a new issue