Skip to content

Commit

Permalink
Prepared for sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtheman committed Sep 24, 2023
1 parent 9f288da commit 7a409da
Show file tree
Hide file tree
Showing 12 changed files with 637 additions and 846 deletions.
95 changes: 86 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,93 @@ documentation.

## Install

``` sh
pip install ai_estimator
```
\#AI Estimator

## How to use
This code is a proof of concept intended larger project that aims to
assist with property management tasks. It is designed to help with the
estimation of materials needed for a roofing job. It takes into account
various factors such as the size and shape of the roof, the type of
materials being used, and the specific requirements of the job.

Fill me in please! Don’t forget code examples:
## Calculations

``` python
1+1
```
The code uses the OpenAI API to interact with the user and perform tasks
based on the user’s input. It can create estimates for property
renovations or repairs, retrieve property owner details from the
database, retrieve property information from the database, retrieve
building structure information from the database, and retrieve materials
templates from the database.

2
The code is organized into several classes and functions, each with a
specific role. For example, the
[`SupportedTrade`](https://maxtheman.github.io/ai_estimator/core.html#supportedtrade)
and
[`RequiredRoofingMaterials`](https://maxtheman.github.io/ai_estimator/core.html#requiredroofingmaterials)
classes define the types of jobs and materials that the calculator can
handle. The
[`Material`](https://maxtheman.github.io/ai_estimator/core.html#material)
class represents a specific type of material, including its name, role,
how many units are in a package, the cost per unit, and a waste factor
to account for any material that might be wasted during the job.

The
[`RoofInputMeasurements`](https://maxtheman.github.io/ai_estimator/core.html#roofinputmeasurements)
class represents the measurements of the roof, including the length and
width of the area, the total length of the roof area, and specific
measurements for different parts of the roof like ridges, valleys,
rakes, etc. The
[`RoofingSettings`](https://maxtheman.github.io/ai_estimator/core.html#roofingsettings)
class represents the assumptions for a roofing calculator, like how many
shingles are needed per square foot of roof, how many nails are needed
per square foot, etc.

The
[`MaterialTemplate`](https://maxtheman.github.io/ai_estimator/core.html#materialtemplate)
class represents a template for a specific brand of materials, including
the name of the template, a list of materials, and the roofing settings.
The
[`LineItem`](https://maxtheman.github.io/ai_estimator/core.html#lineitem)
class represents a line item in the estimate, including the material
needed, the number of packages needed, and the cost per package. The
[`MaterialList`](https://maxtheman.github.io/ai_estimator/core.html#materiallist)
class represents a list of materials needed for a roofing job, including
the trade (roofing) and a list of line items.

Finally, the
[`RoofEstimate`](https://maxtheman.github.io/ai_estimator/core.html#roofestimate)
class is the main part of the calculator. It takes in the required roles
of materials, the measurements of the roof, and the material templates.
It then validates the templates, calculates the quantity and cost of
each material, and generates an estimate of the materials needed for the
job.

\##AI Usage

Uses Langchain’s `ChatOpenAI` Agent and tool decorators to provide the
above calculations to the Agent. Examples are provided showing how the
data is supposed to flow and a hardcoded example given a single full
property.

## How to to install

1. Clone this repo
2. Set `OPEN_API_KEY`
3. pip install requirements.txt
4. Then, open in VSCode with the Jupyter extension or start jupyter
from command line. Development was done with `nbdev`

How to use:

First,

Run this in the terminal to run on Modal: www.modal.com:

First, `modal token new` to set up your own modal account

`nbdev_export` to get the latest package exported from jupyter
`modal serve ai_estimator/server.py` to see the docal preview

`modal deploy` to set it to run on your account

See demo running at:
https://maxtheman–ai-estimator-run-server.modal.run/
2 changes: 1 addition & 1 deletion _proc/.quarto/idx/00_core.ipynb.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _proc/.quarto/xref/37d187bf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"headings":["install","how-to-use"],"entries":[]}
{"entries":[],"headings":["install","calculations","how-to-to-install"]}
921 changes: 260 additions & 661 deletions _proc/00_core.ipynb

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions _proc/01_server.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"---\n",
"\n",
"### Function(run_server)\n",
"\n",
"> Function(run_server) (*args, **kwargs)\n",
"\n",
"Functions are the basic units of serverless execution on Modal.\n",
"\n",
"Generally, you will not construct a `Function` directly. Instead, use the\n",
"`@stub.function()` decorator on the `Stub` object for your application."
],
"text/plain": [
"---\n",
"\n",
"### Function(run_server)\n",
"\n",
"> Function(run_server) (*args, **kwargs)\n",
"\n",
"Functions are the basic units of serverless execution on Modal.\n",
"\n",
"Generally, you will not construct a `Function` directly. Instead, use the\n",
"`@stub.function()` decorator on the `Stub` object for your application."
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#| echo: false\n",
"#| output: asis\n",
"show_doc(run_server)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
85 changes: 43 additions & 42 deletions _proc/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,72 +21,73 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"This file will become your README and also the index of your documentation."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Install"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"```sh\n",
"pip install ai_estimator\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to use"
"#AI Estimator\n",
"\n",
"This code is a proof of concept intended larger project that aims to assist with property management tasks. It is designed to help with the estimation of materials needed for a roofing job. It takes into account various factors such as the size and shape of the roof, the type of materials being used, and the specific requirements of the job.\n",
"\n",
"## Calculations\n",
"\n",
"The code uses the OpenAI API to interact with the user and perform tasks based on the user's input. It can create estimates for property renovations or repairs, retrieve property owner details from the database, retrieve property information from the database, retrieve building structure information from the database, and retrieve materials templates from the database.\n",
"\n",
"The code is organized into several classes and functions, each with a specific role. For example, the [`SupportedTrade`](https://maxtheman.github.io/ai_estimator/core.html#supportedtrade) and [`RequiredRoofingMaterials`](https://maxtheman.github.io/ai_estimator/core.html#requiredroofingmaterials) classes define the types of jobs and materials that the calculator can handle. The [`Material`](https://maxtheman.github.io/ai_estimator/core.html#material) class represents a specific type of material, including its name, role, how many units are in a package, the cost per unit, and a waste factor to account for any material that might be wasted during the job.\n",
"\n",
"The [`RoofInputMeasurements`](https://maxtheman.github.io/ai_estimator/core.html#roofinputmeasurements) class represents the measurements of the roof, including the length and width of the area, the total length of the roof area, and specific measurements for different parts of the roof like ridges, valleys, rakes, etc. The [`RoofingSettings`](https://maxtheman.github.io/ai_estimator/core.html#roofingsettings) class represents the assumptions for a roofing calculator, like how many shingles are needed per square foot of roof, how many nails are needed per square foot, etc.\n",
"\n",
"The [`MaterialTemplate`](https://maxtheman.github.io/ai_estimator/core.html#materialtemplate) class represents a template for a specific brand of materials, including the name of the template, a list of materials, and the roofing settings. The [`LineItem`](https://maxtheman.github.io/ai_estimator/core.html#lineitem) class represents a line item in the estimate, including the material needed, the number of packages needed, and the cost per package. The [`MaterialList`](https://maxtheman.github.io/ai_estimator/core.html#materiallist) class represents a list of materials needed for a roofing job, including the trade (roofing) and a list of line items.\n",
"\n",
"Finally, the [`RoofEstimate`](https://maxtheman.github.io/ai_estimator/core.html#roofestimate) class is the main part of the calculator. It takes in the required roles of materials, the measurements of the roof, and the material templates. It then validates the templates, calculates the quantity and cost of each material, and generates an estimate of the materials needed for the job.\n",
"\n",
"##AI Usage\n",
"\n",
"Uses Langchain's `ChatOpenAI` Agent and tool decorators to provide the above calculations to the Agent. Examples are provided showing how the data is supposed to flow and a hardcoded example given a single full property."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Fill me in please! Don't forget code examples:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1+1"
"## How to to install\n",
"1. Clone this repo\n",
"2. Set `OPEN_API_KEY`\n",
"3. pip install requirements.txt\n",
"4. Then, open in VSCode with the Jupyter extension or start jupyter from command line. Development was done with `nbdev`\n",
"\n",
"How to use:\n",
"\n",
"First,\n",
"\n",
"Run this in the terminal to run on Modal: www.modal.com:\n",
"\n",
"First, `modal token new` to set up your own modal account\n",
"\n",
"`nbdev_export` to get the latest package exported from jupyter\n",
"`modal serve ai_estimator/server.py` to see the docal preview\n",
"\n",
"`modal deploy` to set it to run on your account\n",
"\n",
"See demo running at: https://maxtheman--ai-estimator-run-server.modal.run/"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
5 changes: 5 additions & 0 deletions _proc/sidebar.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
website:
sidebar:
contents:
- index.ipynb
- 00_core.ipynb
Loading

0 comments on commit 7a409da

Please sign in to comment.