Skip to content

Commit 964e462

Browse files
Merge branch 'main' into main
2 parents e719273 + 51efecf commit 964e462

File tree

72 files changed

+2723
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2723
-213
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean \
1313
RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
1414
apt update && apt-get --no-install-recommends install -y ca-certificates
1515

16-
# If you are at mainland China, you can use tsinghua mirror to speed up apt and poetry
16+
# If you download Python modules too slow, you can use a pip mirror site to speed up apt and poetry
1717
RUN sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/ubuntu.sources
1818
ENV POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/
1919

Dockerfile.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean \
1313
RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
1414
apt update && apt-get --no-install-recommends install -y ca-certificates
1515

16-
# If you are at mainland China, you can use tsinghua mirror to speed up apt and poetry
16+
# If you download Python modules too slow, you can use a pip mirror site to speed up apt and poetry
1717
RUN sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/ubuntu.sources
1818
ENV POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/
1919

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ Try our demo at [https://demo.ragflow.io](https://demo.ragflow.io).
153153
```
154154
155155
3. Build the pre-built Docker images and start up the server:
156-
> Running the following commands automatically downloads the *dev* version RAGFlow Docker image. To download and run a specified Docker version, update `RAGFLOW_IMAGE` in **docker/.env** to the intended version, for example `RAGFLOW_IMAGE=infiniflow/ragflow:v0.12.0`, before running the following commands.
156+
> Running the following commands automatically downloads the *dev-slim* version RAGFlow Docker image. To download and run a specified Docker version, update `RAGFLOW_IMAGE` in **docker/.env** to the intended version, for example `RAGFLOW_IMAGE=infiniflow/ragflow:v0.12.0-slim`, before running the following commands.
157157
158158
```bash
159159
$ cd ragflow/docker
160160
$ docker compose up -d
161161
```
162162
163-
> The core image is about 9 GB in size and may take a while to load.
163+
> The core image is about 1 GB in size and may take a while to load.
164164
165165
4. Check the server status after having the server up and running:
166166
@@ -294,7 +294,7 @@ docker build -f Dockerfile -t infiniflow/ragflow:dev .
294294
## 📚 Documentation
295295
296296
- [Quickstart](https://ragflow.io/docs/dev/)
297-
- [User guide](https://ragflow.io/docs/dev/category/user-guides)
297+
- [User guide](https://ragflow.io/docs/dev/category/guides)
298298
- [References](https://ragflow.io/docs/dev/category/references)
299299
- [FAQ](https://ragflow.io/docs/dev/faq)
300300

README_ja.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,12 @@
137137

138138
```bash
139139
$ cd ragflow/docker
140-
$ chmod +x ./entrypoint.sh
141140
$ docker compose up -d
142141
```
143142

144-
> 上記のコマンドを実行すると、RAGFlowの開発版dockerイメージが自動的にダウンロードされます。 特定のバージョンのDockerイメージをダウンロードして実行したい場合は、docker/.envファイルのRAGFLOW_IMAGE変数を見つけて、対応するバージョンに変更してください。 例えば、`RAGFLOW_IMAGE=infiniflow/ragflow:v0.12.0`として、上記のコマンドを実行してください。
143+
> 上記のコマンドを実行すると、RAGFlowの開発版dockerイメージが自動的にダウンロードされます。 特定のバージョンのDockerイメージをダウンロードして実行したい場合は、docker/.envファイルのRAGFLOW_IMAGE変数を見つけて、対応するバージョンに変更してください。 例えば、`RAGFLOW_IMAGE=infiniflow/ragflow:v0.12.0-slim`として、上記のコマンドを実行してください。
145144
146-
> コアイメージのサイズは約 9 GB で、ロードに時間がかかる場合があります。
145+
> コアイメージのサイズは約 1 GB で、ロードに時間がかかる場合があります。
147146
148147
4. サーバーを立ち上げた後、サーバーの状態を確認する:
149148

@@ -276,7 +275,7 @@ docker build -f Dockerfile -t infiniflow/ragflow:dev .
276275
## 📚 ドキュメンテーション
277276

278277
- [Quickstart](https://ragflow.io/docs/dev/)
279-
- [User guide](https://ragflow.io/docs/dev/category/user-guides)
278+
- [User guide](https://ragflow.io/docs/dev/category/guides)
280279
- [References](https://ragflow.io/docs/dev/category/references)
281280
- [FAQ](https://ragflow.io/docs/dev/faq)
282281

README_ko.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,13 @@
138138
139139
3. 미리 빌드된 Docker 이미지를 생성하고 서버를 시작하세요:
140140

141-
> 다음 명령어를 실행하면 *dev* 버전의 RAGFlow Docker 이미지가 자동으로 다운로드됩니다. 특정 Docker 버전을 다운로드하고 실행하려면, **docker/.env** 파일에서 `RAGFLOW_IMAGE`을 원하는 버전으로 업데이트한 후, 예를 들어 `RAGFLOW_IMAGE=infiniflow/ragflow:v0.12.0`로 업데이트 한 뒤, 다음 명령어를 실행하세요.
141+
> 다음 명령어를 실행하면 *dev* 버전의 RAGFlow Docker 이미지가 자동으로 다운로드됩니다. 특정 Docker 버전을 다운로드하고 실행하려면, **docker/.env** 파일에서 `RAGFLOW_IMAGE`을 원하는 버전으로 업데이트한 후, 예를 들어 `RAGFLOW_IMAGE=infiniflow/ragflow:v0.12.0-slim`로 업데이트 한 뒤, 다음 명령어를 실행하세요.
142142
```bash
143143
$ cd ragflow/docker
144-
$ chmod +x ./entrypoint.sh
145144
$ docker compose up -d
146145
```
147146

148-
> 기본 이미지는 약 9GB 크기이며 로드하는 데 시간이 걸릴 수 있습니다.
147+
> 기본 이미지는 약 1GB 크기이며 로드하는 데 시간이 걸릴 수 있습니다.
149148
150149

151150
4. 서버가 시작된 후 서버 상태를 확인하세요:
@@ -278,7 +277,7 @@ docker build -f Dockerfile -t infiniflow/ragflow:dev .
278277
## 📚 문서
279278

280279
- [Quickstart](https://ragflow.io/docs/dev/)
281-
- [User guide](https://ragflow.io/docs/dev/category/user-guides)
280+
- [User guide](https://ragflow.io/docs/dev/category/guides)
282281
- [References](https://ragflow.io/docs/dev/category/references)
283282
- [FAQ](https://ragflow.io/docs/dev/faq)
284283

README_zh.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,12 @@
137137

138138
```bash
139139
$ cd ragflow/docker
140-
$ chmod +x ./entrypoint.sh
141140
$ docker compose -f docker-compose.yml up -d
142141
```
143142

144-
> 请注意,运行上述命令会自动下载 RAGFlow 的开发版本 docker 镜像。如果你想下载并运行特定版本的 docker 镜像,请在 docker/.env 文件中找到 RAGFLOW_IMAGE 变量,将其改为对应版本。例如 `RAGFLOW_IMAGE=infiniflow/ragflow:v0.12.0`,然后运行上述命令。
143+
> 请注意,运行上述命令会自动下载 RAGFlow 的开发版本 docker 镜像。如果你想下载并运行特定版本的 docker 镜像,请在 docker/.env 文件中找到 RAGFLOW_IMAGE 变量,将其改为对应版本。例如 `RAGFLOW_IMAGE=infiniflow/ragflow:v0.12.0-slim`,然后运行上述命令。
145144
146-
> 核心镜像下载大小为 9 GB,可能需要一定时间拉取。请耐心等待。
145+
> 核心镜像下载大小为 1 GB,可能需要一定时间拉取。请耐心等待。
147146
148147
4. 服务器启动成功后再次确认服务器状态:
149148

@@ -278,7 +277,7 @@ docker build -f Dockerfile -t infiniflow/ragflow:dev .
278277
## 📚 技术文档
279278

280279
- [Quickstart](https://ragflow.io/docs/dev/)
281-
- [User guide](https://ragflow.io/docs/dev/category/user-guides)
280+
- [User guide](https://ragflow.io/docs/dev/category/guides)
282281
- [References](https://ragflow.io/docs/dev/category/references)
283282
- [FAQ](https://ragflow.io/docs/dev/faq)
284283

agent/component/exesql.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
from abc import ABC
1717
import re
1818
import pandas as pd
19-
from peewee import MySQLDatabase, PostgresqlDatabase
19+
import pymysql
20+
import psycopg2
2021
from agent.component.base import ComponentBase, ComponentParamBase
2122

2223

@@ -66,28 +67,28 @@ def _run(self, history, **kwargs):
6667
raise Exception("SQL statement not found!")
6768

6869
if self._param.db_type in ["mysql", "mariadb"]:
69-
db = MySQLDatabase(self._param.database, user=self._param.username, host=self._param.host,
70-
port=self._param.port, password=self._param.password)
70+
db = pymysql.connect(db=self._param.database, user=self._param.username, host=self._param.host,
71+
port=self._param.port, password=self._param.password)
7172
elif self._param.db_type == 'postgresql':
72-
db = PostgresqlDatabase(self._param.database, user=self._param.username, host=self._param.host,
73-
port=self._param.port, password=self._param.password)
73+
db = psycopg2.connect(dbname=self._param.database, user=self._param.username, host=self._param.host,
74+
port=self._param.port, password=self._param.password)
7475

7576
try:
76-
db.connect()
77+
cursor = db.cursor()
7778
except Exception as e:
7879
raise Exception("Database Connection Failed! \n" + str(e))
7980
sql_res = []
8081
for single_sql in re.split(r';', ans.replace(r"\n", " ")):
8182
if not single_sql:
8283
continue
8384
try:
84-
query = db.execute_sql(single_sql)
85-
if query.rowcount == 0:
86-
sql_res.append({"content": "\nTotal: " + str(query.rowcount) + "\n No record in the database!"})
85+
cursor.execute(single_sql)
86+
if cursor.rowcount == 0:
87+
sql_res.append({"content": "\nTotal: 0\n No record in the database!"})
8788
continue
88-
single_res = pd.DataFrame([i for i in query.fetchmany(size=self._param.top_n)])
89-
single_res.columns = [i[0] for i in query.description]
90-
sql_res.append({"content": "\nTotal: " + str(query.rowcount) + "\n" + single_res.to_markdown()})
89+
single_res = pd.DataFrame([i for i in cursor.fetchmany(size=self._param.top_n)])
90+
single_res.columns = [i[0] for i in cursor.description]
91+
sql_res.append({"content": "\nTotal: " + str(cursor.rowcount) + "\n" + single_res.to_markdown()})
9192
except Exception as e:
9293
sql_res.append({"content": "**Error**:" + str(e) + "\nError SQL Statement:" + single_sql})
9394
pass

api/apps/document_app.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from rag.utils.storage_factory import STORAGE_IMPL
5252
from api.utils.file_utils import filename_type, thumbnail, get_project_base_directory
5353
from api.utils.web_utils import html2pdf, is_valid_url
54+
from api.contants import IMG_BASE64_PREFIX
5455

5556

5657
@manager.route('/upload', methods=['POST'])
@@ -209,6 +210,11 @@ def list_docs():
209210
try:
210211
docs, tol = DocumentService.get_by_kb_id(
211212
kb_id, page_number, items_per_page, orderby, desc, keywords)
213+
214+
for doc_item in docs:
215+
if doc_item['thumbnail'] and not doc_item['thumbnail'].startswith(IMG_BASE64_PREFIX):
216+
doc_item['thumbnail'] = f"/v1/document/image/{kb_id}-{doc_item['thumbnail']}"
217+
212218
return get_json_result(data={"total": tol, "docs": docs})
213219
except Exception as e:
214220
return server_error_response(e)

api/contants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
NAME_LENGTH_LIMIT = 2 ** 10
16+
NAME_LENGTH_LIMIT = 2 ** 10
17+
18+
IMG_BASE64_PREFIX = 'data:image/png;base64,'

api/db/services/file_service.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from api.db.services.document_service import DocumentService
2727
from api.db.services.file2document_service import File2DocumentService
2828
from api.utils import get_uuid
29-
from api.utils.file_utils import filename_type, thumbnail
29+
from api.utils.file_utils import filename_type, thumbnail_img
3030
from rag.utils.storage_factory import STORAGE_IMPL
3131

3232

@@ -354,8 +354,15 @@ def upload_document(self, kb, file_objs, user_id):
354354
location += "_"
355355
blob = file.read()
356356
STORAGE_IMPL.put(kb.id, location, blob)
357+
358+
doc_id = get_uuid()
359+
360+
img = thumbnail_img(filename, blob)
361+
thumbnail_location = f'thumbnail_{doc_id}.png'
362+
STORAGE_IMPL.put(kb.id, thumbnail_location, img)
363+
357364
doc = {
358-
"id": get_uuid(),
365+
"id": doc_id,
359366
"kb_id": kb.id,
360367
"parser_id": self.get_parser(filetype, filename, kb.parser_id),
361368
"parser_config": kb.parser_config,
@@ -364,7 +371,7 @@ def upload_document(self, kb, file_objs, user_id):
364371
"name": filename,
365372
"location": location,
366373
"size": len(blob),
367-
"thumbnail": thumbnail(filename, blob)
374+
"thumbnail": thumbnail_location
368375
}
369376
DocumentService.insert(doc)
370377

0 commit comments

Comments
 (0)