Spaces:
Runtime error
Runtime error
File size: 3,998 Bytes
78c89b2 | 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | ### Credily API - Make Predictions from External Data Sources
### Use with VS Code REST Client, Insomnia, or Postman
@baseUrl = http://localhost:8000
@model_path = C:/credily/models/credit_model.pkl
###############################################################################
### 1. PREDICT FROM PostgreSQL DATABASE
###############################################################################
POST {{baseUrl}}/api/predict-from-source
Content-Type: application/json
{
"data_source": {
"source_type": "database",
"database_type": "postgres",
"connection_string": "postgresql://user:password@localhost:5432/credit_db",
"query": "SELECT age, income, credit_score, loan_amount, debt_to_income FROM new_loan_applications WHERE processed = false"
},
"model_path": "{{model_path}}",
"include_proba": true,
"save_results": true
}
###############################################################################
### 2. PREDICT FROM REST API
###############################################################################
POST {{baseUrl}}/api/predict-from-source
Content-Type: application/json
{
"data_source": {
"source_type": "api",
"url": "https://api.example.com/v1/pending-applications",
"method": "GET",
"headers": {
"Accept": "application/json"
},
"auth": {
"type": "bearer",
"token": "your-api-token"
},
"json_path": "data.applications"
},
"model_path": "{{model_path}}",
"threshold": 0.45,
"include_proba": true,
"save_results": true
}
###############################################################################
### 3. PREDICT FROM GraphQL ENDPOINT
###############################################################################
POST {{baseUrl}}/api/predict-from-source
Content-Type: application/json
{
"data_source": {
"source_type": "graphql",
"url": "https://api.example.com/graphql",
"graphql_query": "query GetPendingApplications($status: String!) { loanApplications(status: $status) { id age income creditScore loanAmount } }",
"graphql_variables": {
"status": "pending_review"
},
"headers": {
"Authorization": "Bearer your-token"
},
"json_path": "data.loanApplications"
},
"model_path": "{{model_path}}",
"include_proba": true
}
###############################################################################
### 4. PREDICT FROM MongoDB
###############################################################################
POST {{baseUrl}}/api/predict-from-source
Content-Type: application/json
{
"data_source": {
"source_type": "database",
"database_type": "mongodb",
"connection_string": "mongodb://user:password@localhost:27017/",
"query": "{\"database\": \"credit_db\", \"collection\": \"pending_applications\", \"query\": {\"status\": \"pending\"}}"
},
"model_path": "{{model_path}}",
"save_results": true
}
###############################################################################
### 5. PREDICT FROM CSV FILE URL
###############################################################################
POST {{baseUrl}}/api/predict-from-source
Content-Type: application/json
{
"data_source": {
"source_type": "url",
"url": "https://storage.example.com/predictions/pending_loans.csv",
"format": "csv"
},
"model_path": "{{model_path}}",
"threshold": 0.5,
"include_proba": true,
"save_results": true
}
###############################################################################
### 6. PREDICT WITH CUSTOM THRESHOLD
###############################################################################
POST {{baseUrl}}/api/predict-from-source
Content-Type: application/json
{
"data_source": {
"source_type": "api",
"url": "https://api.example.com/v1/applications-to-score",
"auth": {
"type": "bearer",
"token": "token"
},
"json_path": "data"
},
"model_path": "{{model_path}}",
"threshold": 0.35,
"include_proba": true,
"save_results": true
}
|