translated docstrings to english and enhanced the webui

This commit is contained in:
Saifeddine ALOUI
2025-01-27 02:07:06 +01:00
parent 2cd4fc0258
commit a68aebb124
4 changed files with 475 additions and 755 deletions

View File

@@ -1789,6 +1789,11 @@ def create_app(args):
except Exception as e:
trace_exception(e)
raise HTTPException(status_code=500, detail=str(e))
@app.get("/documents", dependencies=[Depends(optional_api_key)])
async def get_status():
"""Get current system status"""
return doc_manager.indexed_files
@app.get("/health", dependencies=[Depends(optional_api_key)])
async def get_status():
@@ -1798,7 +1803,7 @@ def create_app(args):
"working_directory": str(args.working_dir),
"input_directory": str(args.input_dir),
"indexed_files": doc_manager.indexed_files,
"indexed_files_count": len(doc_manager.scan_directory()),
"indexed_files_count": len(doc_manager.indexed_files),
"configuration": {
# LLM configuration binding/host address (if applicable)/model (if applicable)
"llm_binding": args.llm_binding,
@@ -1817,16 +1822,16 @@ def create_app(args):
}
# webui mount /webui/index.html
app.mount(
"/webui",
StaticFiles(
directory=Path(__file__).resolve().parent / "webui" / "static", html=True
),
name="webui_static",
)
# app.mount(
# "/webui",
# StaticFiles(
# directory=Path(__file__).resolve().parent / "webui" / "static", html=True
# ),
# name="webui_static",
# )
# Serve the static files
static_dir = Path(__file__).parent / "static"
static_dir = Path(__file__).parent / "static"
static_dir.mkdir(exist_ok=True)
app.mount("/", StaticFiles(directory=static_dir, html=True), name="static")

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,4 @@
// lightrag.js
// Modify according to the actual API address
const API_BASE = 'http://localhost:9621';
// init
function initializeApp() {
setupFileUpload();
@@ -37,7 +34,7 @@ async function apiRequest(endpoint, method = 'GET', body = null) {
}
try {
const response = await fetch(`${API_BASE}${endpoint}`, options);
const response = await fetch(`${endpoint}`, options);
if (!response.ok) {
throw new Error(`request failed: ${response.status}`);
}
@@ -72,7 +69,7 @@ async function handleTextUpload() {
...(description && {description})
};
const response = await fetch(`${API_BASE}/documents/text`, {
const response = await fetch(`/documents/text`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -154,7 +151,7 @@ async function handleFiles(files) {
statusDiv.textContent = '';
try {
showStatus('loading', 'UPLOADING...', statusDiv);
const response = await fetch(`${API_BASE}/documents/upload`, {
const response = await fetch(`/documents/upload`, {
method: 'POST',
body: formData
});
@@ -213,7 +210,7 @@ async function handleQuery() {
// handle stream api
async function handleStreamingQuery(payload, resultsDiv) {
try {
const response = await fetch(`${API_BASE}/query/stream`, {
const response = await fetch(`/query/stream`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(payload)
@@ -313,7 +310,7 @@ async function handleChat(chatInput) {
chatHistory.scrollTop = chatHistory.scrollHeight;
try {
const response = await fetch(`${API_BASE}/api/chat`, {
const response = await fetch(`/api/chat`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({