SDK for writing FasterFoods recommendation algorithms
Project description
fasterfoodsstack (Python)
SDK for writing FasterFoods recommendation algorithms in Python.
Install
pip install fasterfoodsstack
Or from source:
cd python/
pip install -e .
Quickstart
import fasterfoodsstack as ffs
from fasterfoodsstack import run_local
# Set your dev API key once (or use the FASTERFOODS_API_KEY env var)
ffs.configure(api_key="ffs-dev-...")
# Write your recommendation algorithm
def get_meal_recommendation(user):
remaining = user.goals.calories - (user.meals.last.calories if user.meals.last else 0)
if user.goals.goal_type == "gain_muscle":
return ffs.recommend.meal(
name="Grilled Chicken Bowl",
reason=f"{remaining} kcal remaining — prioritising protein for muscle gain",
calories=720,
protein_g=60.0,
tags=["high-protein", "meal-prep"],
)
return ffs.recommend.meal(
name="Tuna & Quinoa Salad",
reason=f"{remaining} kcal remaining today",
calories=480,
protein_g=42.0,
tags=["high-protein", "low-carb"],
)
# Fetch a pre-seeded test profile from the dev environment and run locally
ctx = ffs.dummy.athlete()
result = run_local(get_meal_recommendation, ctx)
# -> prints timing, validates return type, prints result fields
# Available profiles: athlete(), weight_loss(), starter(), family()
ctx = ffs.dummy.weight_loss()
result = run_local(get_meal_recommendation, ctx)
API reference
ffs.user (runtime, injected by platform)
| Attribute | Type | Description |
|---|---|---|
ffs.user.profile.dietary_flags |
list[str] |
e.g. ["vegetarian", "gluten-free"] |
ffs.user.meals.last |
Meal | None |
Most recently logged meal |
ffs.user.meals.history(days=7) |
list[Meal] |
Meals in the last N days |
ffs.user.meals.favorites |
list[Meal] |
User's favourite meals |
ffs.user.goals.calories |
int |
Daily calorie target |
ffs.user.goals.protein_g |
float |
Daily protein target (grams) |
ffs.user.goals.carbs_g |
float |
Daily carbs target (grams) |
ffs.user.goals.fat_g |
float |
Daily fat target (grams) |
ffs.user.goals.goal_type |
str |
"lose_weight" | "maintain" | "gain_muscle" |
ffs.recommend
ffs.recommend.meal(
name: str,
reason: str,
calories: int,
protein_g: float,
tags: list[str] = [],
) -> MealRecommendation
ffs.recommend.workout(
type: str, # "strength" | "cardio" | "flexibility" | "rest"
duration_minutes: int,
reason: str,
) -> WorkoutRecommendation
ffs.dummy
Fetches pre-seeded test user contexts from the FasterFoods dev environment. Each call makes an authenticated API request and returns a user context with the same shape as the runtime user namespace.
ctx = ffs.dummy.athlete() # high-calorie, gain_muscle
ctx = ffs.dummy.weight_loss() # caloric deficit, gluten-free
ctx = ffs.dummy.starter() # balanced beginner, maintain
ctx = ffs.dummy.family() # vegetarian, maintain
ffs.configure(api_key, base_url=None)
Sets the API key for all SDK calls. Call once at startup, or set FASTERFOODS_API_KEY in your environment instead.
run_local(fn, context)
Runs your function with a fetched user context, prints timing and the result, validates the return type.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fasterfoodsstack-0.1.0.tar.gz.
File metadata
- Download URL: fasterfoodsstack-0.1.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f893180830491ce0a98e504a01033d7b9229333975089e3a102f20efcc52718e
|
|
| MD5 |
0cb74e979688c06f6501365481d22ac0
|
|
| BLAKE2b-256 |
8a8132b9e0d1f483d1c3b52a04bd8ea873bc37df102aa0fde002cd0d2601fadc
|
Provenance
The following attestation bundles were made for fasterfoodsstack-0.1.0.tar.gz:
Publisher:
publish-python.yml on RitvikJoshi97/fasterfoodsstack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fasterfoodsstack-0.1.0.tar.gz -
Subject digest:
f893180830491ce0a98e504a01033d7b9229333975089e3a102f20efcc52718e - Sigstore transparency entry: 1593814875
- Sigstore integration time:
-
Permalink:
RitvikJoshi97/fasterfoodsstack@ef0bf9f4ae74bc7c63256f88a3b01b19f9284b77 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/RitvikJoshi97
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@ef0bf9f4ae74bc7c63256f88a3b01b19f9284b77 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fasterfoodsstack-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fasterfoodsstack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c87df21d7849de082ba8d552cd21e31a3638bd10887b852d1d97cf3df3c52677
|
|
| MD5 |
86db47c250485aa9f8fd679bccc1bd52
|
|
| BLAKE2b-256 |
d2f2e27606ab286243c5305b340c6c993b711836eafea412c31e19b48331b811
|
Provenance
The following attestation bundles were made for fasterfoodsstack-0.1.0-py3-none-any.whl:
Publisher:
publish-python.yml on RitvikJoshi97/fasterfoodsstack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fasterfoodsstack-0.1.0-py3-none-any.whl -
Subject digest:
c87df21d7849de082ba8d552cd21e31a3638bd10887b852d1d97cf3df3c52677 - Sigstore transparency entry: 1593814984
- Sigstore integration time:
-
Permalink:
RitvikJoshi97/fasterfoodsstack@ef0bf9f4ae74bc7c63256f88a3b01b19f9284b77 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/RitvikJoshi97
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@ef0bf9f4ae74bc7c63256f88a3b01b19f9284b77 -
Trigger Event:
push
-
Statement type: