Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dottxt-ai/prompts
A prompting library
https://github.com/dottxt-ai/prompts
large-language-models prompt-engineering prompt-toolkit
Last synced: 19 days ago
JSON representation
A prompting library
- Host: GitHub
- URL: https://github.com/dottxt-ai/prompts
- Owner: dottxt-ai
- License: apache-2.0
- Created: 2024-07-26T10:48:39.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-09-27T09:23:25.000Z (3 months ago)
- Last Synced: 2024-11-15T07:24:02.095Z (29 days ago)
- Topics: large-language-models, prompt-engineering, prompt-toolkit
- Language: Python
- Homepage: https://dottxt-ai.github.io/prompts/
- Size: 631 KB
- Stars: 124
- Watchers: 4
- Forks: 9
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![.txt Twitter][dottxt-twitter-badge]][dottxt-twitter]
[![Contributors][contributors-badge]][contributors]
[![Discord][discord-badge]][discord]*A prompting library.*
Made with ❤👷️ by the team at [.txt](https://dottxt.co).
## Prompt functions
The `template` decorator takes a function as an argument whose docstring is a Jinja template, and returns a `Template` object:
```python
from prompts import template@template
def few_shots(instructions, examples, question):
return """{{ instructions }}Examples
--------
{% for example in examples %}
Q: {{ example.question }}
A: {{ example.answer }}
{% endfor %}
Q: {{ question}}
A: """
```Calling the `Template` object renders the Jinja template:
```python
instructions = "Please answer the following question following the examples" examples = [
{"question": "2+2=?", "answer":4},
{"question": "3+3=?", "answer":6},
]
question = "4+4 = ?"prompt = few_shots(instructions, examples, question)
```[contributors]: https://github.com/dottxt-ai/prompts/graphs/contributors
[contributors-badge]: https://img.shields.io/github/contributors/dottxt-ai/prompts?style=flat-square&logo=github&logoColor=white&color=ECEFF4
[dottxt-twitter]: https://twitter.com/dottxtai
[discord]: https://discord.gg/R9DSu34mGd
[discord-badge]: https://img.shields.io/discord/1182316225284554793?color=81A1C1&logo=discord&logoColor=white&style=flat-square
[dottxt-twitter-badge]: https://img.shields.io/twitter/follow/dottxtai?style=social