Skip to content

Commit e47ebb3

Browse files
committed
Add ManufacturingAgentSuite example
Add a minimal OPEA manufacturing reference package with compose profiles, smoke tests, benchmark documentation, and CI-compatible lint fixes. Signed-off-by: Ryan Hui <ryan.on2008@gmail.com>
1 parent f564226 commit e47ebb3

55 files changed

Lines changed: 1072 additions & 427 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ repos:
8282
rev: v1.7.7
8383
hooks:
8484
- id: docformatter
85+
language_version: python3.12
8586
args: [
8687
--in-place,
8788
--wrap-summaries=0, # 0 means disable wrap

EdgeCraftRAG/cli/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,14 @@ The CLI will display error messages from the API in JSON format. Network errors
329329
## Tips
330330

331331
- Use `--help` with any command to see detailed help:
332+
332333
```bash
333334
ecrag pipeline --help
334335
ecrag pipeline create --help
335336
```
336337

337338
- Pipe JSON output to other tools:
339+
338340
```bash
339341
ecrag kb list | jq '.[]' | head -n 20
340342
```

EdgeCraftRAG/cli/client.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
import json
5-
import requests
6-
from typing import Optional, Dict, Any
5+
from typing import Any, Dict, Optional
76
from urllib.parse import urljoin
87

8+
import requests
9+
910

1011
class EcragApiClient:
1112
"""API client for Edge Craft RAG."""
1213

1314
def __init__(self, host: str = "http://localhost", server_port: int = 16010, mega_port: int = 16011):
1415
"""Initialize the API client.
15-
16+
1617
Args:
1718
host: The host URL (default: http://localhost)
1819
server_port: The server port (default: 16010)
@@ -21,10 +22,10 @@ def __init__(self, host: str = "http://localhost", server_port: int = 16010, meg
2122
# Normalize host URL
2223
if not host.startswith(("http://", "https://")):
2324
host = f"http://{host}"
24-
25+
2526
# Remove trailing slash if present
2627
host = host.rstrip("/")
27-
28+
2829
self.server_url = f"{host}:{server_port}"
2930
self.mega_url = f"{host}:{mega_port}"
3031

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

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

180185
# Experience Management
181186
def get_experiences(self) -> Dict[str, Any]:

EdgeCraftRAG/cli/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
3-
43
"""Configuration for EdgeCraft RAG CLI."""
54

65
import os

EdgeCraftRAG/cli/main.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
import json
5-
import click
65
import os
76
from pathlib import Path
87
from typing import Optional
8+
9+
import click
910
from cli.client import EcragApiClient
1011
from cli.config import get_config
1112

@@ -34,26 +35,26 @@ def run_chatqna_query(client: EcragApiClient, query: str, top_n: int, max_tokens
3435
@click.pass_context
3536
def cli(ctx, host: Optional[str], port: Optional[int], mega_port: Optional[int]):
3637
"""EdgeCraft RAG CLI Tool.
37-
38+
3839
Configure server connection via command-line options or environment variables:
3940
- ECRAG_HOST: Server host (default: http://localhost)
4041
- ECRAG_PORT: Server port (default: 16010)
4142
- ECRAG_MEGA_PORT: Mega service port (default: 16011)
4243
"""
4344
ctx.ensure_object(dict)
44-
45+
4546
# Get defaults from config
4647
config = get_config()
47-
48+
4849
# Use provided options or environment/defaults
4950
final_host = host or config.host
5051
final_port = port or config.port
5152
final_mega_port = mega_port or config.mega_port
52-
53+
5354
# Normalize host URL
5455
if not final_host.startswith(("http://", "https://")):
5556
final_host = f"http://{final_host}"
56-
57+
5758
ctx.obj["client"] = EcragApiClient(host=final_host, server_port=final_port, mega_port=final_mega_port)
5859

5960

@@ -204,7 +205,7 @@ def load(ctx, model_type: str, model_id: str, model_path: str, device: str, weig
204205

205206
@model.command()
206207
@click.pass_context
207-
def list(ctx):
208+
def list(ctx): # noqa: F811
208209
"""List all models."""
209210
client = ctx.obj["client"]
210211
result = client.get_models()
@@ -214,7 +215,7 @@ def list(ctx):
214215
@model.command()
215216
@click.option("--id", "model_id", required=True, help="Model ID")
216217
@click.pass_context
217-
def get(ctx, model_id: str):
218+
def get(ctx, model_id: str): # noqa: F811
218219
"""Get a specific model."""
219220
client = ctx.obj["client"]
220221
result = client.get_model(model_id)
@@ -241,7 +242,7 @@ def update(ctx, model_id: str, device: Optional[str], weight: Optional[str]):
241242
@model.command()
242243
@click.option("--id", "model_id", required=True, help="Model ID")
243244
@click.pass_context
244-
def delete(ctx, model_id: str):
245+
def delete(ctx, model_id: str): # noqa: F811
245246
"""Delete a model."""
246247
client = ctx.obj["client"]
247248
if click.confirm(f"Are you sure you want to delete model '{model_id}'?"):
@@ -284,7 +285,7 @@ def kb():
284285
@click.option("--description", help="Knowledge base description")
285286
@click.option("-f", "--file", type=click.Path(exists=True), help="KB config JSON file")
286287
@click.pass_context
287-
def create(ctx, name: str, description: Optional[str], file: Optional[str]):
288+
def create(ctx, name: str, description: Optional[str], file: Optional[str]): # noqa: F811
288289
"""Create a knowledge base."""
289290
client = ctx.obj["client"]
290291

@@ -302,7 +303,7 @@ def create(ctx, name: str, description: Optional[str], file: Optional[str]):
302303

303304
@kb.command()
304305
@click.pass_context
305-
def list(ctx):
306+
def list(ctx): # noqa: F811
306307
"""List all knowledge bases."""
307308
client = ctx.obj["client"]
308309
result = client.get_knowledge_bases()
@@ -312,7 +313,7 @@ def list(ctx):
312313
@kb.command()
313314
@click.option("-n", "--name", required=True, help="Knowledge base name")
314315
@click.pass_context
315-
def get(ctx, name: str):
316+
def get(ctx, name: str): # noqa: F811
316317
"""Get a specific knowledge base."""
317318
client = ctx.obj["client"]
318319
result = client.get_knowledge_base(name)
@@ -322,7 +323,7 @@ def get(ctx, name: str):
322323
@kb.command()
323324
@click.option("-n", "--name", required=True, help="Knowledge base name")
324325
@click.pass_context
325-
def get_json(ctx, name: str):
326+
def get_json(ctx, name: str): # noqa: F811
326327
"""Get knowledge base JSON data."""
327328
client = ctx.obj["client"]
328329
result = client.get_knowledge_base_json(name)
@@ -346,7 +347,7 @@ def filemap(ctx, name: str, page_num: int, page_size: int):
346347
@click.option("--active", type=bool, help="Set active status")
347348
@click.option("--description", help="Update description")
348349
@click.pass_context
349-
def update(ctx, name: str, active: Optional[bool], description: Optional[str]):
350+
def update(ctx, name: str, active: Optional[bool], description: Optional[str]): # noqa: F811
350351
"""Update a knowledge base."""
351352
client = ctx.obj["client"]
352353
kb_data = {"name": name}
@@ -361,7 +362,7 @@ def update(ctx, name: str, active: Optional[bool], description: Optional[str]):
361362
@kb.command()
362363
@click.option("-n", "--name", required=True, help="Knowledge base name")
363364
@click.pass_context
364-
def delete(ctx, name: str):
365+
def delete(ctx, name: str): # noqa: F811
365366
"""Delete a knowledge base."""
366367
client = ctx.obj["client"]
367368
if click.confirm(f"Are you sure you want to delete knowledge base '{name}'?"):
@@ -402,7 +403,7 @@ def experience():
402403

403404
@experience.command()
404405
@click.pass_context
405-
def list(ctx):
406+
def list(ctx): # noqa: F811
406407
"""List all experiences."""
407408
client = ctx.obj["client"]
408409
result = client.get_experiences()
@@ -412,7 +413,7 @@ def list(ctx):
412413
@experience.command()
413414
@click.option("--id", required=True, help="Experience ID")
414415
@click.pass_context
415-
def get(ctx, id: str):
416+
def get(ctx, id: str): # noqa: F811
416417
"""Get a specific experience."""
417418
client = ctx.obj["client"]
418419
result = client.get_experience(id)
@@ -424,7 +425,7 @@ def get(ctx, id: str):
424425
@click.option("--question", required=True, help="Question")
425426
@click.option("--content", multiple=True, required=True, help="Answer content")
426427
@click.pass_context
427-
def create(ctx, id: str, question: str, content: tuple):
428+
def create(ctx, id: str, question: str, content: tuple): # noqa: F811
428429
"""Create or update an experience."""
429430
client = ctx.obj["client"]
430431
exp_data = {"idx": id, "question": question, "content": list(content)}
@@ -435,7 +436,7 @@ def create(ctx, id: str, question: str, content: tuple):
435436
@experience.command()
436437
@click.option("--id", required=True, help="Experience ID")
437438
@click.pass_context
438-
def delete(ctx, id: str):
439+
def delete(ctx, id: str): # noqa: F811
439440
"""Delete an experience."""
440441
client = ctx.obj["client"]
441442
if click.confirm(f"Are you sure you want to delete experience '{id}'?"):
@@ -464,7 +465,7 @@ def agent():
464465

465466
@agent.command()
466467
@click.pass_context
467-
def list(ctx):
468+
def list(ctx): # noqa: F811
468469
"""List all agents."""
469470
client = ctx.obj["client"]
470471
result = client.get_agents()
@@ -474,7 +475,7 @@ def list(ctx):
474475
@agent.command()
475476
@click.option("-n", "--name", required=True, help="Agent name")
476477
@click.pass_context
477-
def get(ctx, name: str):
478+
def get(ctx, name: str): # noqa: F811
478479
"""Get a specific agent."""
479480
client = ctx.obj["client"]
480481
result = client.get_agent(name)
@@ -496,7 +497,7 @@ def configs(ctx, type: str):
496497
@click.option("--type", required=True, help="Agent type")
497498
@click.option("--pipeline", required=True, help="Pipeline index or name")
498499
@click.pass_context
499-
def create(ctx, name: str, type: str, pipeline: str):
500+
def create(ctx, name: str, type: str, pipeline: str): # noqa: F811
500501
"""Create an agent."""
501502
client = ctx.obj["client"]
502503
agent_data = {"name": name, "type": type, "pipeline_idx": pipeline}
@@ -508,7 +509,7 @@ def create(ctx, name: str, type: str, pipeline: str):
508509
@click.option("-n", "--name", required=True, help="Agent name")
509510
@click.option("--active", type=bool, help="Active status")
510511
@click.pass_context
511-
def update(ctx, name: str, active: Optional[bool]):
512+
def update(ctx, name: str, active: Optional[bool]): # noqa: F811
512513
"""Update an agent."""
513514
client = ctx.obj["client"]
514515
agent_data = {}
@@ -521,7 +522,7 @@ def update(ctx, name: str, active: Optional[bool]):
521522
@agent.command()
522523
@click.option("-n", "--name", required=True, help="Agent name")
523524
@click.pass_context
524-
def delete(ctx, name: str):
525+
def delete(ctx, name: str): # noqa: F811
525526
"""Delete an agent."""
526527
client = ctx.obj["client"]
527528
if click.confirm(f"Are you sure you want to delete agent '{name}'?"):
@@ -540,7 +541,7 @@ def prompt():
540541

541542
@prompt.command()
542543
@click.pass_context
543-
def get(ctx):
544+
def get(ctx): # noqa: F811
544545
"""Get the current system prompt."""
545546
client = ctx.obj["client"]
546547
result = client.get_prompt()
@@ -674,7 +675,7 @@ def session():
674675

675676
@session.command()
676677
@click.pass_context
677-
def list(ctx):
678+
def list(ctx): # noqa: F811
678679
"""List all sessions."""
679680
client = ctx.obj["client"]
680681
result = client.get_sessions()
@@ -684,7 +685,7 @@ def list(ctx):
684685
@session.command()
685686
@click.option("--id", required=True, help="Session ID")
686687
@click.pass_context
687-
def get(ctx, id: str):
688+
def get(ctx, id: str): # noqa: F811
688689
"""Get a specific session."""
689690
client = ctx.obj["client"]
690691
result = client.get_session(id)

EdgeCraftRAG/cli/quickstart.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
3-
43
"""Quick start guide for EdgeCraft RAG CLI."""
54

65
import json
76
import sys
7+
88
from cli.client import EcragApiClient
99

1010

1111
def test_connection(host: str = "http://localhost", port: int = 16010):
1212
"""Test connection to EdgeCraft RAG server."""
1313
client = EcragApiClient(host=host, server_port=port)
14-
14+
1515
try:
1616
print(f"Testing connection to {client.server_url}...")
1717
result = client.get_system_info()
18-
18+
1919
if "error" in result:
2020
print(f"❌ Connection failed: {result['error']}")
2121
return False
22-
22+
2323
print("✓ Connection successful!")
2424
print(f" System Info: {json.dumps(result, indent=2)}")
2525
return True
@@ -62,7 +62,7 @@ def quick_start_guide():
6262
export ECRAG_MEGA_PORT=16011
6363
6464
COMMON COMMANDS:
65-
65+
6666
Pipeline Management:
6767
ecrag pipeline list
6868
ecrag pipeline get --name <name>

EdgeCraftRAG/cli/setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#!/usr/bin/env python3
22
# Copyright (C) 2024 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
4-
54
"""Canonical setup script for EdgeCraft RAG CLI."""
65

76
from setuptools import setup
87

9-
108
setup(
119
name="ecrag-cli",
1210
version="0.1.0",
@@ -35,4 +33,4 @@
3533
"Programming Language :: Python :: 3.10",
3634
"Programming Language :: Python :: 3.11",
3735
],
38-
)
36+
)

0 commit comments

Comments
 (0)