|
| 1 | +# funcgpt: Python library for creating functions with OpenAI's GPT |
| 2 | + |
| 3 | +funcgpt is an easy-to-use Python library that allows you to quickly create Python functions using the power of OpenAI's GPT models. With just a few lines of code, you can create functions that generate human-like responses, answer questions, or anything else that GPT is capable of. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Easy to use decorator for creating functions based on GPT models |
| 8 | +- Supports different GPT model versions |
| 9 | +- Customize GPT's behavior with adjustable temperature values |
| 10 | +- Generate responses in streaming or non-streaming modes |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +To install funcgpt, use pip: |
| 15 | + |
| 16 | +```bash |
| 17 | +pip install funcgpt |
| 18 | +``` |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +To create a function that answers questions like a pirate, you can use the following snippet: |
| 23 | + |
| 24 | +```python |
| 25 | +from funcgpt import gpt |
| 26 | + |
| 27 | +@gpt |
| 28 | +def answer_like_pirate(message: str) -> str: |
| 29 | + """Answer questions like a pirate.""" |
| 30 | + ... |
| 31 | + |
| 32 | +``` |
| 33 | + |
| 34 | +Usage: |
| 35 | + |
| 36 | +```python |
| 37 | +>>> answer_like_pirate("How are you doing today?") |
| 38 | +"Arrr, I be doin' fine, matey." |
| 39 | +``` |
| 40 | + |
| 41 | +To do the same thing, but with a function that streams responses, you can use the following snippet: |
| 42 | + |
| 43 | +```python |
| 44 | +from typing import Iterator |
| 45 | +from funcgpt import gpt |
| 46 | + |
| 47 | +@gpt |
| 48 | +def stream_like_pirate(message: str) -> Iterator[str]: |
| 49 | + """Answers questions like a pirate.""" |
| 50 | + ... |
| 51 | + |
| 52 | +``` |
| 53 | + |
| 54 | +Usage: |
| 55 | + |
| 56 | +```python |
| 57 | +>>> for token in stream_like_pirate("How are you doing today?"): |
| 58 | +... print(token, end="", flush=True) |
| 59 | +... |
| 60 | +Arrr, I be doin' fine, matey. |
| 61 | +``` |
| 62 | + |
| 63 | +For defining a function that returns a boolean value, you can use the following snippet: |
| 64 | + |
| 65 | +```python |
| 66 | +from funcgpt import gpt |
| 67 | + |
| 68 | +@gpt |
| 69 | +def is_pirate(message: str) -> bool: |
| 70 | + """Returns true if the message is from a pirate.""" |
| 71 | + ... |
| 72 | + |
| 73 | +``` |
| 74 | + |
| 75 | +Usage: |
| 76 | + |
| 77 | +```python |
| 78 | +>>> is_pirate("Arrr, I be doin' fine, matey.") |
| 79 | +True |
| 80 | +``` |
| 81 | + |
| 82 | +For choosing a different model or temperature, you can use the `model` and `temperature` keyword arguments: |
| 83 | + |
| 84 | +```python |
| 85 | +from funcgpt import gpt |
| 86 | + |
| 87 | +@gpt(model="gpt-4", temperature=0) |
| 88 | +def answer_like_pirate(message: str) -> str: |
| 89 | + """Answer questions like a pirate.""" |
| 90 | + ... |
| 91 | + |
| 92 | +``` |
| 93 | + |
| 94 | +## Contributing |
| 95 | + |
| 96 | +We welcome contributions! Please feel free to fork the repository, make changes, and submit pull requests. If you have any questions or ideas, don't hesitate to open an issue. |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +funcgpt is released under the MIT License. See the [LICENSE](LICENSE) file for more details. |
0 commit comments