agentic-kit-common 0.0.12__tar.gz → 0.0.14__tar.gz
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.
Potentially problematic release.
This version of agentic-kit-common might be problematic. Click here for more details.
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/PKG-INFO +2 -1
- agentic_kit_common-0.0.14/agentic_kit_common/llm/__init__.py +2 -0
- agentic_kit_common-0.0.14/agentic_kit_common/llm/openai.py +33 -0
- agentic_kit_common-0.0.14/agentic_kit_common/llm/utils.py +61 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/orm/execution.py +1 -1
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common.egg-info/PKG-INFO +2 -1
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common.egg-info/SOURCES.txt +3 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common.egg-info/requires.txt +1 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/setup.py +2 -1
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/README.md +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/log/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/log/logger.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/minio/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/minio/minio_manager.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/orm/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/orm/base.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/orm/manager.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/orm/multi_session.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/orm/schema.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/orm/session.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/embedding/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/embedding/embedding.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/manager/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/manager/milvus_manager.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/schema/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/schema/base.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/schema/milvus_schema.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/web/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/web/http/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/web/http/response.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common.egg-info/dependency_links.txt +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common.egg-info/top_level.txt +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/setup.cfg +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/test/__init__.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/test/config.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/test/settings.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/test/test_embedding.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/test/test_minio.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/test/test_orm.py +0 -0
- {agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/test/test_vector.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentic-kit-common
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.14
|
|
4
4
|
Summary: Common utilities and tools for agentic kit ecosystem
|
|
5
5
|
Home-page:
|
|
6
6
|
Author: manson
|
|
@@ -24,6 +24,7 @@ Requires-Dist: langchain_core
|
|
|
24
24
|
Requires-Dist: langgraph
|
|
25
25
|
Requires-Dist: langchain_community
|
|
26
26
|
Requires-Dist: langchain_experimental
|
|
27
|
+
Requires-Dist: langchain-openai
|
|
27
28
|
Requires-Dist: mysql-connector-python
|
|
28
29
|
Requires-Dist: sqlalchemy
|
|
29
30
|
Requires-Dist: sqlglot
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
from langchain_openai import ChatOpenAI
|
|
5
|
+
|
|
6
|
+
load_dotenv()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
model_name = os.getenv("MODEL_NAME", None)
|
|
10
|
+
openai_api_base = os.getenv("OPENAI_API_BASE", None)
|
|
11
|
+
openai_api_key = os.getenv("OPENAI_API_KEY", 'API_KEY')
|
|
12
|
+
temperature = float(os.getenv("TEMPERATURE", 0.2))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def create_openai_llm(**kwargs):
|
|
16
|
+
_model_name = kwargs.pop('model_name', model_name)
|
|
17
|
+
_openai_api_base = kwargs.pop('openai_api_base', openai_api_base)
|
|
18
|
+
_openai_api_key = kwargs.pop('openai_api_key', openai_api_key)
|
|
19
|
+
if not _openai_api_key:
|
|
20
|
+
_openai_api_key = 'API_KEY'
|
|
21
|
+
_temperature = kwargs.pop('temperature', temperature)
|
|
22
|
+
|
|
23
|
+
assert model_name is not None
|
|
24
|
+
assert openai_api_base is not None
|
|
25
|
+
|
|
26
|
+
llm = ChatOpenAI(
|
|
27
|
+
model_name=_model_name,
|
|
28
|
+
openai_api_base=_openai_api_base,
|
|
29
|
+
openai_api_key=_openai_api_key,
|
|
30
|
+
temperature=_temperature,
|
|
31
|
+
**kwargs
|
|
32
|
+
)
|
|
33
|
+
return llm
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import re
|
|
3
|
+
from typing import Any, Dict, List, Union
|
|
4
|
+
|
|
5
|
+
from langchain_core.messages import BaseMessage, SystemMessage, HumanMessage
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def combine_simple_context(system: str, user: str = None):
|
|
9
|
+
context: List[Union[BaseMessage, dict[str, Any]]] = [SystemMessage(content=system)]
|
|
10
|
+
if user:
|
|
11
|
+
context.append(HumanMessage(content=system))
|
|
12
|
+
return context
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def fix_json_response(text: str) -> Union[Dict, List, str, int, float, bool, None]:
|
|
16
|
+
"""
|
|
17
|
+
去掉大模型返回的 ```json / ``` 等 markdown 标记,并安全反序列化 JSON。
|
|
18
|
+
若解析失败,返回原字符串。
|
|
19
|
+
|
|
20
|
+
参数
|
|
21
|
+
----
|
|
22
|
+
text : str
|
|
23
|
+
原始响应,可能包含 ```json ... ``` 或其他变体。
|
|
24
|
+
|
|
25
|
+
返回
|
|
26
|
+
----
|
|
27
|
+
Python 对象(dict / list / str / int / float / bool / None)
|
|
28
|
+
解析失败时返回输入字符串本身。
|
|
29
|
+
"""
|
|
30
|
+
if not isinstance(text, str):
|
|
31
|
+
return text
|
|
32
|
+
|
|
33
|
+
# 1. 去掉 ```json 或 ``` 包裹(支持开头、结尾、单行、多行)
|
|
34
|
+
cleaned = re.sub(r'^\s*```(?:json|JSON)?\s*\n?', '', text)
|
|
35
|
+
cleaned = re.sub(r'\n?\s*```\s*$', '', cleaned)
|
|
36
|
+
|
|
37
|
+
# 2. 去掉首尾空白
|
|
38
|
+
cleaned = cleaned.strip()
|
|
39
|
+
|
|
40
|
+
# 3. 尝试 JSON 反序列化
|
|
41
|
+
try:
|
|
42
|
+
json.loads(cleaned)
|
|
43
|
+
return cleaned
|
|
44
|
+
except json.JSONDecodeError:
|
|
45
|
+
# 4. 兜底:返回原字符串
|
|
46
|
+
return text
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# ----------------- 使用示例 -----------------
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
demo_list = [
|
|
52
|
+
'```json\n{"a": 1, "b": "hello"}\n```',
|
|
53
|
+
"```JSON{'key': 'value'}```",
|
|
54
|
+
"```\n[1, 2, 3]```",
|
|
55
|
+
"plain text",
|
|
56
|
+
{"already_dict": 1},
|
|
57
|
+
]
|
|
58
|
+
for d in demo_list:
|
|
59
|
+
print("原始:", repr(d))
|
|
60
|
+
print("修复:", repr(fix_json_response(d)))
|
|
61
|
+
print("-" * 30)
|
|
@@ -59,7 +59,7 @@ def is_readonly_expression(node: expressions.Expression, allowed_operations: Opt
|
|
|
59
59
|
if allowed_operations:
|
|
60
60
|
op_type = get_operation_type(node)
|
|
61
61
|
# 检查操作类型
|
|
62
|
-
if op_type not in allowed_operations:
|
|
62
|
+
if op_type.lower() not in allowed_operations and op_type.upper() not in allowed_operations:
|
|
63
63
|
return False, op_type
|
|
64
64
|
|
|
65
65
|
if enable_wildcard_check and isinstance(node, expressions.Select) and node.find(expressions.Star):
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentic-kit-common
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.14
|
|
4
4
|
Summary: Common utilities and tools for agentic kit ecosystem
|
|
5
5
|
Home-page:
|
|
6
6
|
Author: manson
|
|
@@ -24,6 +24,7 @@ Requires-Dist: langchain_core
|
|
|
24
24
|
Requires-Dist: langgraph
|
|
25
25
|
Requires-Dist: langchain_community
|
|
26
26
|
Requires-Dist: langchain_experimental
|
|
27
|
+
Requires-Dist: langchain-openai
|
|
27
28
|
Requires-Dist: mysql-connector-python
|
|
28
29
|
Requires-Dist: sqlalchemy
|
|
29
30
|
Requires-Dist: sqlglot
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common.egg-info/SOURCES.txt
RENAMED
|
@@ -6,6 +6,9 @@ agentic_kit_common.egg-info/SOURCES.txt
|
|
|
6
6
|
agentic_kit_common.egg-info/dependency_links.txt
|
|
7
7
|
agentic_kit_common.egg-info/requires.txt
|
|
8
8
|
agentic_kit_common.egg-info/top_level.txt
|
|
9
|
+
agentic_kit_common/llm/__init__.py
|
|
10
|
+
agentic_kit_common/llm/openai.py
|
|
11
|
+
agentic_kit_common/llm/utils.py
|
|
9
12
|
agentic_kit_common/log/__init__.py
|
|
10
13
|
agentic_kit_common/log/logger.py
|
|
11
14
|
agentic_kit_common/minio/__init__.py
|
|
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
|
|
|
4
4
|
|
|
5
5
|
setup(
|
|
6
6
|
name='agentic-kit-common',
|
|
7
|
-
version="0.0.
|
|
7
|
+
version="0.0.14",
|
|
8
8
|
author="manson",
|
|
9
9
|
author_email="manson.li3307@gmail.com",
|
|
10
10
|
description='Common utilities and tools for agentic kit ecosystem',
|
|
@@ -37,6 +37,7 @@ setup(
|
|
|
37
37
|
"langgraph",
|
|
38
38
|
"langchain_community",
|
|
39
39
|
"langchain_experimental",
|
|
40
|
+
"langchain-openai",
|
|
40
41
|
|
|
41
42
|
# sqlalchemy
|
|
42
43
|
"mysql-connector-python",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/minio/__init__.py
RENAMED
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/minio/minio_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/orm/multi_session.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/schema/__init__.py
RENAMED
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/vector/schema/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/web/http/__init__.py
RENAMED
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common/web/http/response.py
RENAMED
|
File without changes
|
|
File without changes
|
{agentic_kit_common-0.0.12 → agentic_kit_common-0.0.14}/agentic_kit_common.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|