Valdanito 5110a3ba90
refactor(API): Split SDK class to optimize code structure (#2515)
### What problem does this PR solve?

1. Split SDK class to optimize code structure
`ragflow.get_all_datasets()`  ===>     `ragflow.dataset.list()`
2. Fixed the parameter validation to allow for empty values.
3. Change the way of checking parameter nullness, Because even if the
parameter is empty, the key still exists, this is a feature from
[APIFlask](https://apiflask.com/schema/).

`if "parser_config" in json_data` ===> `if json_data["parser_config"]`


![image](https://github.com/user-attachments/assets/dd2a26d6-b3e3-4468-84ee-dfcf536e59f7)

4. Some common parameter error messages, all from
[Marshmallow](https://marshmallow.readthedocs.io/en/stable/marshmallow.fields.html)

Parameter validation configuration
```
    kb_id = fields.String(required=True)
    parser_id = fields.String(validate=validators.OneOf([parser_type.value for parser_type in ParserType]),
                              allow_none=True)
```

When my parameter is
```
kb_id=None,
parser_id='A4'
```

Error messages
```
{
    "detail": {
        "json": {
            "kb_id": [
                "Field may not be null."
            ],
            "parser_id": [
                "Must be one of: presentation, laws, manual, paper, resume, book, qa, table, naive, picture, one, audio, email, knowledge_graph."
            ]
        }
    },
    "message": "Validation error"
}
```

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
2024-09-20 17:28:57 +08:00
..
2024-06-27 14:41:52 +08:00
2024-08-23 18:38:20 +08:00

python-ragflow

update python client

  • Update "version" field of [project] chapter
  • Build new python SDK
  • Upload to pypi.org
  • Install new python SDK

build python SDK

rm -f dist/* && python setup.py sdist bdist_wheel

install python SDK

pip uninstall -y ragflow && pip install dist/*.whl

This will install ragflow-sdk and its dependencies.

upload to pypi.org

twine upload dist/*.whl

Enter your pypi API token according to the prompt.

Note that pypi allows a version of a package be uploaded only once. You need to change the version inside the pyproject.toml before building and uploading.

using


For developer

pip install -e .