Skip to content

Commit

Permalink
still modfiying
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscojavierarceo committed May 10, 2024
1 parent 064dce0 commit 031967c
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 413 deletions.
4 changes: 3 additions & 1 deletion module_4_rag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ Then run
```bash
python batch_score_documents.py
```
Which will output data to `city_wikipedia_summaries_with_embeddings.parquet`
Which will output data to `data/city_wikipedia_summaries_with_embeddings.parquet`

Next we'll need to do some Feast work and move the data into a repo created by
Feast.
## Feast

To get started, make sure to have Feast installed and PostGreSQL.
Expand Down
74 changes: 12 additions & 62 deletions module_4_rag/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,13 @@
)
from flasgger import Swagger
from datetime import datetime
from get_features import (
get_onboarding_features,
get_onboarding_score,
get_daily_features,
get_daily_score,
)
from ml import make_risk_decision

app = Flask(__name__)
swagger = Swagger(app)


@app.route("/")
def onboarding_page():
return render_template("index.html")


@app.route("/home")
def home_page():
return render_template("home.html")


@app.route("/onboarding-risk-features/", methods=["POST"])
def onboarding_features():
@app.route("/get_documents")
def get_documents():
"""Example endpoint returning features by id
This is using docstrings for specifications.
---
Expand All @@ -39,60 +22,27 @@ def onboarding_features():
in: query
required: true
default: NJ
- name: ssn
type: string
in: query
required: true
default: 123-45-6789
- name: dl
type: string
in: query
required: true
default: some-dl-number
- name: dob
type: string
in: query
required: true
default: 12-23-2000
responses:
200:
description: A JSON of features
description: A JSON of documents
schema:
id: OnboardingFeatures
id: Document ID
properties:
is_gt_18_years_old:
type: array
items:
schema:
id: value
type: number
is_valid_state:
type: array
items:
schema:
id: value
type: number
is_previously_seen_ssn:
type: array
items:
schema:
id: value
type: number
is_previously_seen_dl:
type: array
items:
schema:
id: value
type: number
"""
r = request.args
feature_vector = get_onboarding_features(
r.get("state"), r.get("ssn"), r.get("dl"), r.get("dob")
)
return jsonify(feature_vector)
question = request.form["question"]
documents = store.get_online_documents(query)
return render_template("documents.html", documents=documents)


@app.route("/")
def home():
return render_template("home.html")


if __name__ == "__main__":
Expand Down
256 changes: 256 additions & 0 deletions module_4_rag/feature_repo/data/city_wikipedia_summaries.csv

Large diffs are not rendered by default.

Binary file not shown.
2 changes: 1 addition & 1 deletion module_4_rag/feature_repo/feature_store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ online_store:
host: 127.0.0.1
port: 5432
database: feast
user: ""
user: "demo_user"
password: ""


Expand Down
2 changes: 1 addition & 1 deletion module_4_rag/feature_repo/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from entities import item


parquet_file_path = "../data/city_wikipedia_summaries_with_embeddings.parquet"
parquet_file_path = "./data/city_wikipedia_summaries_with_embeddings.parquet"

source = FileSource(
file_format=ParquetFormat(),
Expand Down
Loading

0 comments on commit 031967c

Please sign in to comment.