mirror of
https://github.com/kennethreitz/instructor.git
synced 2026-06-05 22:50:18 +00:00
improve documentation
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 115 KiB |
+54
-3
@@ -1,8 +1,28 @@
|
||||
# OpenAI Function Calls Quick Start Guide
|
||||
# OpenAI Function Call
|
||||
|
||||
*OpenAISchema, structured extraction in Python, powered by OpenAI, designed for simplicity, transparency, and control.*
|
||||
|
||||
-----
|
||||
|
||||
This library is build to interact with openai's function call api from python code, with python objects. It's designed to be intuitive, easy to use, but give great visibily in how we call openai.
|
||||
|
||||
**OpenAISchema** is based on Python type annotations, and powered by Pydantic.
|
||||
|
||||
The key features are:
|
||||
|
||||
* **Intuitive to write**: Great support for editors, completions. Spend less time debugging.
|
||||
* **Writing prompts as code**: Collocate docstrings and descriptions as part of your prompting.
|
||||
* **Extensible**: Bring your own kitchen sink without being weighted down by abstractions.
|
||||
|
||||
## Structured Extraction with `openai`
|
||||
|
||||
Welcome to the Quick Start Guide for OpenAI Function Call. This guide will walk you through the installation process and provide examples demonstrating the usage of function calls and schemas with OpenAI and Pydantic.
|
||||
|
||||
## Installation
|
||||
### Requirements
|
||||
|
||||
This library depends on **Pydantic** an **OpenAI** that's all.
|
||||
|
||||
### Installation
|
||||
|
||||
To get started with OpenAI Function Call, you need to install it using `pip`. Run the following command in your terminal:
|
||||
|
||||
@@ -132,10 +152,41 @@ print(user.age) # Output: 30
|
||||
|
||||
By calling `UserDetails.from_response`, we create an instance of the `UserDetails` class using the response from the API call. Subsequently, we can access the extracted user details through the `name` and `age` attributes of the `user` object.
|
||||
|
||||
## Next Steps
|
||||
## IDE Support
|
||||
|
||||
Everything is designed for you to get the best developer experience possible, with the best editor support.
|
||||
|
||||
Including **autocompletion**:
|
||||
|
||||

|
||||
|
||||
And even **inline errors**
|
||||
|
||||

|
||||
|
||||
## OpenAI Schema and Pydantic
|
||||
|
||||
This quick start guide provided you with a basic understanding of how to use OpenAI Function Call for schema extraction and function calls. You can now explore more advanced use cases and creative applications of this library.
|
||||
|
||||
Since `UserDetails` is a `OpenAISchems` and a `pydantic.BaseModel` you can use inheritance and nesting to create more complex emails while avoiding code duplication
|
||||
|
||||
```python
|
||||
class UserDetails(OpenAISchema):
|
||||
name: str = Field(..., description="User's full name")
|
||||
age: int
|
||||
|
||||
class UserWithAddress(UserDetails):
|
||||
address: str
|
||||
|
||||
class UserWithFriends(UserDetails):
|
||||
best_friend: UserDetail
|
||||
friends: List[UserDetails]
|
||||
```
|
||||
|
||||
If you have any questions, feel free to leave an issue or reach out to the library's author on [Twitter](https://twitter.com/jxnlco). For a more comprehensive solution with additional features, consider checking out [MarvinAI](https://www.askmarvin.ai/).
|
||||
|
||||
To see more examples of how we can create interesting models check out some [examples.](examples/index.md)
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under ther terms of the MIT License.
|
||||
+8
-7
@@ -44,12 +44,9 @@ markdown_extensions:
|
||||
- md_in_html
|
||||
- admonition
|
||||
nav:
|
||||
- Quick Start: 'index.md'
|
||||
- API Reference:
|
||||
- 'OpenAISchema': 'openai_schema.md'
|
||||
- "MultiTask Schema": "multitask.md"
|
||||
- "Introduction: Writing Prompts": "writing-prompts.md"
|
||||
- "Prompting Templates": "chat-completion.md"
|
||||
- Introduction:
|
||||
- Function Calls: 'index.md'
|
||||
- Philosophy: 'philosophy.md'
|
||||
- Use Cases:
|
||||
- 'Overview': 'examples/index.md'
|
||||
- 'Segmented Search': 'examples/search.md'
|
||||
@@ -58,7 +55,11 @@ nav:
|
||||
- 'Exact Citations': 'examples/exact_citations.md'
|
||||
- 'Automated Dataframe Extraction': "examples/autodataframe.md"
|
||||
- 'Creating multiple file programs': "examples/gpt-engineer.md"
|
||||
- Philosophy: 'philosophy.md'
|
||||
- API Reference:
|
||||
- 'OpenAISchema': 'openai_schema.md'
|
||||
- "MultiTask Schema": "multitask.md"
|
||||
- "Introduction: Writing Prompts": "writing-prompts.md"
|
||||
- "Prompting Templates": "chat-completion.md"
|
||||
extra:
|
||||
analytics:
|
||||
provider: google
|
||||
|
||||
Reference in New Issue
Block a user