Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ repos:
rev: v1.7.7
hooks:
- id: docformatter
language_version: python3.12
args: [
--in-place,
--wrap-summaries=0, # 0 means disable wrap
Expand Down
2 changes: 2 additions & 0 deletions EdgeCraftRAG/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,14 @@ The CLI will display error messages from the API in JSON format. Network errors
## Tips

- Use `--help` with any command to see detailed help:

```bash
ecrag pipeline --help
ecrag pipeline create --help
```

- Pipe JSON output to other tools:

```bash
ecrag kb list | jq '.[]' | head -n 20
```
Expand Down
19 changes: 12 additions & 7 deletions EdgeCraftRAG/cli/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
# SPDX-License-Identifier: Apache-2.0

import json
import requests
from typing import Optional, Dict, Any
from typing import Any, Dict, Optional
from urllib.parse import urljoin

import requests


class EcragApiClient:
"""API client for Edge Craft RAG."""

def __init__(self, host: str = "http://localhost", server_port: int = 16010, mega_port: int = 16011):
"""Initialize the API client.

Args:
host: The host URL (default: http://localhost)
server_port: The server port (default: 16010)
Expand All @@ -21,10 +22,10 @@ def __init__(self, host: str = "http://localhost", server_port: int = 16010, meg
# Normalize host URL
if not host.startswith(("http://", "https://")):
host = f"http://{host}"

# Remove trailing slash if present
host = host.rstrip("/")

self.server_url = f"{host}:{server_port}"
self.mega_url = f"{host}:{mega_port}"

Expand Down Expand Up @@ -170,12 +171,16 @@ def delete_knowledge_base(self, kb_name: str) -> Dict[str, Any]:
def add_files_to_kb(self, kb_name: str, local_paths: list) -> Dict[str, Any]:
"""Add files to a knowledge base."""
url = urljoin(self.server_url, f"/v1/knowledge/{kb_name}/files")
return self._request("POST", url, json={"local_paths": local_paths}, headers={"Content-Type": "application/json"})
return self._request(
"POST", url, json={"local_paths": local_paths}, headers={"Content-Type": "application/json"}
)

def delete_files_from_kb(self, kb_name: str, local_paths: list) -> Dict[str, Any]:
"""Delete files from a knowledge base."""
url = urljoin(self.server_url, f"/v1/knowledge/{kb_name}/files")
return self._request("DELETE", url, json={"local_paths": local_paths}, headers={"Content-Type": "application/json"})
return self._request(
"DELETE", url, json={"local_paths": local_paths}, headers={"Content-Type": "application/json"}
)

# Experience Management
def get_experiences(self) -> Dict[str, Any]:
Expand Down
1 change: 0 additions & 1 deletion EdgeCraftRAG/cli/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""Configuration for EdgeCraft RAG CLI."""

import os
Expand Down
13 changes: 7 additions & 6 deletions EdgeCraftRAG/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# SPDX-License-Identifier: Apache-2.0

import json
import click
import os
from pathlib import Path
from typing import Optional

import click
from cli.client import EcragApiClient
from cli.config import get_config

Expand Down Expand Up @@ -34,26 +35,26 @@ def run_chatqna_query(client: EcragApiClient, query: str, top_n: int, max_tokens
@click.pass_context
def cli(ctx, host: Optional[str], port: Optional[int], mega_port: Optional[int]):
"""EdgeCraft RAG CLI Tool.

Configure server connection via command-line options or environment variables:
- ECRAG_HOST: Server host (default: http://localhost)
- ECRAG_PORT: Server port (default: 16010)
- ECRAG_MEGA_PORT: Mega service port (default: 16011)
"""
ctx.ensure_object(dict)

# Get defaults from config
config = get_config()

# Use provided options or environment/defaults
final_host = host or config.host
final_port = port or config.port
final_mega_port = mega_port or config.mega_port

# Normalize host URL
if not final_host.startswith(("http://", "https://")):
final_host = f"http://{final_host}"

ctx.obj["client"] = EcragApiClient(host=final_host, server_port=final_port, mega_port=final_mega_port)


Expand Down
10 changes: 5 additions & 5 deletions EdgeCraftRAG/cli/quickstart.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""Quick start guide for EdgeCraft RAG CLI."""

import json
import sys

from cli.client import EcragApiClient


def test_connection(host: str = "http://localhost", port: int = 16010):
"""Test connection to EdgeCraft RAG server."""
client = EcragApiClient(host=host, server_port=port)

try:
print(f"Testing connection to {client.server_url}...")
result = client.get_system_info()

if "error" in result:
print(f"❌ Connection failed: {result['error']}")
return False

print("✓ Connection successful!")
print(f" System Info: {json.dumps(result, indent=2)}")
return True
Expand Down Expand Up @@ -62,7 +62,7 @@ def quick_start_guide():
export ECRAG_MEGA_PORT=16011

COMMON COMMANDS:

Pipeline Management:
ecrag pipeline list
ecrag pipeline get --name <name>
Expand Down
4 changes: 1 addition & 3 deletions EdgeCraftRAG/cli/setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env python3
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""Canonical setup script for EdgeCraft RAG CLI."""

from setuptools import setup


setup(
name="ecrag-cli",
version="0.1.0",
Expand Down Expand Up @@ -35,4 +33,4 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
)
)
13 changes: 8 additions & 5 deletions EdgeCraftRAG/docker_compose/intel/gpu/arc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ This section describes how to quickly deploy and test the EdgeCraftRAG service m

### 1. Prerequisites

EC-RAG supports vLLM deployment(default method) and local OpenVINO deployment for Intel Arc GPU and Core Ultra Platform. Prerequisites are shown as below:
EC-RAG supports vLLM deployment(default method) and local OpenVINO deployment for Intel Arc GPU and Core Ultra Platform. Prerequisites are shown as below:

#### Core Ultra

**OS**: Ubuntu 24.04 or newer
**Driver & libraries**: Please refer to [Installing Client GPUs on Ubuntu Desktop](https://dgpu-docs.intel.com/driver/client/overview.html#installing-client-gpus-on-ubuntu-desktop)
**Available Inferencing Framework**: openVINO

#### Intel Arc B60
**OS**: Ubuntu 25.04 Desktop (for Core Ultra and Xeon-W), Ubuntu 25.04 Server (for Xeon-SP).

**OS**: Ubuntu 25.04 Desktop (for Core Ultra and Xeon-W), Ubuntu 25.04 Server (for Xeon-SP).
**Driver & libraries**: Please refer to [Install Bare Metal Environment](https://github.com/intel/llm-scaler/tree/main/vllm#11-install-bare-metal-environment) for detailed setup
**Available Inferencing Framework**: openVINO, vLLM

#### Intel Arc A770

**OS**: Ubuntu Server 22.04.1 or newer (at least 6.2 LTS kernel)
**Driver & libraries**: Please refer to [Installing GPUs Drivers](https://dgpu-docs.intel.com/driver/client/overview.html#ubuntu-22.04) for detailed driver & libraries setup
**Available Inferencing Framework**: openVINO, vLLM
Expand All @@ -48,9 +51,9 @@ cd GenAIExamples/EdgeCraftRAG

> **NOTE**: If you want to checkout a released version, such as v1.5:
>
>```
>git checkout v1.5
>```
> ```
> git checkout v1.5
> ```

### 3. Run quick_start.sh

Expand Down
25 changes: 14 additions & 11 deletions EdgeCraftRAG/docker_compose/intel/gpu/arc/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
EC-RAG 支持 vLLM 部署(默认方式)以及面向 Intel Arc GPU 和 Core Ultra 平台的本地 OpenVINO 部署。前置条件如下:

#### Core Ultra

**操作系统**:Ubuntu 24.04 或更高版本
**驱动与库**:请参考 [Installing Client GPUs on Ubuntu Desktop](https://dgpu-docs.intel.com/driver/client/overview.html#installing-client-gpus-on-ubuntu-desktop)
**可用推理框架**:openVINO

#### Intel Arc B60

**操作系统**:Ubuntu 25.04 Desktop(适用于 Core Ultra 和 Xeon-W),Ubuntu 25.04 Server(适用于 Xeon-SP)。
**驱动与库**:详细安装请参考 [Install Bare Metal Environment](https://github.com/intel/llm-scaler/tree/main/vllm#11-install-bare-metal-environment)
**可用推理框架**:openVINO、vLLM

#### Intel Arc A770

**操作系统**:Ubuntu Server 22.04.1 或更高版本(至少 6.2 LTS 内核)
**驱动与库**:详细驱动与库安装请参考 [Installing GPUs Drivers](https://dgpu-docs.intel.com/driver/client/overview.html#ubuntu-22.04)
**可用推理框架**:openVINO、vLLM
Expand All @@ -48,9 +51,9 @@ cd GenAIExamples/EdgeCraftRAG

> **注意**:如果你想切换到某个发布版本,例如 v1.5:
>
>```
>git checkout v1.5
>```
> ```
> git checkout v1.5
> ```

### 3. 运行 quick_start.sh

Expand Down Expand Up @@ -112,11 +115,11 @@ If you are accessing from another machine, replace ${HOST_IP} with your server's

下表全面概述了示例 Docker Compose 文件中各类部署所使用的 EdgeCraftRAG 服务。表中每一行代表一个独立服务,详细说明了可用镜像及其在部署架构中的功能描述。

| 服务名称 | 可选镜像名称 | 可选 | 描述 |
| ------------------- | ---------------------------------------- | ---- | ------------------------------------------------------------------------------------------------ |
| etcd | quay.io/coreos/etcd:v3.5.5 | 否 | 提供分布式键值存储,用于服务发现和配置管理。 |
| minio | minio/minio:RELEASE.2023-03-20T20-16-18Z | 否 | 提供对象存储服务,用于存储文档和模型文件。 |
| milvus-standalone | milvusdb/milvus:v2.4.6 | 否 | 提供向量数据库能力,用于管理 embedding 和相似度检索。 |
| edgecraftrag-server | opea/edgecraftrag-server:latest | 否 | 作为 EdgeCraftRAG 服务后端,具体形态随部署方式不同而变化。 |
| edgecraftrag-ui | opea/edgecraftrag-ui:latest | 否 | 提供 EdgeCraftRAG 服务的用户界面。 |
| ecrag | opea/edgecraftrag:latest | 否 | 作为反向代理,管理 UI 与后端服务之间的流量。 |
| 服务名称 | 可选镜像名称 | 可选 | 描述 |
| ------------------- | ---------------------------------------- | ---- | ---------------------------------------------------------- |
| etcd | quay.io/coreos/etcd:v3.5.5 | 否 | 提供分布式键值存储,用于服务发现和配置管理。 |
| minio | minio/minio:RELEASE.2023-03-20T20-16-18Z | 否 | 提供对象存储服务,用于存储文档和模型文件。 |
| milvus-standalone | milvusdb/milvus:v2.4.6 | 否 | 提供向量数据库能力,用于管理 embedding 和相似度检索。 |
| edgecraftrag-server | opea/edgecraftrag-server:latest | 否 | 作为 EdgeCraftRAG 服务后端,具体形态随部署方式不同而变化。 |
| edgecraftrag-ui | opea/edgecraftrag-ui:latest | 否 | 提供 EdgeCraftRAG 服务的用户界面。 |
| ecrag | opea/edgecraftrag:latest | 否 | 作为反向代理,管理 UI 与后端服务之间的流量。 |
1 change: 1 addition & 0 deletions EdgeCraftRAG/docs/API_Guide.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Edge Craft Retrieval-Augmented Generation API Guide

> **Base URLs**
>
> - EC-RAG Server: `http://${HOST_IP}:16010`
> - EC-RAG Mega Service: `http://${HOST_IP}:16011`
Expand Down
4 changes: 2 additions & 2 deletions EdgeCraftRAG/docs/Advanced_Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ optimum-cli export openvino -m BAAI/bge-reranker-large ${MODEL_PATH}/BAAI/bge-re
#### LLM

##### openVINO

If you have Core Ultra platform only, please prepare openVINO models:
You can also run openVINO models on discrete GPU.

Expand All @@ -51,6 +52,7 @@ optimum-cli export openvino --model Qwen/Qwen3-8B ${MODEL_PATH}/OpenVINO/Qwen3-8
```

##### vLLM

Alternatively, if you have discrete GPU and want to use vLLM, please prepare models for vLLM:

```bash
Expand Down Expand Up @@ -178,5 +180,3 @@ export TP=4 # for multi GPU, you can change TP value
export ZE_AFFINITY_MASK=0,1,2,3 # for multi GPU, you can export ZE_AFFINITY_MASK=0,1,2...
docker compose --profile b60 -f docker_compose/intel/gpu/arc/compose.yaml up -d
```


3 changes: 2 additions & 1 deletion EdgeCraftRAG/docs/Advanced_Setup_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ optimum-cli export openvino -m BAAI/bge-reranker-large ${MODEL_PATH}/BAAI/bge-re
#### LLM

##### openVINO

如果仅使用 Core Ultra 平台,请准备 openVINO 模型:
你也可以在独立 GPU 上运行 openVINO 模型。

Expand All @@ -51,6 +52,7 @@ optimum-cli export openvino --model Qwen/Qwen3-8B ${MODEL_PATH}/OpenVINO/Qwen3-8
```

##### vLLM

如果你有独立 GPU 并希望使用 vLLM,可按如下方式准备模型:

```bash
Expand Down Expand Up @@ -105,7 +107,6 @@ export MILVUS_ENABLED=0
# export CHAT_HISTORY_ROUND= # 按需修改
```


### 使用 Docker Compose 在 Intel GPU 上部署服务

#### 选项 a:为 Core Ultra / Arc B60 / Arc A770 部署基于 openVINO LLM 的 EC-RAG
Expand Down
15 changes: 7 additions & 8 deletions EdgeCraftRAG/docs/Explore_Edge_Craft_RAG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ Then, you can submit messages in the chat box in `Chat` page.
![alt text](../assets/img/Explore_Edge_Craft_RAG_08.jpg)

## ChatQnA with Kbadmin in UI

### Kbadmin Knowledge Base

Go to `Knowledge Base` page and click `Create Knowledge Base` button to create your knowledge base.
Please select 'kbadmin' in `Type`and select kb name from the kbs you created in kbadmin UI page. Loading kb name might be slow ,please wait with patient

![alt text](../assets/img/Explore_Edge_Craft_RAG_09.png)
Ten you can select embedding infomation in 'Indexer' page

Ten you can select embedding information in 'Indexer' page

![alt text](../assets/img/Explore_Edge_Craft_RAG_10.png)

After creation, you can see kbadmin tag in knowledge base then you can submit messages in the chat box in `Chat` page.
![alt text](../assets/img/Explore_Edge_Craft_RAG_11.png)

8 changes: 4 additions & 4 deletions EdgeCraftRAG/docs/Explore_Edge_Craft_RAG_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@

流水线创建完成后,前往 `Knowledge Base` 页面,点击 `Create Knowledge Base` 按钮创建知识库。
请在 `Type` 中选择 `kbadmin`,并从 kbadmin UI 页面中已创建的知识库列表中选择 kb 名称。加载kb名称可能比较耗时,请耐心等待。

![alt text](../assets/img/Explore_Edge_Craft_RAG_09.png)

在 `Indexer` 页面,填写 Embedding 服务和向量数据库信息,注意 Embedding 服务端口为 13020,向量数据库端口为 29530。

![alt text](../assets/img/Explore_Edge_Craft_RAG_10.png)

然后,在 `Chat` 页面的聊天框中提交您的问题。
![alt text](../assets/img/Explore_Edge_Craft_RAG_11.png)
6 changes: 4 additions & 2 deletions EdgeCraftRAG/edgecraftrag/api/v1/chatqna.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ async def res_gen_json():
async def context_suffix_gen():
yield '","contexts":' + json.dumps(serialize_retrievals(retrievals)) + "}"

query_gen = stream_generator('{"query":' + json.dumps(original_query, ensure_ascii=False) + ',"response":"')
query_gen = stream_generator(
'{"query":' + json.dumps(original_query, ensure_ascii=False) + ',"response":"'
)
output_gen = chain_async_generators([query_gen, res_gen_json(), context_suffix_gen()])

return StreamingResponse(output_gen, media_type="text/plain")
Expand All @@ -149,7 +151,7 @@ async def res_gen_json():
yield json.dumps(token, ensure_ascii=False)[1:-1]

# Reconstruct RagOut in stream response
query_gen = stream_generator('{"query":' + json.dumps(request.messages, ensure_ascii=False) + ',')
query_gen = stream_generator('{"query":' + json.dumps(request.messages, ensure_ascii=False) + ",")

s_contexts = json.dumps(serialize_contexts(contexts))
context_gen = stream_generator('"contexts":' + s_contexts + ',"response":"')
Expand Down
Loading
Loading