easyllm icon indicating copy to clipboard operation
easyllm copied to clipboard

Pydantic problem

Open bacoco opened this issue 2 years ago • 6 comments

Hello,

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

Thanks

bacoco avatar Aug 07 '23 06:08 bacoco

What is the error you are getting?

philschmid avatar Aug 07 '23 07:08 philschmid

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'

van51 avatar Aug 12 '23 14:08 van51

Can you please share the versions you have installed?

philschmid avatar Aug 12 '23 15:08 philschmid

Hi @van51, are you still facing the issue?

murdadesmaeeli avatar Nov 20 '23 19:11 murdadesmaeeli

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.

van51 avatar Nov 21 '23 07:11 van51

@philschmid this issue can be closed :+1:

murdadesmaeeli avatar Nov 26 '23 05:11 murdadesmaeeli