Skip to content

Commit 628ea4a

Browse files
Merge branch 'main' into add-evaluation-cookbook
2 parents 5836880 + 9825f03 commit 628ea4a

File tree

114 files changed

+17695
-1262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+17695
-1262
lines changed

.github/scripts/check_notebooks.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import subprocess
2+
import sys
3+
from pathlib import Path
4+
5+
import nbformat
6+
7+
8+
def get_changed_notebooks(base_ref: str = "origin/main") -> list[Path]:
9+
"""
10+
Returns a list of changed notebook paths in the current git branch
11+
compared to the specified base reference.
12+
"""
13+
result = subprocess.run(
14+
["git", "diff", "--name-only", base_ref, "--", "*.ipynb"],
15+
capture_output=True,
16+
text=True,
17+
check=True,
18+
)
19+
return [Path(line.strip()) for line in result.stdout.splitlines() if line.strip()]
20+
21+
22+
def is_valid_notebook(path: Path) -> bool:
23+
"""
24+
Checks if the notebook at the given path is valid by attempting to read it
25+
with nbformat.
26+
"""
27+
try:
28+
with open(path, "r", encoding="utf-8") as f:
29+
nbformat.read(f, as_version=4)
30+
return True
31+
except Exception as e:
32+
print(f"{path}: INVALID - {e}")
33+
return False
34+
35+
36+
def main() -> None:
37+
"""
38+
Main function to validate the format of changed notebooks.
39+
"""
40+
changed_notebooks = get_changed_notebooks()
41+
if not changed_notebooks:
42+
print("No changed .ipynb files to validate.")
43+
sys.exit(0)
44+
45+
print(f"Validating {len(changed_notebooks)} notebook(s)...")
46+
errors = 0
47+
for path in changed_notebooks:
48+
if not path.exists():
49+
continue # skip deleted files
50+
if not is_valid_notebook(path):
51+
errors += 1
52+
53+
if errors:
54+
print(f"{errors} invalid notebook(s) found.")
55+
sys.exit(1)
56+
else:
57+
print("All changed notebooks are valid.")
58+
59+
60+
if __name__ == "__main__":
61+
main()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Validate Changed Notebooks
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
validate-notebooks:
7+
name: Validate Notebooks
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0 # needed for git diff to work
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Install dependencies
22+
run: pip install nbformat
23+
24+
- name: Validate changed .ipynb files
25+
run: python .github/scripts/check_notebooks.py

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ dmypy.json
137137
*.DS_Store
138138
tmp_*
139139
examples/fine-tuned_qa/local_cache/*
140+
examples/multimodal/.local_cache/*
140141

141142
# PyCharm files
142143
.idea/
144+
.cursorignore
145+
146+
# VS Code files
147+
.vscode/
148+
.cursorignore

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
> ✨ Navigate at [cookbook.openai.com](https://cookbook.openai.com)
1111
12-
Example code and guides for accomplishing common tasks with the [OpenAI API](https://platform.openai.com/docs/introduction). To run these examples, you'll need an OpenAI account and associated API key ([create a free account here](https://beta.openai.com/signup)). Set an environment variable called `OPENAI_API_KEY` with your API key. Alternatively, in most IDEs such as Visual Studio Code, you can create an `.env` file at the root of your repo containing `OPENAI_API_KEY=<your API key>`, which will be picked up by the notebooks.
12+
Example code and guides for accomplishing common tasks with the [OpenAI API](https://platform.openai.com/docs/introduction). To run these examples, you'll need an OpenAI account and associated API key ([create a free account here](https://platform.openai.com/signup)). Set an environment variable called `OPENAI_API_KEY` with your API key. Alternatively, in most IDEs such as Visual Studio Code, you can create an `.env` file at the root of your repo containing `OPENAI_API_KEY=<your API key>`, which will be picked up by the notebooks.
1313

1414
Most code examples are written in Python, though the concepts can be applied in any language.
1515

1616
For other useful tools, guides and courses, check out these [related resources from around the web](https://cookbook.openai.com/related_resources).
1717

1818
## License
1919

20-
MIT
20+
MIT License

articles/related_resources.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ People are writing great tools and papers for improving outputs from GPT. Here a
77
- [Arthur Shield](https://www.arthur.ai/get-started): A paid product for detecting toxicity, hallucination, prompt injection, etc.
88
- [Baserun](https://baserun.ai/): A paid product for testing, debugging, and monitoring LLM-based apps
99
- [Chainlit](https://docs.chainlit.io/overview): A Python library for making chatbot interfaces.
10+
- [ElatoAI](https://github.com/akdeb/ElatoAI): A platform for running OpenAI Realtime API Speech on ESP32 on Arduino using Deno Edge Runtime and Supabase.
1011
- [Embedchain](https://github.com/embedchain/embedchain): A Python library for managing and syncing unstructured data with LLMs.
1112
- [FLAML (A Fast Library for Automated Machine Learning & Tuning)](https://microsoft.github.io/FLAML/docs/Getting-Started/): A Python library for automating selection of models, hyperparameters, and other tunable choices.
1213
- [Guidance](https://github.com/microsoft/guidance): A handy looking Python library from Microsoft that uses Handlebars templating to interleave generation, prompting, and logical control.

authors.yaml

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
# You can optionally customize how your information shows up cookbook.openai.com over here.
44
# If your information is not present here, it will be pulled from your GitHub profile.
5+
prashantmital-openai:
6+
name: "Prashant Mital"
7+
website: "https://www.linkedin.com/in/pmital/"
8+
avatar: "https://avatars.githubusercontent.com/u/173949238?v=4"
9+
10+
theophile-oai:
11+
name: "Theophile Sautory"
12+
website: "https://www.linkedin.com/in/theophilesautory"
13+
avatar: "https://avatars.githubusercontent.com/u/206768658?v=4"
14+
15+
robert-tinn:
16+
name: "Robert Tinn"
17+
website: "https://www.linkedin.com/in/robert-tinn/"
18+
avatar: "https://avatars.githubusercontent.com/u/208724428?v=4"
19+
20+
minh-hoque:
21+
name: "Minhajul Hoque"
22+
website: "https://www.linkedin.com/in/minhajul-hoque-83242b163/"
23+
avatar: "https://avatars.githubusercontent.com/u/84698472?v=4"
524

625
shikhar-cyber:
726
name: "Shikhar Kwatra"
@@ -58,6 +77,11 @@ ibigio:
5877
website: "https://twitter.com/ilanbigio"
5978
avatar: "https://pbs.twimg.com/profile_images/1841544725654077440/DR3b8DMr_400x400.jpg"
6079

80+
willhath-openai:
81+
name: "Will Hathaway"
82+
website: "https://www.willhath.com"
83+
avatar: "https://media.licdn.com/dms/image/v2/D4E03AQEHOtMrHtww4Q/profile-displayphoto-shrink_200_200/B4EZRR64p9HgAc-/0/1736541178829?e=2147483647&v=beta&t=w1rX0KhLZaK5qBkVLkJjmYmfNMbsV2Bcn8InFVX9lwI"
84+
6185
jhills20:
6286
name: "James Hills"
6387
website: "https://twitter.com/jamesmhills"
@@ -126,13 +150,13 @@ aaronwilkowitz-openai:
126150
charuj:
127151
name: "Charu Jaiswal"
128152
website: "https://www.linkedin.com/in/charu-j-8a866471"
129-
avatar: "https://avatars.githubusercontent.com/u/18404643?v=4"
153+
avatar: "https://avatars.githubusercontent.com/u/18404643?v=4"
130154

131155
rupert-openai:
132156
name: "Rupert Truman"
133157
website: "https://www.linkedin.com/in/rupert-truman/"
134158
avatar: "https://avatars.githubusercontent.com/u/171234447"
135-
159+
136160
keelan-openai:
137161
name: "Keelan Schule"
138162
website: "https://www.linkedin.com/in/keelanschule/"
@@ -171,8 +195,8 @@ evanweiss-openai:
171195
girishd:
172196
name: "Girish Dusane"
173197
website: "https://www.linkedin.com/in/girishdusane/"
174-
avatar: "https://avatars.githubusercontent.com/u/272708"
175-
198+
avatar: "https://avatars.githubusercontent.com/u/272708"
199+
176200
lxing-oai:
177201
name: "Luke Xing"
178202
website: "https://www.linkedin.com/in/lukexing/"
@@ -227,7 +251,7 @@ erickgort:
227251
name: "Erick Gort"
228252
website: "https://www.linkedin.com/in/erick-gort-32ab1678/"
229253
avatar: "https://avatars.githubusercontent.com/u/189261906?v=4"
230-
254+
231255
kylecote-tray:
232256
name: "Kyle Cote"
233257
website: "https://github.com/kylecote-tray"
@@ -248,6 +272,11 @@ msingh-openai:
248272
website: "https://github.com/msingh-openai"
249273
avatar: "https://avatars.githubusercontent.com/u/168678187?v=4"
250274

275+
akashdeepdeb:
276+
name: "Akashdeep Deb"
277+
website: "https://github.com/akdeb"
278+
avatar: "https://avatars.githubusercontent.com/u/20175219"
279+
251280
ted-at-openai:
252281
name: "Ted Sanders"
253282
website: "https://github.com/ted-at-openai"
@@ -277,3 +306,33 @@ josiah-openai:
277306
name: "Josiah Grace"
278307
website: "https://www.linkedin.com/in/josiahbgrace"
279308
avatar: "https://avatars.githubusercontent.com/u/181146311?v=4"
309+
310+
vishnu-oai:
311+
name: "Vishnu Chopra"
312+
website: "https://www.linkedin.com/in/vishnu-chopra/"
313+
avatar: "https://avatars.githubusercontent.com/u/206769912?v=4"
314+
315+
nm-openai:
316+
name: "Noah MacCallum"
317+
website: "https://x.com/noahmacca"
318+
avatar: "https://avatars.githubusercontent.com/u/171723556"
319+
320+
julian-openai:
321+
name: "Julian Lee"
322+
website: "https://x.com/julianl093"
323+
avatar: "https://avatars.githubusercontent.com/u/199828632"
324+
325+
rzhao-openai:
326+
name: "Randy Zhao"
327+
website: "https://www.linkedin.com/in/randy-zhao-27433616b"
328+
avatar: "https://avatars.githubusercontent.com/u/208724779?v=4"
329+
330+
brandonbaker-openai:
331+
name: "Brandon Baker"
332+
website: "https://www.linkedin.com/in/brandonbaker18"
333+
avatar: "https://avatars.githubusercontent.com/u/208719822"
334+
335+
tompakeman-oai:
336+
name: "Tom Pakeman"
337+
website: "https://www.linkedin.com/in/tom-pakeman/"
338+
avatar: "https://avatars.githubusercontent.com/u/204937754"

0 commit comments

Comments
 (0)