MadcowD / ell

A language model programming library.
http://docs.ell.so/
MIT License
3.98k stars 222 forks source link

custom client not used when ell.init(store='./logdir') is called #204

Closed gicque closed 6 days ago

gicque commented 1 week ago

I initialized a custom azure client like so:

client = AzureOpenAI(azure_endpoint=endpoint, api_version="2024-02-01", api_key=AZURE_OPENAI_API_KEY)

The following function works correctly:

@ell.simple(model=AZURE_OPENAI_MODEL_GENERATIVE, temperature=1.0, n=2, client=client)
def write_ten_drafts(idea : str):
   # print('*', client)
   """You are an adept story writer. The story should only be 3 paragraphs"""
   return f"Write a story about {idea}."

idea = "a robot discovers emotions"
drafts = write_ten_drafts(idea)
print('>>>', len(drafts))

but if I add the folowing before calling the function:

ell.init(store='./logdir') 

I receive the error: openai.RateLimitError: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}}

as if I am using openai and not azureOpenAI

MadcowD commented 6 days ago

okay interesting ill try to reproduce

MadcowD commented 6 days ago

Okay I have a workign example of azure here If this https://github.com/MadcowD/ell/blob/main/examples/providers/azure_ex.py merged on https://github.com/MadcowD/ell/pull/214

If this doesn't fix your issue then it's likely on your end.

gicque commented 6 days ago

Thanks for you very quick response and actions !

on version 0.0.7 your example works as announced, and request/response are correctly tracked: @ell.simple(model=AZURE_OPENAI_MODEL_GENERATIVE) def write_a_story(about : str): return f"write me a joke about {about}!"

if I add n=2 for example I got the previous error after the generation of the response: @ell.simple(model=AZURE_OPENAI_MODEL_GENERATIVE, n=2) def write_a_story(about : str): return f"write me a joke about {about}!"

Here is a screenshot: image

gicque commented 6 days ago

I think I understand the issue now, autocommit is set to True by default, and to generate the commit message, differ.py contains a call to a hard coded model "gpt-4o-mini" differ.py line 6 `@simple("gpt-4o-mini", temperature=0.2, exempt_from_tracking=True)`` if I set autocommit to False or remove the call to this function, your example and my project works as intended it seem to be the intended behavior as described in: https://docs.ell.so/core_concepts/versioning_and_storage.html#autocommitting do you think it would be possible to set a custom model for this action in the configuration ?