Skip to content

Commit 022beeb

Browse files
authored
Merge pull request #166 from codeforpdx/apkostka/gemini-refactor
Switch OpenAI -> Gemini
2 parents 471f07c + cfd2b12 commit 022beeb

File tree

24 files changed

+828
-367
lines changed

24 files changed

+828
-367
lines changed

.github/workflows/deploy.production.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: appleboy/scp-action@v0.1.7
3636
with:
3737
host: ${{ vars.URL }}
38-
username: ${{ secrets.SSH_USER }}
38+
username: ${{ vars.SSH_USER }}
3939
key: ${{ secrets.SSH_KEY }}
4040
source: ${{ vars.BACKEND_DIR }}/
4141
target: ${{ vars.REMOTE_APP_DIR }}
@@ -45,7 +45,7 @@ jobs:
4545
uses: appleboy/scp-action@v0.1.7
4646
with:
4747
host: ${{ vars.URL }}
48-
username: ${{ secrets.SSH_USER }}
48+
username: ${{ vars.SSH_USER }}
4949
key: ${{ secrets.SSH_KEY }}
5050
source: ${{ vars.FRONTEND_DIR }}/dist
5151
target: ${{ vars.REMOTE_APP_DIR }}
@@ -55,7 +55,7 @@ jobs:
5555
uses: appleboy/ssh-action@v0.1.7
5656
with:
5757
host: ${{ vars.URL }}
58-
username: ${{ secrets.SSH_USER }}
58+
username: ${{ vars.SSH_USER }}
5959
key: ${{ secrets.SSH_KEY }}
6060
script: |
6161
set -e
@@ -76,16 +76,20 @@ jobs:
7676
sudo chown root:root /etc/tenantfirstaid
7777
cat > /etc/tenantfirstaid/env <<EOF
7878
ENV=${{ vars.ENV }}
79-
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
8079
FLASK_SECRET_KEY=${{ secrets.FLASK_SECRET_KEY }}
8180
DB_HOST=${{secrets.DB_HOST}}
8281
DB_PASSWORD=${{secrets.DB_PASSWORD}}
8382
DB_PORT=${{vars.DB_PORT}}
8483
DB_USER=default
85-
MODEL_REASONING_EFFORT=high
86-
VECTOR_STORE_ID=${{secrets.VECTOR_STORE_ID}}
84+
GEMINI_RAG_CORPUS=${{vars.GEMINI_RAG_CORPUS}}
85+
GOOGLE_SERVICE_ACCOUNT_CREDENTIALS_FILE=/etc/tenantfirstaid/google-service-account.json
8786
EOF
8887
chmod 640 /etc/tenantfirstaid/env
88+
89+
cat > /etc/tenantfirstaid/google-service-account.json <<EOF
90+
${{ secrets.GOOGLE_SERVICE_ACCOUNT_CREDENTIALS}}
91+
EOF
92+
chmod 640 /etc/tenantfirstaid/google-service-account.json
8993
9094
# Ownership, restart, reload
9195
sudo chown -R $USER:www-data ${{ vars.REMOTE_APP_DIR }}

.github/workflows/deploy.staging.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,20 @@ jobs:
7474
sudo chown root:root /etc/tenantfirstaid
7575
cat > /etc/tenantfirstaid/env <<EOF
7676
ENV=${{ vars.ENV }}
77-
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
7877
FLASK_SECRET_KEY=${{ secrets.FLASK_SECRET_KEY }}
7978
DB_HOST=${{secrets.DB_HOST}}
8079
DB_PASSWORD=${{secrets.DB_PASSWORD}}
8180
DB_PORT=${{vars.DB_PORT}}
8281
DB_USER=default
83-
MODEL_REASONING_EFFORT=high
84-
VECTOR_STORE_ID=${{secrets.VECTOR_STORE_ID}}
82+
GEMINI_RAG_CORPUS=${{vars.GEMINI_RAG_CORPUS}}
83+
GOOGLE_SERVICE_ACCOUNT_CREDENTIALS_FILE=/etc/tenantfirstaid/google-service-account.json
8584
EOF
8685
chmod 640 /etc/tenantfirstaid/env
86+
87+
cat > /etc/tenantfirstaid/google-service-account.json <<EOF
88+
${{ secrets.GOOGLE_SERVICE_ACCOUNT_CREDENTIALS}}
89+
EOF
90+
chmod 640 /etc/tenantfirstaid/google-service-account.json
8791
8892
# Ownership, restart, reload
8993
sudo chown -R $USER:www-data ${{ vars.REMOTE_APP_DIR }}

