Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
BenderV committed Sep 8, 2024
1 parent e6168de commit dcfc5c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ export AUTOCHAT_MODEL="gpt-4-turbo"
export OPENAI_API_KEY=<your-key>
```

or with anthropic

```bash
export AUTOCHAT_MODEL="claude-3-opus"
export ANTHROPIC_API_KEY=<your-key>
```

Use `AUTOCHAT_HOST` to use alternative provider (openai, anthropic, openpipe, llama_cpp, ...)

## Support
Expand Down
8 changes: 5 additions & 3 deletions autochat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import traceback
import typing
from enum import Enum

Expand Down Expand Up @@ -134,7 +135,7 @@ def add_function(
def prepare_messages(
self,
transform_function: typing.Callable,
transform_list_function: typing.Callable,
transform_list_function: typing.Callable = lambda x: x,
) -> list[dict]:
"""Prepare messages for API requests using a transformation function."""
first_message = self.messages[0]
Expand Down Expand Up @@ -201,7 +202,7 @@ def run_conversation(
return
# If function call failed, return the error message
# Flatten the error message
content = e.__repr__()
content = traceback.format_exc()

yield response

Expand Down Expand Up @@ -412,7 +413,8 @@ def merge_messages(messages):
}
]
# Tools: Add cache_control to the last tool function
tools[-1]["cache_control"] = {"type": "ephemeral"}
if tools:
tools[-1]["cache_control"] = {"type": "ephemeral"}

# System: add cache_control to the system message
if system is not None:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

setup(
name="autochat",
version="0.3.0",
version="0.3.1",
packages=find_packages(),
install_requires=["tenacity==8.3.0"],
extras_require={
"anthropic": ["anthropic==0.3.1"],
"anthropic": ["anthropic==0.34.2"],
"openai": ["openai==1.26.0"],
"all": ["anthropic==0.3.1", "openai==1.26.0"],
"all": ["anthropic==0.34.2", "openai==1.26.0"],
},
author="Benjamin Derville",
author_email="[email protected]",
Expand Down

0 comments on commit dcfc5c0

Please sign in to comment.