Added api version and Configuration details at startup as well as more useful information
Browse files- lightrag/api/__init__.py +1 -0
- lightrag/api/lightrag_server.py +85 -2
lightrag/api/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__api_version__ = "1.0.0"
|
lightrag/api/lightrag_server.py
CHANGED
@@ -7,6 +7,7 @@ from lightrag.llm import lollms_model_complete, lollms_embed
|
|
7 |
from lightrag.llm import ollama_model_complete, ollama_embed
|
8 |
from lightrag.llm import openai_complete_if_cache, openai_embedding
|
9 |
from lightrag.llm import azure_openai_complete_if_cache, azure_openai_embedding
|
|
|
10 |
|
11 |
from lightrag.utils import EmbeddingFunc
|
12 |
from typing import Optional, List, Union, Any
|
@@ -14,7 +15,7 @@ from enum import Enum
|
|
14 |
from pathlib import Path
|
15 |
import shutil
|
16 |
import aiofiles
|
17 |
-
from ascii_colors import trace_exception
|
18 |
import os
|
19 |
|
20 |
from fastapi import Depends, Security
|
@@ -63,6 +64,85 @@ def get_env_value(env_key: str, default: Any, value_type: type = str) -> Any:
|
|
63 |
except ValueError:
|
64 |
return default
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
def parse_args() -> argparse.Namespace:
|
67 |
"""
|
68 |
Parse command line arguments with environment variable fallback
|
@@ -216,7 +296,10 @@ def parse_args() -> argparse.Namespace:
|
|
216 |
help="Path to SSL private key file (required if --ssl is enabled)",
|
217 |
)
|
218 |
|
219 |
-
|
|
|
|
|
|
|
220 |
|
221 |
|
222 |
class DocumentManager:
|
|
|
7 |
from lightrag.llm import ollama_model_complete, ollama_embed
|
8 |
from lightrag.llm import openai_complete_if_cache, openai_embedding
|
9 |
from lightrag.llm import azure_openai_complete_if_cache, azure_openai_embedding
|
10 |
+
from lightrag.api import __api_version__
|
11 |
|
12 |
from lightrag.utils import EmbeddingFunc
|
13 |
from typing import Optional, List, Union, Any
|
|
|
15 |
from pathlib import Path
|
16 |
import shutil
|
17 |
import aiofiles
|
18 |
+
from ascii_colors import trace_exception, ASCIIColors
|
19 |
import os
|
20 |
|
21 |
from fastapi import Depends, Security
|
|
|
64 |
except ValueError:
|
65 |
return default
|
66 |
|
67 |
+
def display_splash_screen(args: argparse.Namespace) -> None:
|
68 |
+
"""
|
69 |
+
Display a colorful splash screen showing LightRAG server configuration
|
70 |
+
|
71 |
+
Args:
|
72 |
+
args: Parsed command line arguments
|
73 |
+
"""
|
74 |
+
# Banner
|
75 |
+
ASCIIColors.cyan(f"""
|
76 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
77 |
+
β π LightRAG Server v{__api_version__} β
|
78 |
+
β Fast, Lightweight RAG Server Implementation β
|
79 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
80 |
+
""")
|
81 |
+
|
82 |
+
# Server Configuration
|
83 |
+
ASCIIColors.magenta("\nπ‘ Server Configuration:")
|
84 |
+
ASCIIColors.white(f" ββ Host: ", end="")
|
85 |
+
ASCIIColors.yellow(f"{args.host}")
|
86 |
+
ASCIIColors.white(f" ββ Port: ", end="")
|
87 |
+
ASCIIColors.yellow(f"{args.port}")
|
88 |
+
ASCIIColors.white(f" ββ SSL Enabled: ", end="")
|
89 |
+
ASCIIColors.yellow(f"{args.ssl}")
|
90 |
+
if args.ssl:
|
91 |
+
ASCIIColors.white(f" ββ SSL Cert: ", end="")
|
92 |
+
ASCIIColors.yellow(f"{args.ssl_certfile}")
|
93 |
+
ASCIIColors.white(f" ββ SSL Key: ", end="")
|
94 |
+
ASCIIColors.yellow(f"{args.ssl_keyfile}")
|
95 |
+
|
96 |
+
# Directory Configuration
|
97 |
+
ASCIIColors.magenta("\nπ Directory Configuration:")
|
98 |
+
ASCIIColors.white(f" ββ Working Directory: ", end="")
|
99 |
+
ASCIIColors.yellow(f"{args.working_dir}")
|
100 |
+
ASCIIColors.white(f" ββ Input Directory: ", end="")
|
101 |
+
ASCIIColors.yellow(f"{args.input_dir}")
|
102 |
+
|
103 |
+
# LLM Configuration
|
104 |
+
ASCIIColors.magenta("\nπ€ LLM Configuration:")
|
105 |
+
ASCIIColors.white(f" ββ Binding: ", end="")
|
106 |
+
ASCIIColors.yellow(f"{args.llm_binding}")
|
107 |
+
ASCIIColors.white(f" ββ Host: ", end="")
|
108 |
+
ASCIIColors.yellow(f"{args.llm_binding_host}")
|
109 |
+
ASCIIColors.white(f" ββ Model: ", end="")
|
110 |
+
ASCIIColors.yellow(f"{args.llm_model}")
|
111 |
+
|
112 |
+
# Embedding Configuration
|
113 |
+
ASCIIColors.magenta("\nπ Embedding Configuration:")
|
114 |
+
ASCIIColors.white(f" ββ Binding: ", end="")
|
115 |
+
ASCIIColors.yellow(f"{args.embedding_binding}")
|
116 |
+
ASCIIColors.white(f" ββ Host: ", end="")
|
117 |
+
ASCIIColors.yellow(f"{args.embedding_binding_host}")
|
118 |
+
ASCIIColors.white(f" ββ Model: ", end="")
|
119 |
+
ASCIIColors.yellow(f"{args.embedding_model}")
|
120 |
+
ASCIIColors.white(f" ββ Dimensions: ", end="")
|
121 |
+
ASCIIColors.yellow(f"{args.embedding_dim}")
|
122 |
+
|
123 |
+
# RAG Configuration
|
124 |
+
ASCIIColors.magenta("\nβοΈ RAG Configuration:")
|
125 |
+
ASCIIColors.white(f" ββ Max Async Operations: ", end="")
|
126 |
+
ASCIIColors.yellow(f"{args.max_async}")
|
127 |
+
ASCIIColors.white(f" ββ Max Tokens: ", end="")
|
128 |
+
ASCIIColors.yellow(f"{args.max_tokens}")
|
129 |
+
ASCIIColors.white(f" ββ Max Embed Tokens: ", end="")
|
130 |
+
ASCIIColors.yellow(f"{args.max_embed_tokens}")
|
131 |
+
|
132 |
+
# System Configuration
|
133 |
+
ASCIIColors.magenta("\nπ οΈ System Configuration:")
|
134 |
+
ASCIIColors.white(f" ββ Log Level: ", end="")
|
135 |
+
ASCIIColors.yellow(f"{args.log_level}")
|
136 |
+
ASCIIColors.white(f" ββ Timeout: ", end="")
|
137 |
+
ASCIIColors.yellow(f"{args.timeout if args.timeout else 'None (infinite)'}")
|
138 |
+
ASCIIColors.white(f" ββ API Key: ", end="")
|
139 |
+
ASCIIColors.yellow("Set" if args.key else "Not Set")
|
140 |
+
|
141 |
+
# Server Status
|
142 |
+
ASCIIColors.green("\n⨠Server starting up...\n")
|
143 |
+
|
144 |
+
|
145 |
+
|
146 |
def parse_args() -> argparse.Namespace:
|
147 |
"""
|
148 |
Parse command line arguments with environment variable fallback
|
|
|
296 |
help="Path to SSL private key file (required if --ssl is enabled)",
|
297 |
)
|
298 |
|
299 |
+
args = parser.parse_args()
|
300 |
+
display_splash_screen(args)
|
301 |
+
|
302 |
+
return args
|
303 |
|
304 |
|
305 |
class DocumentManager:
|