Skip to content

Commit

Permalink
[AIC-py] Improve openai wrapper + cookbook (#364)
Browse files Browse the repository at this point in the history
[AIC-py] Improve openai wrapper + cookbook
  • Loading branch information
jonathanlastmileai authored Dec 1, 2023
2 parents 1b7795d + 143c3dd commit 802ce1d
Show file tree
Hide file tree
Showing 8 changed files with 986 additions and 688 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
![Python](https://github.com/lastmile-ai/aiconfig/actions/workflows/main_python.yml/badge.svg)
![Node](https://github.com/lastmile-ai/aiconfig/actions/workflows/main-typescript.yml/badge.svg)
![Docs](https://github.com/lastmile-ai/aiconfig/actions/workflows/test-deploy-docs.yml/badge.svg)
[![Discord](https://img.shields.io/badge/Discord-LastMile%20AI-Blue?color=rgb(37%2C%20150%2C%20190))](https://discord.gg/qMqgzDae)

[![Discord](<https://img.shields.io/badge/Discord-LastMile%20AI-Blue?color=rgb(37%2C%20150%2C%20190)>)](https://discord.gg/qMqgzDae)

> Full documentation: **[aiconfig.lastmileai.dev](https://aiconfig.lastmileai.dev/)**
Expand Down Expand Up @@ -300,14 +299,7 @@ Here are some example uses:

If you are already using OpenAI completion API's in your application, you can get started very quickly to start saving the messages in an `aiconfig`.

Simply add the following lines to your `import`:

```python
import openai
from aiconfig.ChatCompletion import create_and_save_to_config
new_config = AIConfigRuntime.create("my_aiconfig", "This is my new AIConfig")
openai.chat.completions.create = create_and_save_to_config(aiconfig=new_config)
```
Usage: see openai_wrapper.ipynb.

Now you can continue using `openai` completion API as normal. When you want to save the config, just call `new_config.save()` and all your openai completion calls will get serialized to disk.

Expand Down
15 changes: 1 addition & 14 deletions aiconfig-docs/docs/overview/create-an-aiconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,7 @@ asyncio.run(main())

If you're using OpenAI chat models, you can also use introspection to wrap OpenAI API calls and save an `aiconfig` automatically:

Replace

```python
import openai
```

with

```python
import openai
from aiconfig.ChatCompletion import create_and_save_to_config
new_config = AIConfigRuntime.create("my_aiconfig", "This is my new AIConfig")
openai.chat.completions.create = create_and_save_to_config(aiconfig=new_config)
```
Usage: see openai_wrapper.ipynb.

Now call OpenAI regularly. The results will automatically get saved in `new_config`:

Expand Down
Loading

0 comments on commit 802ce1d

Please sign in to comment.