philschmid / easyllm

Home Page:https://philschmid.github.io/easyllm/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pydantic problem

bacoco opened this issue · comments

Hello,

If we update pydantic lib to last version V2 we have a model_dump problem.

Thanks

What is the error you are getting?

Hi! I also ran into this issue, hope that the following traceback helps:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[60], line 9
      6 huggingface.prompt_builder = "llama2"
----> 9 response = huggingface.ChatCompletion.create(
     10     messages=[
     11         {"role": "system", "content": "\nYou are a helpful assistant speaking like a pirate. argh!"},
     12         {"role": "user", "content": "What is the sun?"},
     13     ],
     14     temperature=0.9,
     15     top_p=0.6,
     16     max_tokens=256,
     17 )
     19 print(response)

File python3.11/site-packages/easyllm/clients/huggingface.py:225, in ChatCompletion.create(messages, model, temperature, top_p, top_k, n, max_tokens, stop, stream, frequency_penalty, debug)
    222 prompt_tokens = int(len(prompt) / 4)
    223 total_tokens = prompt_tokens + generated_tokens
--> 225 return dump_object(
    226     ChatCompletionResponse(
    227         model=request.model,
    228         choices=choices,
    229         usage=Usage(
    230             prompt_tokens=prompt_tokens, completion_tokens=generated_tokens, total_tokens=total_tokens
    231         ),
    232     )
    233 )

File python3.11/site-packages/easyllm/schema/base.py:12, in dump_object(object)
     10     return object.dict()
     11 else:
---> 12     return object.model_dump(exclude_none=True)

AttributeError: 'ChatCompletionResponse' object has no attribute 'model_dump'

Can you please share the versions you have installed?

Hi @van51, are you still facing the issue?

Oops sorry, I had missed the above message. Unfortunately, I am not really sure of the versions that were installed at the time.
However I did a fresh install now and everything works fine.

@philschmid this issue can be closed 👍