Skip to content

Commit 74a765a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2d35e31 commit 74a765a

37 files changed

+303
-259
lines changed

EdgeCraftRAG/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ docker pull intelanalytics/ipex-llm-serving-xpu:0.8.3-b18
110110
```
111111

112112
Generate your nginx config file
113+
113114
```bash
114115
export HOST_IP=#your host ip
115116
export NGINX_PORT=8086 #set port for nginx
@@ -149,6 +150,7 @@ export SELECTED_XPU_1=<which GPU to select to run for container 1>
149150
```
150151
151152
start with compose_vllm_multi-arc.yaml
153+
152154
```bash
153155
docker compose -f docker_compose/intel/gpu/arc/compose_vllm_multi-arc.yaml --profile ${CONTAINER_COUNT} up -d
154156
```

EdgeCraftRAG/chatqna.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def add_remote_service(self):
4343
async def handle_request(self, request: Request):
4444
input = await request.json()
4545
stream_opt = input.get("stream", False)
46-
input["user"] = request.headers.get("sessionid",None)
46+
input["user"] = request.headers.get("sessionid", None)
4747
chat_request = ChatCompletionRequest.parse_obj(input)
4848
parameters = LLMParams(
4949
max_tokens=chat_request.max_tokens if chat_request.max_tokens else 1024,

EdgeCraftRAG/docker_compose/intel/gpu/arc/compose_vllm_multi-arc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
3-
3+
44
services:
55
server:
66
image: ${REGISTRY:-opea}/edgecraftrag-server:${TAG:-latest}
@@ -150,4 +150,4 @@ services:
150150
- multi_container
151151
networks:
152152
default:
153-
driver: bridge
153+
driver: bridge

EdgeCraftRAG/docker_compose/intel/gpu/arc/set_env.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ export NGINX_CONFIG_PATH=${NGINX_CONFIG_PATH}
2525
export SELECTED_XPU_0=${SELECTED_XPU_0}
2626
export SELECTED_XPU_1=${SELECTED_XPU_1}
2727
export vLLM_ENDPOINT=${vLLM_ENDPOINT}
28-

EdgeCraftRAG/edgecraftrag/api/v1/chatqna.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ async def ragqna(request: ChatCompletionRequest):
6363
ragout = RagOut(query=request.messages, contexts=serialized_contexts, response=str(res))
6464
return ragout
6565
except Exception as e:
66-
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))
66+
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))

EdgeCraftRAG/edgecraftrag/api/v1/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async def delete_file(name):
9595

9696
# Upload & save a file from UI
9797
@data_app.post(path="/v1/data/file/{file_name}")
98-
async def upload_file(file_name: str,file: UploadFile = File(...)):
98+
async def upload_file(file_name: str, file: UploadFile = File(...)):
9999
if ctx.get_pipeline_mgr().get_active_pipeline() is None:
100100
raise HTTPException(
101101
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Please activate pipeline and upload the file"

EdgeCraftRAG/edgecraftrag/api/v1/knowledge_base.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
from fastapi import FastAPI, HTTPException,status
2-
from edgecraftrag.context import ctx
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import os
5+
36
from edgecraftrag.api.v1.data import add_data
47
from edgecraftrag.api_schema import DataIn, KnowledgeBaseCreateIn
5-
import os
8+
from edgecraftrag.context import ctx
9+
from fastapi import FastAPI, HTTPException, status
610

711
kb_app = FastAPI()
812

@@ -23,11 +27,11 @@ async def get_knowledge_base(knowledge_name: str):
2327
return kb
2428

2529

26-
# Create a new knowledge base
30+
# Create a new knowledge base
2731
@kb_app.post(path="/v1/knowledge")
2832
async def create_knowledge_base(knowledge: KnowledgeBaseCreateIn):
2933
try:
30-
kb = ctx.knowledgemgr.create_knowledge_base(knowledge)
34+
kb = ctx.knowledgemgr.create_knowledge_base(knowledge)
3135
if kb.active:
3236
await update_knowledge_base_handler(kb.get_file_paths())
3337
return "Create knowledge base successfully"
@@ -60,48 +64,48 @@ async def update_knowledge_base(knowledge: KnowledgeBaseCreateIn):
6064

6165
# Add a files to the knowledge base
6266
@kb_app.post(path="/v1/knowledge/{knowledge_name}/files")
63-
async def add_file_to_knowledge_base(knowledge_name ,file_path: DataIn):
67+
async def add_file_to_knowledge_base(knowledge_name, file_path: DataIn):
6468
try:
6569
kb = ctx.knowledgemgr.get_knowledge_base_by_name_or_id(knowledge_name)
66-
if os.path.isdir(file_path.local_path) :
70+
if os.path.isdir(file_path.local_path):
6771
for root, _, files in os.walk(file_path.local_path):
6872
for file in files:
6973
file_full_path = os.path.join(root, file)
7074
if file_full_path not in kb.get_file_paths():
7175
kb.add_file_path(file_full_path)
7276
else:
7377
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="File upload failed")
74-
elif os.path.isfile(file_path.local_path) and file_path.local_path not in kb.get_file_paths():
78+
elif os.path.isfile(file_path.local_path) and file_path.local_path not in kb.get_file_paths():
7579
kb.add_file_path(file_path.local_path)
7680
else:
7781
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="File upload failed")
78-
82+
7983
active_kb = ctx.knowledgemgr.get_active_knowledge_base()
8084
if active_kb:
81-
if active_kb.name == knowledge_name or active_kb.idx == knowledge_name:
85+
if active_kb.name == knowledge_name or active_kb.idx == knowledge_name:
8286
await update_knowledge_base_handler(file_path, add_file=True)
8387

84-
return "File upload successfully"
88+
return "File upload successfully"
8589
except ValueError as e:
8690
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e))
8791

8892

8993
# Remove a file from the knowledge base
9094
@kb_app.delete(path="/v1/knowledge/{knowledge_name}/files")
91-
async def remove_file_from_knowledge_base(knowledge_name ,file_path: DataIn):
95+
async def remove_file_from_knowledge_base(knowledge_name, file_path: DataIn):
9296
try:
9397
kb = ctx.knowledgemgr.get_knowledge_base_by_name_or_id(knowledge_name)
94-
if file_path.local_path in kb.get_file_paths():
98+
if file_path.local_path in kb.get_file_paths():
9599
kb.remove_file_path(file_path.local_path)
96100
else:
97101
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="File remove failure")
98102

99103
file_path = kb.get_file_paths()
100104
active_kb = ctx.knowledgemgr.get_active_knowledge_base()
101105
if active_kb:
102-
if active_kb.name == knowledge_name or active_kb.idx == knowledge_name:
106+
if active_kb.name == knowledge_name or active_kb.idx == knowledge_name:
103107
await update_knowledge_base_handler(file_path)
104-
return f"File deleted successfully"
108+
return "File deleted successfully"
105109
except ValueError as e:
106110
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e))
107111

@@ -110,10 +114,10 @@ async def remove_file_from_knowledge_base(knowledge_name ,file_path: DataIn):
110114
async def update_knowledge_base_handler(file_path=None, add_file: bool = False):
111115
if ctx.get_pipeline_mgr().get_active_pipeline() is None:
112116
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Please activate pipeline")
113-
117+
114118
if add_file and file_path:
115119
return await add_data(file_path)
116-
120+
117121
elif file_path:
118122
pl = ctx.get_pipeline_mgr().get_active_pipeline()
119123
ctx.get_node_mgr().del_nodes_by_np_idx(pl.node_parser.idx)
@@ -123,10 +127,10 @@ async def update_knowledge_base_handler(file_path=None, add_file: bool = False):
123127
request = DataIn(local_path=file)
124128
await add_data(request)
125129
return "Done"
126-
130+
127131
else:
128132
pl = ctx.get_pipeline_mgr().get_active_pipeline()
129133
ctx.get_node_mgr().del_nodes_by_np_idx(pl.node_parser.idx)
130134
pl.indexer.reinitialize_indexer()
131135
pl.update_indexer_to_retriever()
132-
return "Done"
136+
return "Done"

EdgeCraftRAG/edgecraftrag/api/v1/prompt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
from edgecraftrag.api_schema import PromptIn
15
from edgecraftrag.context import ctx
26
from fastapi import FastAPI, File, HTTPException, UploadFile, status
3-
from edgecraftrag.api_schema import PromptIn
47

58
prompt_app = FastAPI()
69

@@ -52,4 +55,4 @@ async def reset_prompt():
5255
generator.reset_prompt()
5356
return "Reset LLM Prompt Successfully"
5457
except Exception as e:
55-
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))
58+
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))

EdgeCraftRAG/edgecraftrag/api_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4-
from typing import Optional, Any
4+
from typing import Any, Optional
55

66
from pydantic import BaseModel
77

@@ -76,4 +76,4 @@ class PromptIn(BaseModel):
7676
class KnowledgeBaseCreateIn(BaseModel):
7777
name: str
7878
description: Optional[str] = None
79-
active: Optional[bool] = None
79+
active: Optional[bool] = None

EdgeCraftRAG/edgecraftrag/components/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def convert_text_to_documents(text) -> List[Document]:
5454
def convert_file_to_documents(file_path) -> List[Document]:
5555
from llama_index.core import SimpleDirectoryReader
5656

57-
supported_exts = [".pdf", ".txt", ".doc", ".docx", ".pptx", ".ppt", ".csv", ".md", ".html", ".rst",".epub"]
57+
supported_exts = [".pdf", ".txt", ".doc", ".docx", ".pptx", ".ppt", ".csv", ".md", ".html", ".rst", ".epub"]
5858
if file_path.is_dir():
5959
docs = SimpleDirectoryReader(input_dir=file_path, recursive=True, required_exts=supported_exts).load_data()
6060
elif file_path.is_file():

0 commit comments

Comments
 (0)