Skip to content

Commit

Permalink
Manage ragflow-sdk with poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhichang committed Oct 30, 2024
1 parent 48688af commit 7da419a
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 88 deletions.
42 changes: 5 additions & 37 deletions sdk/python/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
# python-ragflow
# ragflow-sdk

# update python client
# build and publish python SDK to pypi.org

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

# build python SDK

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

# install python SDK
```shell
pip uninstall -y ragflow && pip install dist/*.whl
```

This will install ragflow-sdk and its dependencies.

# upload to pypi.org
```shell
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](https://pypi.org/help/#file-name-reuse). You need to change the `version` inside the `pyproject.toml` before building and uploading.

# using

```python

```

# For developer
```shell
pip install -e .
poetry build
poetry config pypi-token.pypi $YOUR_PYPI_API_TOKEN
poetry publish
```
183 changes: 183 additions & 0 deletions sdk/python/poetry.lock

Large diffs are not rendered by default.

35 changes: 14 additions & 21 deletions sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
[project]
name = "ragflow"
version = "0.8.0.dev1"
authors = [
{ name = "The RAGFlow Development Team", email = "[email protected]" },
] # TODO: email
dependencies = ["pytest~=8.2.0"]
description = "ragflow"
[tool.poetry]
name = "ragflow-sdk"
version = "0.0.2"
description = "Python client sdk of [RAGFlow](https://github.com/infiniflow/ragflow). RAGFlow is an open-source RAG (Retrieval-Augmented Generation) engine based on deep document understanding."
authors = ["Zhichang Yu <[email protected]>"]
license = "Apache License, Version 2.0"
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache License2",
"Operating System :: OS Independent",
]
package-mode = true

[tool.poetry.dependencies]
python = "^3.10"
requests = "^2.30.0"

[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project.urls]
"Homepage" = "https://github.com/pypa/sampleproject"
"Bug Tracker" = "https://github.com/pypa/sampleproject/issues"
# TODO
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import importlib.metadata

__version__ = importlib.metadata.version("ragflow")
__version__ = importlib.metadata.version("ragflow_sdk")

from .ragflow import RAGFlow
from .modules.dataset import DataSet
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from typing import Optional, List

from transformers.models.bloom.modeling_bloom import bloom_gelu_back
from typing import List

from .document import Document

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 0 additions & 21 deletions sdk/python/setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion sdk/python/test/t_chat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ragflow import RAGFlow, Chat
from ragflow_sdk import RAGFlow
HOST_ADDRESS = 'http://127.0.0.1:9380'

def test_create_chat_with_name(get_api_key_fixture):
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/test/t_dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ragflow import RAGFlow
from ragflow_sdk import RAGFlow
import random
import pytest

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/test/t_document.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ragflow import RAGFlow, DataSet, Document, Chunk
from ragflow_sdk import RAGFlow, DataSet, Document, Chunk

HOST_ADDRESS = 'http://127.0.0.1:9380'

Expand Down
3 changes: 1 addition & 2 deletions sdk/python/test/t_session.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ragflow import RAGFlow,Session
import time
from ragflow_sdk import RAGFlow
HOST_ADDRESS = 'http://127.0.0.1:9380'


Expand Down

0 comments on commit 7da419a

Please sign in to comment.