Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove Perspective references (#15)

* Remove Perspective references

* adjust healthcheck start and retries to be faster check on healthiness while still allowing up to 2 minutes of retries for worst case

authored by

Juan Mrad and committed by
GitHub
c6fac175 2ba1fe8a

+20 -121
-18
.devops/aws/src/stacks/api-service/api.ts
··· 88 88 // the arns of all secrets that should be exposed to the api pods. 89 89 secrets: SecretsMap< 90 90 | 'SESSION_SECRET' 91 - | 'PERSPECTIVE_API_KEY' 92 91 | 'GROQ_SECRET_KEY' 93 92 | 'SENDGRID_API_KEY' 94 93 | 'GOOGLE_PLACES_API_KEY' ··· 299 298 // TODO: this if condition is very hacky, but we need to set different metrics 300 299 // per env before we can do this properly. 301 300 if (stage === 'Prod') { 302 - // If we had more than 30 rate limit errors 303 - // in two out of three of the last 1 minute periods, alarm. 304 - withSnsNotifications( 305 - new Metric({ 306 - namespace: 'coop-signals', 307 - metricName: 'Perspective Rate Limit Error', 308 - statistic: 'sum', 309 - period: Duration.minutes(1), 310 - }).createAlarm(this, 'PerspectiveRateLimitErrorAlarm', { 311 - alarmName: 'Recurring Perspective Rate Limit Errors', 312 - threshold: 30, 313 - evaluationPeriods: 3, 314 - datapointsToAlarm: 2, 315 - }), 316 - monitoringAlertsTopic, 317 - ); 318 - 319 301 gateway.restApi.methods.forEach((method) => { 320 302 // Similarly, alert if 500s are too high. 321 303 withSnsNotifications(
-2
.devops/aws/src/stacks/api-service/jobs_workers.ts
··· 54 54 | 'KAFKA_SNOWFLAKE_INGEST_SERVICE_ACCOUNT_PASSWORD' 55 55 | 'KAFKA_API_SERVICE_ACCOUNT_USERNAME' 56 56 | 'KAFKA_API_SERVICE_ACCOUNT_PASSWORD' 57 - | 'PERSPECTIVE_API_KEY' 58 57 >; 59 58 stage: DeploymentEnvironmentName; 60 59 provisionProdLevelsOfCompute: boolean; ··· 230 229 ...pgEnvVars, 231 230 ...redisEnvVars, 232 231 'OPEN_AI_API_KEY', 233 - 'PERSPECTIVE_API_KEY', 234 232 ]), 235 233 KAFKA_BROKER_USERNAME: secrets.KAFKA_API_SERVICE_ACCOUNT_USERNAME, 236 234 KAFKA_BROKER_PASSWORD: secrets.KAFKA_API_SERVICE_ACCOUNT_PASSWORD,
-3
.devops/aws/src/stacks/app_pipeline.ts
··· 242 242 const { arns, globalArns } = props; 243 243 const secrets = { 244 244 SESSION_SECRET: [arns.sessionSecret], 245 - PERSPECTIVE_API_KEY: [ 246 - 'arn:aws:secretsmanager:us-east-2:361188080279:secret:prod/Api/PerspectiveApiKey-R5YxuN', 247 - ], 248 245 GROQ_SECRET_KEY: [ 249 246 'arn:aws:secretsmanager:us-east-2:361188080279:secret:prod/Api/GroqSecretKey-CucLyH', 250 247 ],
-1
.env.githubci
··· 65 65 SEQUELIZE_PRINT_LOGS=true 66 66 SNOWFLAKE_PRINT_LOGS=true 67 67 68 - PERSPECTIVE_API_KEY= 69 68 GROQ_SECRET_KEY= 70 69 71 70 # Other API Keys
+15 -5
docker-compose.yaml
··· 9 9 # Runs all migrations from scratch, after clearing the database(s). 10 10 migrations: 11 11 image: node:20 12 - command: bash -c 'npm i && ( [ "$CI" = "true" ] && npm run db:clean -- --env staging || true ) 13 - && for db in api-server-pg scylla clickhouse; do npm run db:update -- --db "$$db" --env staging; done' 12 + command: bash -c 'set -e 13 + npm i && ( [ "$CI" = "true" ] && npm run db:clean -- --env staging || true ) 14 + && for db in api-server-pg scylla clickhouse; do npm run db:create -- --db "$$db" --env staging; npm run db:update -- --db "$$db" --env staging; done' 14 15 working_dir: /src 15 16 env_file: ./.env.githubci 16 17 environment: ··· 30 31 volumes: 31 32 - .:/src 32 33 depends_on: 33 - - postgres 34 - - scylla 35 - - clickhouse 34 + postgres: 35 + condition: service_healthy 36 + scylla: 37 + condition: service_healthy 38 + clickhouse: 39 + condition: service_healthy 36 40 37 41 drop_dbs: 38 42 image: node:20 ··· 93 97 - scylla_data:/var/lib/scylla 94 98 ports: 95 99 - '9042:9042' 100 + healthcheck: 101 + test: ['CMD-SHELL', 'nodetool status || exit 1'] 102 + interval: 5s 103 + timeout: 5s 104 + retries: 28 105 + start_period: 35s 96 106 97 107 zookeeper: 98 108 image: zookeeper:3.7.0
-2
server/decs.d.ts
··· 1 - declare module 'perspective-api-client'; 2 1 declare module 'homoglyph-search'; 3 2 declare module 'nilsimsa'; 4 3 ··· 275 274 REDIS_PORT?: string; 276 275 REDIS_USER?: string; 277 276 REDIS_PASSWORD?: string; 278 - PERSPECTIVE_API_KEY?: string; 279 277 GROQ_SECRET_KEY?: string; 280 278 SENDGRID_API_KEY?: string; 281 279 GOOGLE_PLACES_API_KEY?: string;
+5 -5
server/services/ruleHistoryService/ruleHistoryService.test.ts
··· 69 69 const mockGetRawHistory = async () => [ 70 70 { 71 71 id: '4fb36ec8fb0', 72 - name: 'Perspective Threat (WIP)', 72 + name: 'Toxicity Rule (WIP)', 73 73 statusIfUnexpired: RuleStatus.LIVE, 74 74 exactVersion: '2022-05-04 19:00:59.556331+00', 75 75 }, 76 76 { 77 77 id: '4fb36ec8fb0', 78 - name: 'Perspective Threat', 78 + name: 'Toxicity Rule', 79 79 statusIfUnexpired: RuleStatus.LIVE, 80 80 exactVersion: '2022-05-11 19:00:59.556331+00', 81 81 }, 82 82 { 83 83 id: '4fb36ec8fb0', 84 - name: 'Perspective Threat', 84 + name: 'Toxicity Rule', 85 85 statusIfUnexpired: RuleStatus.BACKGROUND, 86 86 exactVersion: '2022-05-19 23:39:21.261444+00', 87 87 }, ··· 97 97 expect(res).toEqual([ 98 98 { 99 99 id: '4fb36ec8fb0', 100 - name: 'Perspective Threat', 100 + name: 'Toxicity Rule', 101 101 statusIfUnexpired: 'LIVE', 102 102 exactVersion: '2022-05-11 19:00:59.556331+00', 103 103 approxVersion: new Date('2022-05-11T19:00:59.556Z'), 104 104 }, 105 105 { 106 106 id: '4fb36ec8fb0', 107 - name: 'Perspective Threat', 107 + name: 'Toxicity Rule', 108 108 statusIfUnexpired: 'BACKGROUND', 109 109 exactVersion: '2022-05-19 23:39:21.261444+00', 110 110 approxVersion: new Date('2022-05-19T23:39:21.261Z'),
-85
server/services/signalsService/signals/CoopRiskModelSignal.ts
··· 1 1 import { ScalarTypes } from '@roostorg/types'; 2 2 3 - // import { filterNullOrUndefined } from '../../../utils/collections.js'; 4 - // import { 5 - // isCoopErrorOfType, 6 - // makeSignalPermanentError, 7 - // } from '../../../utils/errors.js'; 8 3 import { Language } from '../../../utils/language.js'; 9 4 import { SignalPricingStructure as SignalPricingStructureType } from '../types/SignalPricingStructure.js'; 10 5 import { SignalType } from '../types/SignalType.js'; ··· 13 8 type SignalInput, 14 9 } from './SignalBase.js'; 15 10 16 - // const riskModelAttributes = ['IDENTITY_ATTACK', 'INSULT', 'THREAT'] as const; 17 - 18 - // const RISK_MODEL_ORDERED_OUTPUTS = [ 19 - // 'Very High', 20 - // 'High', 21 - // 'Medium', 22 - // 'Low', 23 - // 'Very Low', 24 - // 'Extremely Low', 25 - // ]; 26 - 27 11 export default class CoopRiskModelSignal extends SignalBase< 28 12 ScalarTypes['STRING'], 29 13 { scalarType: ScalarTypes['NUMBER'] } 30 - // { scalarType: ScalarTypes['STRING']; enum: string[]; ordered: true } 31 14 > { 32 15 get docsUrl() { 33 16 return null; ··· 43 26 44 27 get recommendedThresholds() { 45 28 return { 46 - // highPrecisionThreshold: 'Very High', 47 - // highRecallThreshold: 'Medium', 48 29 highPrecisionThreshold: '0.95', 49 30 highRecallThreshold: '0.8', 50 31 }; ··· 65 46 override get outputType() { 66 47 return { 67 48 scalarType: ScalarTypes.NUMBER, 68 - // enum: RISK_MODEL_ORDERED_OUTPUTS, 69 - // ordered: true as const, 70 49 }; 71 50 } 72 51 ··· 124 103 score: 0.5, 125 104 outputType: { scalarType: ScalarTypes.NUMBER }, 126 105 }; 127 - // const { value } = input; 128 - // const outputType = { 129 - // scalarType: ScalarTypes.STRING, 130 - // enum: RISK_MODEL_ORDERED_OUTPUTS, 131 - // ordered: true as const, 132 - // }; 133 - // try { 134 - // // Perspective throws an error when given an empty string input, so 135 - // // we just return the max score of 5 immediately 136 - // if (value.value.length === 0) { 137 - // return { 138 - // score: 'Very Low', 139 - // outputType, 140 - // }; 141 - // } 142 - 143 - // const result = await this.getPerspectiveScores( 144 - // process.env.PERSPECTIVE_API_KEY!, 145 - // value.value, 146 - // ); 147 - 148 - // if (result.type === 'UNSUPPORTED_LANGUAGE') { 149 - // throw makeSignalPermanentError( 150 - // `Unable to evaluate content: ${value.value}`, 151 - // ); 152 - // } 153 - 154 - // const attributeScores = filterNullOrUndefined( 155 - // riskModelAttributes.map((attribute) => 156 - // result.attributeMap.get(attribute), 157 - // ), 158 - // ); 159 - 160 - // if (attributeScores.length === 0) { 161 - // throw makeSignalPermanentError( 162 - // `Undefined scores for content: ${value.value}`, 163 - // ); 164 - // } 165 - 166 - // const maxScore = Math.max(...attributeScores); 167 - // const finalScore = 168 - // maxScore > 0.8 169 - // ? 'Very High' 170 - // : maxScore > 0.6 171 - // ? 'High' 172 - // : maxScore > 0.3 173 - // ? 'Medium' 174 - // : maxScore > 0.1 175 - // ? 'Low' 176 - // : maxScore > 0.036 177 - // ? 'Very Low' 178 - // : 'Extremely Low'; 179 - 180 - // return { 181 - // score: finalScore, 182 - // outputType, 183 - // }; 184 - // } catch (e) { 185 - // if (isCoopErrorOfType(e, 'SignalPermanentError')) { 186 - // return { score: e, type: 'ERROR' as const }; 187 - // } 188 - 189 - // throw e; 190 - // } 191 106 } 192 107 }