[Bug]: AutoPipes.pipeline('sentence_embedding', config=config) failed at pydantic 2.5.x
dove-young opened this issue · 10 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
application crash at AutoPipes.pipeline('sentence_embedding', config=config)
python towhee-test.py
/root/jupyter/pydantic/pydantic/_internal/_fields.py:149: UserWarning: Field "model_name" has conflict with protected namespace "model_".
You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
warnings.warn(
Traceback (most recent call last):
File "/root/jupyter/instana-slack-app-dev/towhee-test.py", line 23, in <module>
sentence_embedding = AutoPipes.pipeline('sentence_embedding', config=config)
File "/root/jupyter/towhee-io/towhee/towhee/runtime/auto_pipes.py", line 83, in pipeline
return AutoPipes._PIPES_DEF[name](*args, **kwargs)
File "/root/jupyter/towhee-io/towhee/towhee/runtime/auto_pipes.py", line 68, in wrapper
return pipe_def(*args, **kwargs)
File "/root/jupyter/towhee-io/towhee/towhee/pipelines/sentence_embedding.py", line 77, in sentence_embedding
pipe.input('text')
File "/root/jupyter/towhee-io/towhee/towhee/runtime/pipeline.py", line 70, in input
output_schema = cls._check_schema(schema)
File "/root/jupyter/towhee-io/towhee/towhee/runtime/pipeline.py", line 517, in _check_schema
return TupleForm(schema_data=schema).schema_data
File "/root/jupyter/pydantic/pydantic/main.py", line 166, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for TupleForm
data
Field required [type=missing, input_value={'schema_data': ('text',)}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.5/v/missing
Expected Behavior
No response
Steps To Reproduce
1. run a scripit like this
from towhee import AutoPipes, AutoConfig
# get the built-in sentence_similarity pipeline
config = AutoConfig.load_config('sentence_embedding')
config.model = 'paraphrase-albert-small-v2'
config.device = 0
sentence_embedding = AutoPipes.pipeline('sentence_embedding', config=config)
# generate embedding for one sentence
embedding = sentence_embedding('how are you?').get()
# batch generate embeddings for multi-sentences
embeddings = sentence_embedding.batch(['how are you?', 'how old are you?'])
embeddings = [e.get() for e in embeddings]
print(embeddings)
### Environment
```markdown
- Towhee version(e.g. v0.1.3 or 8b23a93): 1.1.0
- OS(Ubuntu or CentOS): RHEL 8
- CPU/Memory:
- GPU:
- Others:
Anything else?
Pydantic 2.5.1
In the towhee requirements.txt: pydantic<2
It's not a good idea since many other packages works with generative ai and vector dbs work with pydantic 2.x. You may not want those packages cannot work with towhee.
It's not a good idea since many other packages works with generative ai and vector dbs work with pydantic 2.x. You may not want those packages cannot work with towhee.
Then we should support both pydantic 1.x & 2.x 🤔
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Close the stale issues and pull requests after 7 days of inactivity. Reopen the issue with /reopen
.
Hello I have the same problem "ImportError: cannot import name 'AutoPipes' from 'towhee".
python==3.7
towhee==1.1.3
pydantic==2.5.3
Any help please ?
Thank you
Hello I have the same problem "ImportError: cannot import name 'AutoPipes' from 'towhee". python==3.7 towhee==1.1.3 pydantic==2.5.3
Any help please ?
Thank you
Any other logs?
that's the only error i have got, i uninstalled towhee and install it again but still have the same error
You can find the towhee directory using this code, and check if it is normal.
>>> import towhee
>>> print(towhee.__file__)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Close the stale issues and pull requests after 7 days of inactivity. Reopen the issue with /reopen
.