Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from openai:main #67

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ Why are these changes necessary? How do they improve the cookbook?

## For new content

When contributing new content, make sure to read through our [contributions rubric](/project/rubric.md) before submitting, and complete the following action items:
When contributing new content, read through our [contribution guidelines](/CONTRIBUTING.md), and mark the following action items as completed:

- [ ] I have added a new entry in [registry.yaml](/registry.yaml) so that my content renders on the cookbook website.
- [ ] I have conducted a self-review of my content based on the [contributions rubric](/project/rubric.md):
- [ ] Relevance: This content is related to building with the OpenAI API.
- [ ] I have conducted a self-review of my content based on the [c](/CONTRIBUTING.md#rubric):
- [ ] Relevance: This content is related to building with OpenAI technlogies and is useful to others.
- [ ] Uniqueness: I have searched for related examples in the OpenAI Cookbook, and verified that my content offers new insights or unique information compared to existing documentation.
- [ ] Spelling and Grammar: I have checked for spelling or grammatical mistakes.
- [ ] Clarity and Comprehensibility: I have done a final read-through and verified that the content is easy to understand.
- [ ] Accuracy and Correctness: The information I include is correct, appropriately cited, and all of my code executes successfully.
- [ ] Usability: I have verified that the content and code is well organized and easy to navigate and use.
- [ ] Completeness: I have verified that my content thorough and detailed, and I have explained everything fully.
- [ ] Clarity: I have done a final read-through and verified that my submission is well-organized and easy to understand.
- [ ] Correctness: The information I include is correct and all of my code executes successfully.
- [ ] Completeness: I have explained everything fully, including all necessary references and citations.

Remember, we will rate each of these areas on a scale from 1 to 5, with 1 being the lowest and 5 being the highest. Aim for a score of 3 or higher in each area to increase the chances of your contribution being accepted. Refer to our [contributions rubric](/project/rubric.md) for more details.
We will rate each of these areas on a scale from 1 to 4, and will only accept contributions that score 3 or higher on all areas. Refer to our [contributions guidelines](/CONTRIBUTING.md) for more details.
33 changes: 17 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ The OpenAI Cookbook is a community-driven resource aimed at sharing knowledge in

Before contributing, read through the existing issues and pull requests to see if someone else is already working on something similar. That way you can avoid duplicating efforts.

## What makes a good cookbook?
## What makes a good contribution?

**Useful:** Involves concepts or techniques that can be applied broadly, and can translate to practical uses and solving real-world problems. In your introduction, explain why the topic is important.
Generally, we have found that the best contributions to the Cookbook are **useful**, **novel** or **creative**, or a combination of these.

**Novel or common:** Showcases new developments or techniques. Look out for new research on how to best use LLMs, or new models and capabilities in the API. Alternatively, you can identify common challenges. If you're doing something often, chances are others are too, and having reusable examples to reference can be very helpful.
- **Useful:** Involves concepts or techniques that can be applied broadly and often, and can translate to practical use-cases and solving real-world problems. If you're doing something often, chances are others are too, and having reusable examples to reference can be very helpful.
- **Novel:** Showcases new developments or techniques. Look out for new research on how to best use LLMs, or new models and capabilities in the API.
- **Creative:** Uses LLMs in creative and innovative ways, or combines multiple APIs and tools in novel ways.

**Creative:** Uses LLMs in creative and innovative ways, or combines multiple APIs and tools in novel ways.
Additionally, we strive to maintain a **neutral** tone, and aim for **high quality** writing.

**Neutral:** Maintains a neutral stance on tools and products. While it's natural to have preferences for particular tools, a good guide avoids over-evangelizing or marketing specific products, ensuring integrity and inclusivity.

**High quality:** Well structured, clear and complete. Writing good content ensures others can fully benefit from it. See the rubric below for more details on how we assess the quality of submissions to the Cookbook.
- **Neutral:** Maintains a neutral stance on tools and products. While it's natural to have preferences for particular tools, a good guide avoids over-evangelizing or marketing specific products, ensuring integrity and inclusivity.
- **High quality:** Well structured, clear and complete. Writing good content ensures others can fully benefit from it. See the rubric below for more details on how we assess the quality of submissions to the Cookbook.

## Rubric

Expand All @@ -26,7 +27,7 @@ For additional advice on writing good documentation, refer to [What Makes Docume

| Criteria | Description | Score |
| ------------ | --------------------------------------------------------------------------------------------------- | ----- |
| Relevance | Is the content related to building with the OpenAI API? Is it useful? | |
| Relevance | Is the content related to building with OpenAI technologies? Is it useful to others? | |
| Uniqueness | Does the content offer new insights or unique information compared to existing documentation? | |
| Clarity | Is the language easy to understand? Are things well-explained? Is the title clear? | |
| Correctness | Are the facts, code snippets, and examples correct and reliable? Does everything execute correctly? | |
Expand All @@ -35,11 +36,11 @@ For additional advice on writing good documentation, refer to [What Makes Docume

### Breakdown

| Criteria | 1 | 2 | 3 | 4 |
| ------------ | ------------------------------------- | --------------------------------------------- | ---------------------------------------- | -------------------------------------- |
| Relevance | Not relevant to AI or OpenAI API. | Tangentially relevant. | Relevant but not very useful. | Relevant and useful. |
| Uniqueness | Many similar guides/examples. | Some unique aspects, but significant overlap. | Unique with minor overlaps. | Completely unique with fresh insights. |
| Clarity | Confusing and unclear. | Some sections unclear. | Clear language, unclear structure. | Clear language and structure. |
| Correctness | Many errors, code doesn't execute. | Few errors and warnings. | Code works, minor improvements needed. | Completely error free. |
| Completeness | Missing significant portions. | Lacks some explanations. | Mostly complete, minor additions needed. | Complete and detailed. |
| Grammar | Numerous spelling/grammatical errors. | Some spelling/grammatical errors. | Correct grammar, few typos. | Perfect grammar. |
| Criteria | 4 | 3 | 2 | 1 |
| ------------ | -------------------------------------- | ---------------------------------------- | --------------------------------------------- | ------------------------------------- |
| Relevance | Relevant and useful. | Relevant but not very useful. | Tangentially relevant. | Not relevant. |
| Uniqueness | Completely unique with fresh insights. | Unique with minor overlaps. | Some unique aspects, but significant overlap. | Many similar guides/examples. |
| Clarity | Clear language and structure. | Clear language, unclear structure. | Some sections unclear. | Confusing and unclear. |
| Correctness | Completely error free. | Code works, minor improvements needed. | Few errors and warnings. | Many errors, code doesn't execute. |
| Completeness | Complete and detailed. | Mostly complete, minor additions needed. | Lacks some explanations. | Missing significant portions. |
| Grammar | Perfect grammar. | Correct grammar, few typos. | Some spelling/grammatical errors. | Numerous spelling/grammatical errors. |
40 changes: 4 additions & 36 deletions examples/How_to_count_tokens_with_tiktoken.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"- .NET / C#: [SharpToken](https://github.com/dmitry-brazhenko/SharpToken), [TiktokenSharp](https://github.com/aiqinxuancai/TiktokenSharp)\n",
"- Java: [jtokkit](https://github.com/knuddelsgmbh/jtokkit)\n",
"- Golang: [tiktoken-go](https://github.com/pkoukk/tiktoken-go)\n",
"- Rust: [tiktoken-rs](https://github.com/zurawiki/tiktoken-rs)\n",
"\n",
"For `r50k_base` (`gpt2`) encodings, tokenizers are available in many languages.\n",
"- Python: [tiktoken](https://github.com/openai/tiktoken/blob/main/README.md) (or alternatively [GPT2TokenizerFast](https://huggingface.co/docs/transformers/model_doc/gpt2#transformers.GPT2TokenizerFast))\n",
Expand All @@ -48,6 +49,7 @@
"- Java: [gpt2-tokenizer-java](https://github.com/hyunwoongko/gpt2-tokenizer-java)\n",
"- PHP: [GPT-3-Encoder-PHP](https://github.com/CodeRevolutionPlugins/GPT-3-Encoder-PHP)\n",
"- Golang: [tiktoken-go](https://github.com/pkoukk/tiktoken-go)\n",
"- Rust: [tiktoken-rs](https://github.com/zurawiki/tiktoken-rs)\n",
"\n",
"(OpenAI makes no endorsements or guarantees of third-party libraries.)\n",
"\n",
Expand All @@ -69,43 +71,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: tiktoken in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (0.5.1)\n",
"Requirement already satisfied: requests>=2.26.0 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from tiktoken) (2.31.0)\n",
"Requirement already satisfied: regex>=2022.1.18 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from tiktoken) (2023.8.8)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from requests>=2.26.0->tiktoken) (2023.7.22)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from requests>=2.26.0->tiktoken) (3.4)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from requests>=2.26.0->tiktoken) (3.2.0)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from requests>=2.26.0->tiktoken) (2.0.5)\n",
"\u001b[33mWARNING: You are using pip version 22.0.4; however, version 23.2.1 is available.\n",
"You should consider upgrading via the '/Users/simon/.virtualenvs/openai/bin/python -m pip install --upgrade pip' command.\u001b[0m\u001b[33m\n",
"\u001b[0mNote: you may need to restart the kernel to use updated packages.\n",
"Requirement already satisfied: openai in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (0.28.1)\n",
"Requirement already satisfied: aiohttp in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (3.8.5)\n",
"Requirement already satisfied: requests>=2.20 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (2.31.0)\n",
"Requirement already satisfied: tqdm in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (4.66.1)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from requests>=2.20->openai) (3.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from requests>=2.20->openai) (2023.7.22)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from requests>=2.20->openai) (3.2.0)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from requests>=2.20->openai) (2.0.5)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from aiohttp->openai) (1.4.0)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from aiohttp->openai) (1.3.1)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from aiohttp->openai) (4.0.3)\n",
"Requirement already satisfied: yarl<2.0,>=1.0 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from aiohttp->openai) (1.9.2)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from aiohttp->openai) (6.0.4)\n",
"Requirement already satisfied: attrs>=17.3.0 in /Users/simon/.virtualenvs/openai/lib/python3.9/site-packages (from aiohttp->openai) (23.1.0)\n",
"\u001b[33mWARNING: You are using pip version 22.0.4; however, version 23.2.1 is available.\n",
"You should consider upgrading via the '/Users/simon/.virtualenvs/openai/bin/python -m pip install --upgrade pip' command.\u001b[0m\u001b[33m\n",
"\u001b[0mNote: you may need to restart the kernel to use updated packages.\n"
]
}
],
"outputs": [],
"source": [
"%pip install --upgrade tiktoken\n",
"%pip install --upgrade openai"
Expand Down
Loading