.github/workflows/generate_conversations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ on:
2525
model:
2626
description: 'Model to use'
2727
required: true
28-
default: 'o3'
28+
default: 'gpt-2.5-flash'
2929
type: string
3030

3131
jobs:

.github/workflows/pr-check.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ jobs:
4343
run: uv run ty check
4444

4545
- name: Run tests
46-
env:
47-
OPENAI_API_KEY: XXXX
48-
PERSISTENT_STORAGE_DIR: /tmp/tenantfirstaid_data
4946
run: uv run pytest -v -s
5047

5148
frontend-build:

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ venv/
1313
# Env config
1414
.env
1515
*.env
16+
google-service-account.json
17+
.python-version
1618

1719
# Python tooling
1820
pip-log.txt
@@ -57,5 +59,6 @@ chatlog.jsonl
5759
/backend/feedback.jsonl
5860
/backend/data
5961
/backend/scripts/eval_results.json
60-
combined_training_gpt-4_1.jsonl
61-
combined_training_o3.jsonl
62+
/backend/scripts/generate_conversation/*.csv
63+
!/backend/scripts/generate_conversation/tenant_questions_facts_full.csv
64+
combined_training_gpt-4_1.jsonl

backend/.env.example

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
OPENAI_API_KEY=openai_api_key
2-
# If you want to use Github Models instead, omit OPENAI_API_KEY and use
3-
# GITHUB_API_KEY and MODEL_ENDPOINT
4-
GITHUB_API_KEY=github_api_key
5-
MODEL_ENDPOINT=https://api.openai.com/v1
6-
71
# Specify a different model
8-
MODEL_NAME=o3
9-
10-
# Change the persistent storage directory from '/root/tenantfirstaid'
11-
PERSISTENT_STORAGE_DIR=../storage
2+
MODEL_NAME=gpt-2.5-flash
123

134
# Vector store ID for OpenAI (use the create_vector_store script to create one)
145
VECTOR_STORE_ID=my_vector_store_id

backend/pyproject.toml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ dependencies = [
66
"flask",
77
"valkey",
88
"gunicorn",
9+
"google-auth",
10+
"google-genai",
11+
"google-cloud-aiplatform",
912
"openai==1.89",
1013
"jsonlines",
1114
"simplejson",
1215
"python-dotenv",
1316
"pandas>=2.3.0",
17+
"vertexai",
1418
]
1519

1620
[tool.setuptools.packages.find]
@@ -23,20 +27,16 @@ build-backend = "setuptools.build_meta"
2327

2428
[dependency-groups]
2529
dev = [
26-
"ipdb>=0.13.13",
27-
"mypy>=1.16.1",
28-
"pyrefly>=0.21.0",
29-
"pytest>=8.4.0",
30-
"pytest-cov>=6.1.1",
31-
"pytest-mock>=3.14.1",
32-
"ruff>=0.12.0",
33-
"ty>=0.0.1a11",
34-
"types-Flask>=1.1.6",
35-
"types-simplejson>=3.20.0.20250326",
36-
]
37-
38-
gen_convo = [
39-
"pandas",
40-
"openai",
30+
"ipdb>=0.13.13",
31+
"mypy>=1.16.1",
32+
"pyrefly>=0.21.0",
33+
"pytest>=8.4.0",
34+
"pytest-cov>=6.1.1",
35+
"pytest-mock>=3.14.1",
36+
"ruff>=0.12.0",
37+
"ty>=0.0.1a11",
38+
"types-Flask>=1.1.6",
39+
"types-simplejson>=3.20.0.20250326",
4140
]
4241

42+
gen_convo = ["pandas", "openai"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ORS 109.697
2+
The Legislative Assembly finds that there are in the State of Oregon unemancipated minors who are living apart from their parents and are homeless. Many of these minors are able financially to provide housing and utility services for themselves and their children, but cannot contract for these necessities due to perceived legal limitations affecting contracts with minors. The purpose of this legislation is to address those limitations.
3+
(2)For purposes of this section, “minor” means an unemancipated and unmarried person who is living apart from the person’s parent, parents or legal guardian, and who is either:
4+
(a)Sixteen or 17 years of age;
5+
(b)Under 16 years of age and the parent of a child or children who are living in the physical custody of the person; or
6+
(c)Under 16 years of age, pregnant and expecting the birth of a child who will be living in the physical custody of the person.
7+
Notwithstanding any other provision of law, a minor may contract for the necessities of a residential dwelling unit and for utility services to that unit. Such a contract is binding upon the minor and cannot be voided or disaffirmed by the minor based upon the minor’s age or status as a minor.
8+
(4)The consent of the parent or legal guardian of such minor shall not be necessary to contract for a residential dwelling unit or utility services to that unit. The parent or legal guardian of such minor shall not be liable under a contract by that minor for a residential dwelling unit or for utility services to that unit unless the parent or guardian is a party to the minor’s contract, or enters another contract, for the purpose of acting as guarantor of the minor’s debt. [1993 c.369 §29]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
ORS 659A.421
2+
Discrimination in selling, renting or leasing real property prohibited
3+
Text
4+
Annotations 6
5+
(1)As used in this section:
6+
(a)“Dwelling” means:
7+
(A)A building or structure, or portion of a building or structure, that is occupied, or designed or intended for occupancy, as a residence by one or more families; or
8+
(B)Vacant land offered for sale or lease for the construction or location of a building or structure, or portion of a building or structure, that is occupied, or designed or intended for occupancy, as a residence by one or more families.
9+
(b)“Purchaser” includes an occupant, prospective occupant, renter, prospective renter, lessee, prospective lessee, buyer or prospective buyer.
10+
(c)“Real property” includes a dwelling.
11+
(d)Intentionally left blank —Ed.
12+
(A)“Source of income” includes federal rent subsidy payments under 42 U.S.C. 1437f and any other local, state or federal housing assistance.
13+
(B)“Source of income” does not include income derived from a specific occupation or income derived in an illegal manner.
14+
(2)A person may not, because of the race, color, religion, sex, sexual orientation, gender identity, national origin, marital status, familial status or source of income of any person:
15+
(a)Refuse to sell, lease or rent any real property to a purchaser. This paragraph does not prevent a person from refusing to lease or rent real property to a prospective renter or prospective lessee:
16+
(A)Based upon the past conduct of a prospective renter or prospective lessee provided the refusal to lease or rent based on past conduct is consistent with local, state and federal law, including but not limited to fair housing laws; or
17+
(B)Based upon the prospective renter’s or prospective lessee’s inability to pay rent, taking into account the value of the prospective renter’s or prospective lessee’s local, state and federal housing assistance, provided the refusal to lease or rent based on inability to pay rent is consistent with local, state and federal law, including but not limited to fair housing laws.
18+
(b)Expel a purchaser from any real property.
19+
(c)Make any distinction, discrimination or restriction against a purchaser in the price, terms, conditions or privileges relating to the sale, rental, lease or occupancy of real property or in the furnishing of any facilities or services in connection therewith.
20+
(d)Attempt to discourage the sale, rental or lease of any real property to a purchaser.
21+
(e)Publish, circulate, issue or display, or cause to be published, circulated, issued or displayed, any communication, notice, advertisement or sign of any kind relating to the sale, rental or leasing of real property that indicates any preference, limitation, specification or unlawful discrimination based on race, color, religion, sex, sexual orientation, gender identity, national origin, marital status, familial status or source of income.
22+
(f)Assist, induce, incite or coerce another person to commit an act or engage in a practice that violates this section.
23+
(g)Coerce, intimidate, threaten or interfere with any person in the exercise or enjoyment of, or on account of the person having exercised or enjoyed or having aided or encouraged any other person in the exercise or enjoyment of, any right granted or protected by this section.
24+
(h)Deny access to, or membership or participation in, any multiple listing service, real estate brokers’ organization or other service, organization or facility relating to the business of selling or renting dwellings, or discriminate against any person in the terms or conditions of the access, membership or participation.
25+
(i)Represent to a person that a dwelling is not available for inspection, sale or rental when the dwelling in fact is available for inspection, sale or rental.
26+
(j)Otherwise make unavailable or deny a dwelling to a person.
27+
(3)Intentionally left blank —Ed.
28+
(a)A person whose business includes engaging in residential real estate related transactions may not discriminate against any person in making a transaction available, or in the terms or conditions of the transaction, because of race, color, religion, sex, sexual orientation, gender identity, national origin, marital status, familial status or source of income.
29+
(b)As used in this subsection, “residential real estate related transaction” means any of the following:
30+
(A)The making or purchasing of loans or providing other financial assistance:
31+
(i)For purchasing, constructing, improving, repairing or maintaining a dwelling; or
32+
(ii)Secured by residential real estate; or
33+
(B)The selling, brokering or appraising of residential real property.
34+
(4)A real estate licensee may not accept or retain a listing of real property for sale, lease or rental with an understanding that a purchaser may be discriminated against with respect to the sale, rental or lease thereof because of race, color, religion, sex, sexual orientation, gender identity, national origin, marital status, familial status or source of income.
35+
(5)A person may not, for profit, induce or attempt to induce any other person to sell or rent any dwelling by representations regarding the entry or prospective entry into the neighborhood of a person or persons of a particular race, color, religion, sex, sexual orientation, gender identity, national origin, marital status, familial status or source of income.
36+
(6)This section does not apply with respect to sex distinction, discrimination or restriction if the real property involved is such that the application of this section would necessarily result in common use of bath or bedroom facilities by unrelated persons of opposite sex.
37+
(7)Intentionally left blank —Ed.
38+
(a)This section does not apply to familial status distinction, discrimination or restriction with respect to housing for older persons.
39+
(b)As used in this subsection, “housing for older persons” means housing:
40+
(A)Provided under any state or federal program that is specifically designed and operated to assist elderly persons, as defined by the state or federal program;
41+
(B)Intended for, and solely occupied by, persons 62 years of age or older; or
42+
(C)Intended and operated for occupancy by at least one person 55 years of age or older per unit. Housing qualifies as housing for older persons under this subparagraph if:
43+
(i)At least 80 percent of the dwellings are occupied by at least one person 55 years of age or older per unit; and
44+
(ii)Policies and procedures that demonstrate an intent by the owner or manager to provide housing for persons 55 years of age or older are published and adhered to.
45+
(c)Housing does not fail to meet the requirements for housing for older persons if:
46+
(A)Persons residing in the housing as of September 13, 1988, do not meet the requirements of paragraph (b)(B) or (C) of this subsection. However, new occupants of the housing shall meet the age requirements of paragraph (b)(B) or (C) of this subsection; or
47+
(B)The housing includes unoccupied units that are reserved for occupancy by persons who meet the age requirements of paragraph (b)(B) or (C) of this subsection.
48+
(d)Nothing in this section limits the applicability of any reasonable local, state or federal restrictions regarding the maximum number of occupants permitted to occupy a dwelling.
49+
(8)The provisions of subsection (2)(a) to (d) and (f) of this section that prohibit actions based upon sex, sexual orientation, gender identity or familial status do not apply to the renting of space within a single-family residence if the owner actually maintains and occupies the residence as the owner’s primary residence and all occupants share some common space within the residence.
50+
(9)Any violation of this section is an unlawful practice. [Formerly 659.033; 2007 c.100 §8; 2007 c.903 §4a; 2008 c.36 §6; 2013 c.740 §1; 2021 c.367 §40]

backend/scripts/documents/or/eugene/EHC8.425.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
These laws are only applicable to users in Eugene, Oregon.
2+
13
8.425 Rental Housing – Standards and Protections.
24
(1) Structural Integrity. Roofs, floors, walls, foundations and all other structural components shall be capable of resisting loads prescribed by the building code in effect at the time of construction.
35
(2) Plumbing.

0 commit comments

Comments
 (0)