-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Conversas com Claude.ai - Componentization | ||
|
||
## Solicitando um Serviço de Correlação | ||
|
||
Given a file "intake-person-demo(age).csv" with the following file fields: age, gender, ethnicity, and fcid_code. Create a FastAPI service that has the following endpoint: | ||
|
||
GET /correlation | ||
|
||
This service receives the fcid_code of a food product. It returns the correlation between the age and intake_bw of the food product. The data to calculate the correlation comes from the csv file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
Given a file "intake-person-demo(age).csv" with the following file fields: age, gender, ethnicity, and fcid_code. Create a FastAPI service that has the following endpoint: | ||
# Conversas com Claude.ai - Componentization | ||
|
||
GET /correlation | ||
|
||
This service receives the fcid_code of a food product. It returns the correlation between the age and intake_bw of the food product. The data to calculate the correlation comes from the csv file. | ||
|
||
----- | ||
## Passo 2 - Transformando Workflow em Componente | ||
|
||
Given a . Create a python class to execute logistic regression predictions with two operations: | ||
|
||
* train: Receives the csv file path file with the following file fields: age, gender, ethnicity, and fcid_code. Trains a logistic regression model to predict the fcid_code given age, gender, and ethnicity. | ||
* predict: Receives three parameters (age, gender, and ethnicity) and predicts the fcid_code with the logistic regression model. | ||
|
||
----- | ||
### Exemplo de uso | ||
|
||
Can you give me a example of code using this class to do predictions with the following parameters: | ||
* train: file path = "intake-person-demo(beans).csv" | ||
* predict: age=31; gender=1; ethnicity=2 | ||
|
||
----- | ||
## Passo 3 - Componente para Serviço | ||
|
||
Can you transform this code into a FastAPI service with two endpoints: | ||
* POST /train | ||
* GET /predict | ||
* GET /predict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# FastAPI | ||
https://fastapi.tiangolo.com/ | ||
|
||
# Installing | ||
|
||
This statement forces a specific version of FastAPI installation when the default is not the latest. | ||
|
||
~~~ | ||
pip3 install "fastapi[standard]"==0.112.0 | ||
~~~ | ||
|
||
# Simple Example | ||
|
||
Examples derived from the tutorial: | ||
https://fastapi.tiangolo.com/ | ||
|
||
~~~ | ||
fastapi dev main.py | ||
~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from fastapi import FastAPI | ||
|
||
app = FastAPI() | ||
|
||
@app.get("/") | ||
def read_root(): | ||
return {"Hello": "World"} | ||
|
||
@app.get("/items/{item_id}") | ||
def read_item(item_id: int, q: str | None = None): | ||
return {"item_id": item_id, "q": q} |