warning for autocommit failure

This commit is contained in:
William Guss
2024-09-11 23:30:23 -07:00
parent 55f3dfef71
commit 555ede4efe
4 changed files with 17 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ import ell # type: ignore
@ell.simple(model="claude-3-5-sonnet-20240620", max_tokens=12)
def hello_from_claude():
"""You are an AI assistant. Your task is to respond to the user's message with a friendly greeting."""
return "Say hello to the world!"
return "Say hello to the world!!!"
if __name__ == "__main__":

View File

@@ -17,6 +17,6 @@ def make_a_joke_about_the_image(image: Image.Image) -> str:
if __name__ == "__main__":
ell.set_store('./logdir', autocommit=False)
ell.set_store('./logdir', autocommit=True)
joke = make_a_joke_about_the_image(cat_meme_pil)
print(joke)

View File

@@ -3,6 +3,7 @@ import logging
import threading
from ell.types import SerializedLMP, Invocation, InvocationTrace, InvocationContents
from ell.types.studio import LMPType, utc_now
from ell.util._warnings import _autocommit_warning
import ell.util.closure
from ell.configurator import config
from ell.types._lstr import _lstr
@@ -177,10 +178,12 @@ def _serialize_lmp(func):
latest_lmp = max(lmps, key=lambda x: x.created_at)
version = latest_lmp.version_number + 1
if config.autocommit:
from ell.util.differ import write_commit_message_for_diff
commit = str(write_commit_message_for_diff(
# XXX: Move this out to autocommit itself.
if not _autocommit_warning():
from ell.util.differ import write_commit_message_for_diff
commit = str(write_commit_message_for_diff(
f"{latest_lmp.dependencies}\n\n{latest_lmp.source}",
f"{fn_closure[1]}\n\n{fn_closure[0]}")[0])
f"{fn_closure[1]}\n\n{fn_closure[0]}")[0])
serialized_lmp = SerializedLMP(
lmp_id=func.__ell_hash__,

View File

@@ -53,4 +53,12 @@ ell.simple(model, client=my_client)(...)
```
{Style.RESET_ALL}""")
elif (client_to_use := config.registry[model]) is None or not client_to_use.api_key:
logger.warning(_no_api_key_warning(model, fn.__name__, client_to_use or '', long=False))
logger.warning(_no_api_key_warning(model, fn.__name__, client_to_use or '', long=False))
def _autocommit_warning():
if (config.get_client_for("gpt-4o-mini")[0] is None):
logger.warning(f"{Fore.LIGHTYELLOW_EX}WARNING: Autocommit is enabled but no OpenAI client found for autocommit model 'gpt-4o-mini' (set your OpenAI API key). Commit messages will not be written.{Style.RESET_ALL}")
return True
return False