sane secrets management

This commit is contained in:
Andrej Karpathy
2026-01-04 19:29:22 +00:00
parent eb7bbc1b66
commit ed2082fbc4
4 changed files with 21 additions and 5 deletions
+4 -1
View File
@@ -3,4 +3,7 @@ __pycache__/
*.pyc *.pyc
dev-ignore/ dev-ignore/
report.md report.md
eval_bundle/ eval_bundle/
# Secrets
.env
+4 -3
View File
@@ -24,8 +24,7 @@ prompt:
manually generate any kind of entropy you can think of and include it in your prompts manually generate any kind of entropy you can think of and include it in your prompts
to maintain healthy and good diversity in the data. to maintain healthy and good diversity in the data.
NOTE: You need OpenRouter API key in a file called "openroutertoken.txt" in the root directory of the repo. NOTE: You need OPENROUTER_API_KEY set in .env or as an environment variable.
(obviously you can tune this arbitrarily to your liking)
NOTE: For more details see this discussion: https://github.com/karpathy/nanochat/discussions/139 NOTE: For more details see this discussion: https://github.com/karpathy/nanochat/discussions/139
""" """
import requests import requests
@@ -34,10 +33,12 @@ import os
import copy import copy
import random import random
from concurrent.futures import ThreadPoolExecutor, as_completed from concurrent.futures import ThreadPoolExecutor, as_completed
from dotenv import load_dotenv
from nanochat.common import get_base_dir from nanochat.common import get_base_dir
api_key = open("openroutertoken.txt", "r", encoding="utf-8").read().strip() load_dotenv()
api_key = os.environ["OPENROUTER_API_KEY"]
url = "https://openrouter.ai/api/v1/chat/completions" url = "https://openrouter.ai/api/v1/chat/completions"
headers = { headers = {
+2 -1
View File
@@ -8,6 +8,7 @@ dependencies = [
"datasets>=4.0.0", "datasets>=4.0.0",
"fastapi>=0.117.1", "fastapi>=0.117.1",
"psutil>=7.1.0", "psutil>=7.1.0",
"python-dotenv>=1.2.1",
"regex>=2025.9.1", "regex>=2025.9.1",
"rustbpe>=0.1.0", "rustbpe>=0.1.0",
"setuptools>=80.9.0", "setuptools>=80.9.0",
@@ -63,4 +64,4 @@ conflicts = [
{ extra = "cpu" }, { extra = "cpu" },
{ extra = "gpu" }, { extra = "gpu" },
], ],
] ]
Generated
+11
View File
@@ -741,6 +741,7 @@ dependencies = [
{ name = "datasets" }, { name = "datasets" },
{ name = "fastapi" }, { name = "fastapi" },
{ name = "psutil" }, { name = "psutil" },
{ name = "python-dotenv" },
{ name = "regex" }, { name = "regex" },
{ name = "rustbpe" }, { name = "rustbpe" },
{ name = "setuptools" }, { name = "setuptools" },
@@ -774,6 +775,7 @@ requires-dist = [
{ name = "datasets", specifier = ">=4.0.0" }, { name = "datasets", specifier = ">=4.0.0" },
{ name = "fastapi", specifier = ">=0.117.1" }, { name = "fastapi", specifier = ">=0.117.1" },
{ name = "psutil", specifier = ">=7.1.0" }, { name = "psutil", specifier = ">=7.1.0" },
{ name = "python-dotenv", specifier = ">=1.2.1" },
{ name = "regex", specifier = ">=2025.9.1" }, { name = "regex", specifier = ">=2025.9.1" },
{ name = "rustbpe", specifier = ">=0.1.0" }, { name = "rustbpe", specifier = ">=0.1.0" },
{ name = "setuptools", specifier = ">=80.9.0" }, { name = "setuptools", specifier = ">=80.9.0" },
@@ -1404,6 +1406,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" }, { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" },
] ]
[[package]]
name = "python-dotenv"
version = "1.2.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" },
]
[[package]] [[package]]
name = "pytz" name = "pytz"
version = "2025.2" version = "2025.2"