agent-api-server 2.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_api_server/__init__.py +0 -0
- agent_api_server/api/__init__.py +0 -0
- agent_api_server/api/v1/__init__.py +0 -0
- agent_api_server/api/v1/api.py +25 -0
- agent_api_server/api/v1/config.py +57 -0
- agent_api_server/api/v1/graph.py +59 -0
- agent_api_server/api/v1/schema.py +57 -0
- agent_api_server/api/v1/thread.py +563 -0
- agent_api_server/cache/__init__.py +0 -0
- agent_api_server/cache/redis_cache.py +385 -0
- agent_api_server/callback_handler.py +18 -0
- agent_api_server/client/css/styles.css +1202 -0
- agent_api_server/client/favicon.ico +0 -0
- agent_api_server/client/index.html +102 -0
- agent_api_server/client/js/app.js +1499 -0
- agent_api_server/client/js/index.umd.js +824 -0
- agent_api_server/config_center/config_center.py +239 -0
- agent_api_server/configs/__init__.py +3 -0
- agent_api_server/configs/config.py +163 -0
- agent_api_server/dynamic_llm/__init__.py +0 -0
- agent_api_server/dynamic_llm/dynamic_llm.py +331 -0
- agent_api_server/listener.py +530 -0
- agent_api_server/log/__init__.py +0 -0
- agent_api_server/log/formatters.py +122 -0
- agent_api_server/log/logging.json +50 -0
- agent_api_server/mcp_convert/__init__.py +0 -0
- agent_api_server/mcp_convert/mcp_convert.py +375 -0
- agent_api_server/memeory/__init__.py +0 -0
- agent_api_server/memeory/postgres.py +233 -0
- agent_api_server/register/__init__.py +0 -0
- agent_api_server/register/register.py +65 -0
- agent_api_server/service.py +354 -0
- agent_api_server/service_hub/service_hub.py +233 -0
- agent_api_server/service_hub/service_hub_test.py +700 -0
- agent_api_server/shared/__init__.py +0 -0
- agent_api_server/shared/ase.py +54 -0
- agent_api_server/shared/base_model.py +103 -0
- agent_api_server/shared/common.py +110 -0
- agent_api_server/shared/decode_token.py +107 -0
- agent_api_server/shared/detect_message.py +410 -0
- agent_api_server/shared/get_model_info.py +491 -0
- agent_api_server/shared/message.py +419 -0
- agent_api_server/shared/util_func.py +372 -0
- agent_api_server/sso_service/__init__.py +1 -0
- agent_api_server/sso_service/sdk/__init__.py +1 -0
- agent_api_server/sso_service/sdk/client.py +224 -0
- agent_api_server/sso_service/sdk/credential.py +11 -0
- agent_api_server/sso_service/sdk/encoding.py +22 -0
- agent_api_server/sso_service/sso_service.py +177 -0
- agent_api_server-2.1.7.dist-info/METADATA +130 -0
- agent_api_server-2.1.7.dist-info/RECORD +52 -0
- agent_api_server-2.1.7.dist-info/WHEEL +4 -0
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from fastapi import APIRouter
|
|
3
|
+
from agent_api_server.api.v1.schema import api_router as schema_router
|
|
4
|
+
from agent_api_server.api.v1.thread import api_router as thread_router
|
|
5
|
+
from agent_api_server.api.v1.config import api_router as config_router
|
|
6
|
+
from agent_api_server.api.v1.graph import api_router as graph_router
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
api_router = APIRouter()
|
|
11
|
+
api_router.include_router(thread_router, prefix="/thread", tags=["thread"])
|
|
12
|
+
api_router.include_router(schema_router, prefix="/schema", tags=["schema"])
|
|
13
|
+
api_router.include_router(config_router, prefix="/config", tags=["config"])
|
|
14
|
+
api_router.include_router(graph_router, prefix="/graph", tags=["graph"])
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@api_router.get("/health")
|
|
19
|
+
async def health_check(
|
|
20
|
+
):
|
|
21
|
+
"""Health check endpoint with connection pool verification"""
|
|
22
|
+
return {
|
|
23
|
+
"message": "Welcome to the LangGraph FastAPI Server!",
|
|
24
|
+
"worker_pid": os.getpid(),
|
|
25
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from fastapi import APIRouter
|
|
3
|
+
from fastapi.responses import JSONResponse
|
|
4
|
+
from agent_api_server.shared.base_model import error_response
|
|
5
|
+
from agent_api_server.shared.util_func import load_graph_config, load_graph
|
|
6
|
+
from langgraph.graph.state import CompiledStateGraph
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
api_router = APIRouter()
|
|
10
|
+
|
|
11
|
+
@api_router.get(
|
|
12
|
+
"/",
|
|
13
|
+
responses={
|
|
14
|
+
200: {
|
|
15
|
+
"description": "Successfully returned config JSON Schema",
|
|
16
|
+
"content": {"application/schema+json": {}}
|
|
17
|
+
},
|
|
18
|
+
400: {"model": error_response, "description": "Invalid graph instance"},
|
|
19
|
+
422: {"model": error_response, "description": "Schema validation error"},
|
|
20
|
+
500: {"model": error_response, "description": "Internal server error"}
|
|
21
|
+
},
|
|
22
|
+
summary="Get JSON Schema for graph_name"
|
|
23
|
+
)
|
|
24
|
+
async def get_config_schema(graph_name: str):
|
|
25
|
+
try:
|
|
26
|
+
graph_cfg = await load_graph_config()
|
|
27
|
+
validated_name, graph_instance, _ = await load_graph(graph_name, graph_cfg, False)
|
|
28
|
+
|
|
29
|
+
if not isinstance(graph_instance, CompiledStateGraph):
|
|
30
|
+
raise error_response(
|
|
31
|
+
status_code=400,
|
|
32
|
+
error_type="invalid_graph",
|
|
33
|
+
message="Graph instance type mismatch",
|
|
34
|
+
graph_name=graph_name,
|
|
35
|
+
actual_type=type(graph_instance).__name__
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return JSONResponse(
|
|
39
|
+
content=graph_instance.get_context_jsonschema(),
|
|
40
|
+
media_type="application/schema+json",
|
|
41
|
+
)
|
|
42
|
+
except ValueError as ve:
|
|
43
|
+
logger.error(f"Schema validation failed for {graph_name}: {str(ve)}", exc_info=True)
|
|
44
|
+
raise error_response(
|
|
45
|
+
status_code=422,
|
|
46
|
+
error_type="schema_validation",
|
|
47
|
+
message=str(ve),
|
|
48
|
+
graph_name=graph_name
|
|
49
|
+
)
|
|
50
|
+
except Exception as e:
|
|
51
|
+
logger.critical(f"Unexpected error in {graph_name}: {str(e)}", exc_info=True)
|
|
52
|
+
raise error_response(
|
|
53
|
+
status_code=500,
|
|
54
|
+
error_type="internal_error",
|
|
55
|
+
message=str(e),
|
|
56
|
+
graph_name=graph_name
|
|
57
|
+
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from fastapi import APIRouter
|
|
3
|
+
from fastapi.responses import JSONResponse
|
|
4
|
+
from fastapi import HTTPException
|
|
5
|
+
from agent_api_server.shared.base_model import error_response
|
|
6
|
+
from agent_api_server.shared.util_func import get_all_graph_names
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
api_router = APIRouter()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@api_router.get(
|
|
13
|
+
"/",
|
|
14
|
+
responses={
|
|
15
|
+
200: {
|
|
16
|
+
"description": "Successfully returned list of available graphs",
|
|
17
|
+
"content": {
|
|
18
|
+
"application/json": {
|
|
19
|
+
"example": {
|
|
20
|
+
"graphs": ["Test_App", "iot_data_analyse"],
|
|
21
|
+
"count": 2
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
500: {"model": error_response, "description": "Internal server error"}
|
|
27
|
+
},
|
|
28
|
+
summary="Get all available graph names",
|
|
29
|
+
response_description="List of available graph names"
|
|
30
|
+
)
|
|
31
|
+
async def get_available_graphs():
|
|
32
|
+
"""
|
|
33
|
+
Get all available graph names defined in the configuration file.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
JSON response containing:
|
|
37
|
+
- graphs: List of available graph names
|
|
38
|
+
- count: Number of available graphs
|
|
39
|
+
"""
|
|
40
|
+
try:
|
|
41
|
+
graph_names = await get_all_graph_names()
|
|
42
|
+
return JSONResponse(
|
|
43
|
+
content={
|
|
44
|
+
"graphs": graph_names,
|
|
45
|
+
"count": len(graph_names)
|
|
46
|
+
},
|
|
47
|
+
status_code=200
|
|
48
|
+
)
|
|
49
|
+
except HTTPException as e:
|
|
50
|
+
raise e
|
|
51
|
+
except Exception as e:
|
|
52
|
+
logger.error(f"Failed to get graph names: {str(e)}")
|
|
53
|
+
raise HTTPException(
|
|
54
|
+
status_code=500,
|
|
55
|
+
detail={
|
|
56
|
+
"error": "internal_server_error",
|
|
57
|
+
"message": "Failed to retrieve graph names"
|
|
58
|
+
}
|
|
59
|
+
)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from fastapi import APIRouter
|
|
3
|
+
from fastapi.responses import JSONResponse
|
|
4
|
+
from agent_api_server.shared.base_model import error_response
|
|
5
|
+
from agent_api_server.shared.util_func import load_graph_config, load_graph
|
|
6
|
+
from langgraph.graph.state import CompiledStateGraph
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
api_router = APIRouter()
|
|
10
|
+
|
|
11
|
+
@api_router.get(
|
|
12
|
+
"/",
|
|
13
|
+
responses={
|
|
14
|
+
200: {
|
|
15
|
+
"description": "Successfully returned JSON Schema",
|
|
16
|
+
"content": {"application/schema+json": {}}
|
|
17
|
+
},
|
|
18
|
+
400: {"model": error_response, "description": "Invalid graph instance"},
|
|
19
|
+
422: {"model": error_response, "description": "Schema validation error"},
|
|
20
|
+
500: {"model": error_response, "description": "Internal server error"}
|
|
21
|
+
},
|
|
22
|
+
summary="Get JSON Schema for graph_name"
|
|
23
|
+
)
|
|
24
|
+
async def get_graph_schema(graph_name: str):
|
|
25
|
+
try:
|
|
26
|
+
graph_cfg = await load_graph_config()
|
|
27
|
+
validated_name, graph_instance, _ = await load_graph(graph_name, graph_cfg, False)
|
|
28
|
+
|
|
29
|
+
if not isinstance(graph_instance, CompiledStateGraph):
|
|
30
|
+
raise error_response(
|
|
31
|
+
status_code=400,
|
|
32
|
+
error_type="invalid_graph",
|
|
33
|
+
message="Graph instance type mismatch",
|
|
34
|
+
graph_name=graph_name,
|
|
35
|
+
actual_type=type(graph_instance).__name__
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return JSONResponse(
|
|
39
|
+
content=graph_instance.get_input_jsonschema(),
|
|
40
|
+
media_type="application/schema+json",
|
|
41
|
+
)
|
|
42
|
+
except ValueError as ve:
|
|
43
|
+
logger.error(f"Schema validation failed for {graph_name}: {str(ve)}", exc_info=True)
|
|
44
|
+
raise error_response(
|
|
45
|
+
status_code=422,
|
|
46
|
+
error_type="schema_validation",
|
|
47
|
+
message=str(ve),
|
|
48
|
+
graph_name=graph_name
|
|
49
|
+
)
|
|
50
|
+
except Exception as e:
|
|
51
|
+
logger.critical(f"Unexpected error in {graph_name}: {str(e)}", exc_info=True)
|
|
52
|
+
raise error_response(
|
|
53
|
+
status_code=500,
|
|
54
|
+
error_type="internal_error",
|
|
55
|
+
message=str(e),
|
|
56
|
+
graph_name=graph_name
|
|
57
|
+
)
|