Added optional Azure configuration
Browse files- .env.example +10 -0
- lightrag/api/lightrag_server.py +64 -0
.env.example
CHANGED
@@ -35,3 +35,13 @@ LOG_LEVEL=INFO
|
|
35 |
|
36 |
# Optional Timeout
|
37 |
#TIMEOUT=30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
# Optional Timeout
|
37 |
#TIMEOUT=30
|
38 |
+
|
39 |
+
|
40 |
+
# Optional for Azure
|
41 |
+
# AZURE_OPENAI_API_VERSION=2024-08-01-preview
|
42 |
+
# AZURE_OPENAI_DEPLOYMENT=gpt-4o
|
43 |
+
# AZURE_OPENAI_API_KEY=myapikey
|
44 |
+
# AZURE_OPENAI_ENDPOINT=https://myendpoint.openai.azure.com
|
45 |
+
|
46 |
+
# AZURE_EMBEDDING_DEPLOYMENT=text-embedding-3-large
|
47 |
+
# AZURE_EMBEDDING_API_VERSION=2023-05-15
|
lightrag/api/lightrag_server.py
CHANGED
@@ -141,6 +141,70 @@ def display_splash_screen(args: argparse.Namespace) -> None:
|
|
141 |
# Server Status
|
142 |
ASCIIColors.green("\n⨠Server starting up...\n")
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
|
146 |
def parse_args() -> argparse.Namespace:
|
|
|
141 |
# Server Status
|
142 |
ASCIIColors.green("\n⨠Server starting up...\n")
|
143 |
|
144 |
+
# Server Access Information
|
145 |
+
protocol = "https" if args.ssl else "http"
|
146 |
+
if args.host == "0.0.0.0":
|
147 |
+
ASCIIColors.magenta("\nπ Server Access Information:")
|
148 |
+
ASCIIColors.white(" ββ Local Access: ", end="")
|
149 |
+
ASCIIColors.yellow(f"{protocol}://localhost:{args.port}")
|
150 |
+
ASCIIColors.white(" ββ Remote Access: ", end="")
|
151 |
+
ASCIIColors.yellow(f"{protocol}://<your-ip-address>:{args.port}")
|
152 |
+
ASCIIColors.white(" ββ API Documentation (local): ", end="")
|
153 |
+
ASCIIColors.yellow(f"{protocol}://localhost:{args.port}/docs")
|
154 |
+
ASCIIColors.white(" ββ Alternative Documentation (local): ", end="")
|
155 |
+
ASCIIColors.yellow(f"{protocol}://localhost:{args.port}/redoc")
|
156 |
+
|
157 |
+
ASCIIColors.yellow("\nπ Note:")
|
158 |
+
ASCIIColors.white(""" Since the server is running on 0.0.0.0:
|
159 |
+
- Use 'localhost' or '127.0.0.1' for local access
|
160 |
+
- Use your machine's IP address for remote access
|
161 |
+
- To find your IP address:
|
162 |
+
β’ Windows: Run 'ipconfig' in terminal
|
163 |
+
β’ Linux/Mac: Run 'ifconfig' or 'ip addr' in terminal
|
164 |
+
""")
|
165 |
+
else:
|
166 |
+
base_url = f"{protocol}://{args.host}:{args.port}"
|
167 |
+
ASCIIColors.magenta("\nπ Server Access Information:")
|
168 |
+
ASCIIColors.white(" ββ Base URL: ", end="")
|
169 |
+
ASCIIColors.yellow(f"{base_url}")
|
170 |
+
ASCIIColors.white(" ββ API Documentation: ", end="")
|
171 |
+
ASCIIColors.yellow(f"{base_url}/docs")
|
172 |
+
ASCIIColors.white(" ββ Alternative Documentation: ", end="")
|
173 |
+
ASCIIColors.yellow(f"{base_url}/redoc")
|
174 |
+
|
175 |
+
# Usage Examples
|
176 |
+
ASCIIColors.magenta("\nπ Quick Start Guide:")
|
177 |
+
ASCIIColors.cyan("""
|
178 |
+
1. Access the Swagger UI:
|
179 |
+
Open your browser and navigate to the API documentation URL above
|
180 |
+
|
181 |
+
2. API Authentication:""")
|
182 |
+
if args.key:
|
183 |
+
ASCIIColors.cyan(""" Add the following header to your requests:
|
184 |
+
X-API-Key: <your-api-key>
|
185 |
+
""")
|
186 |
+
else:
|
187 |
+
ASCIIColors.cyan(" No authentication required\n")
|
188 |
+
|
189 |
+
ASCIIColors.cyan(""" 3. Basic Operations:
|
190 |
+
- POST /upload_document: Upload new documents to RAG
|
191 |
+
- POST /query: Query your document collection
|
192 |
+
- GET /collections: List available collections
|
193 |
+
|
194 |
+
4. Monitor the server:
|
195 |
+
- Check server logs for detailed operation information
|
196 |
+
- Use healthcheck endpoint: GET /health
|
197 |
+
""")
|
198 |
+
|
199 |
+
# Security Notice
|
200 |
+
if args.key:
|
201 |
+
ASCIIColors.yellow("\nβ οΈ Security Notice:")
|
202 |
+
ASCIIColors.white(""" API Key authentication is enabled.
|
203 |
+
Make sure to include the X-API-Key header in all your requests.
|
204 |
+
""")
|
205 |
+
|
206 |
+
ASCIIColors.green("Server is ready to accept connections! π\n")
|
207 |
+
|
208 |
|
209 |
|
210 |
def parse_args() -> argparse.Namespace:
|