osis-python 0.1.0__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.
- osis_python-0.1.0/LICENSE +21 -0
- osis_python-0.1.0/PKG-INFO +64 -0
- osis_python-0.1.0/README.md +10 -0
- osis_python-0.1.0/pyproject.toml +66 -0
- osis_python-0.1.0/setup.cfg +4 -0
- osis_python-0.1.0/src/osis_python.egg-info/PKG-INFO +64 -0
- osis_python-0.1.0/src/osis_python.egg-info/SOURCES.txt +59 -0
- osis_python-0.1.0/src/osis_python.egg-info/dependency_links.txt +1 -0
- osis_python-0.1.0/src/osis_python.egg-info/requires.txt +14 -0
- osis_python-0.1.0/src/osis_python.egg-info/top_level.txt +1 -0
- osis_python-0.1.0/src/pyosis/__init__.py +15 -0
- osis_python-0.1.0/src/pyosis/ai/__init__.py +6 -0
- osis_python-0.1.0/src/pyosis/ai/agents/BaseAgent.py +79 -0
- osis_python-0.1.0/src/pyosis/ai/agents/DecisionAgent.py +189 -0
- osis_python-0.1.0/src/pyosis/ai/agents/MaterialAgent.py +44 -0
- osis_python-0.1.0/src/pyosis/ai/agents/ModelAgent.py +42 -0
- osis_python-0.1.0/src/pyosis/ai/agents/QuickBuildingAgent.py +74 -0
- osis_python-0.1.0/src/pyosis/ai/agents/SectionAgent.py +40 -0
- osis_python-0.1.0/src/pyosis/ai/agents/__init__.py +0 -0
- osis_python-0.1.0/src/pyosis/boundary/__init__.py +7 -0
- osis_python-0.1.0/src/pyosis/boundary/interface.py +90 -0
- osis_python-0.1.0/src/pyosis/control/__init__.py +1 -0
- osis_python-0.1.0/src/pyosis/control/interface.py +182 -0
- osis_python-0.1.0/src/pyosis/core/PyInterface.pyi +153 -0
- osis_python-0.1.0/src/pyosis/core/__init__.py +12 -0
- osis_python-0.1.0/src/pyosis/core/command.py +180 -0
- osis_python-0.1.0/src/pyosis/core/engine.py +13 -0
- osis_python-0.1.0/src/pyosis/element/__init__.py +1 -0
- osis_python-0.1.0/src/pyosis/element/interface.py +220 -0
- osis_python-0.1.0/src/pyosis/general/__init__.py +1 -0
- osis_python-0.1.0/src/pyosis/general/interface.py +31 -0
- osis_python-0.1.0/src/pyosis/live/__init__.py +3 -0
- osis_python-0.1.0/src/pyosis/live/analysis.py +116 -0
- osis_python-0.1.0/src/pyosis/live/grade.py +125 -0
- osis_python-0.1.0/src/pyosis/live/lane.py +56 -0
- osis_python-0.1.0/src/pyosis/load/__init__.py +3 -0
- osis_python-0.1.0/src/pyosis/load/loadcase.py +59 -0
- osis_python-0.1.0/src/pyosis/load/static.py +274 -0
- osis_python-0.1.0/src/pyosis/load/tendon.py +325 -0
- osis_python-0.1.0/src/pyosis/material/__init__.py +1 -0
- osis_python-0.1.0/src/pyosis/material/interface.py +207 -0
- osis_python-0.1.0/src/pyosis/node/__init__.py +1 -0
- osis_python-0.1.0/src/pyosis/node/interface.py +51 -0
- osis_python-0.1.0/src/pyosis/post/__init__.py +1 -0
- osis_python-0.1.0/src/pyosis/post/interface.py +21 -0
- osis_python-0.1.0/src/pyosis/property/__init__.py +0 -0
- osis_python-0.1.0/src/pyosis/property/coordinate.py +5 -0
- osis_python-0.1.0/src/pyosis/property/creep_shrink.py +53 -0
- osis_python-0.1.0/src/pyosis/property/damping.py +37 -0
- osis_python-0.1.0/src/pyosis/property/pu_curve.py +59 -0
- osis_python-0.1.0/src/pyosis/quick_building/__init__.py +1 -0
- osis_python-0.1.0/src/pyosis/quick_building/interface.py +298 -0
- osis_python-0.1.0/src/pyosis/section/__init__.py +4 -0
- osis_python-0.1.0/src/pyosis/section/common.py +325 -0
- osis_python-0.1.0/src/pyosis/section/numeric.py +0 -0
- osis_python-0.1.0/src/pyosis/section/param.py +96 -0
- osis_python-0.1.0/src/pyosis/section/steel.py +0 -0
- osis_python-0.1.0/src/pyosis/stage/__init__.py +3 -0
- osis_python-0.1.0/src/pyosis/stage/define.py +123 -0
- osis_python-0.1.0/src/pyosis/stage/overall.py +85 -0
- osis_python-0.1.0/tests/test_osis.py +77 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CCCC Highway Consultant Co. Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: osis-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python client library for Osis APDL
|
|
5
|
+
Author-email: "CCCC Highway Consultant Co. Ltd." <support@osisbim.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 CCCC Highway Consultant Co. Ltd.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Homepage, https://github.com/osis-ai/pyosis
|
|
28
|
+
Project-URL: Documentation, https://github.com/osis-ai/pyosis#readme
|
|
29
|
+
Project-URL: Repository, https://github.com/osis-ai/pyosis.git
|
|
30
|
+
Project-URL: BugTracker, https://github.com/osis-ai/pyosis/issues
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Requires-Python: >=3.11
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE
|
|
41
|
+
Requires-Dist: langchain>=1.0.3
|
|
42
|
+
Requires-Dist: langchain-core>=1.0.3
|
|
43
|
+
Requires-Dist: langchain-openai>=1.0.2
|
|
44
|
+
Requires-Dist: pydantic>=2.12.4
|
|
45
|
+
Requires-Dist: pydantic_core>=2.41.5
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
48
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
49
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
50
|
+
Provides-Extra: test
|
|
51
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
52
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test"
|
|
53
|
+
Dynamic: license-file
|
|
54
|
+
|
|
55
|
+
# pyosis
|
|
56
|
+
|
|
57
|
+
中交公路规划设计院自研OSIS桥隧分析平台的Python接口
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install osis-python
|
|
63
|
+
|
|
64
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
# PyPI 上的包名
|
|
7
|
+
name = "osis-python"
|
|
8
|
+
# 版本号
|
|
9
|
+
version = "0.1.0"
|
|
10
|
+
# 作者信息
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "CCCC Highway Consultant Co. Ltd.", email = "support@osisbim.com"},
|
|
13
|
+
]
|
|
14
|
+
# 描述
|
|
15
|
+
description = "A Python client library for Osis APDL"
|
|
16
|
+
# 详细描述文件
|
|
17
|
+
readme = "README.md"
|
|
18
|
+
# 许可证文件
|
|
19
|
+
license = {file = "LICENSE"}
|
|
20
|
+
# Python 版本要求
|
|
21
|
+
requires-python = ">=3.11"
|
|
22
|
+
# 分类器
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 4 - Beta",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Topic :: Software Development :: Libraries",
|
|
27
|
+
"License :: OSI Approved :: MIT License",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
]
|
|
32
|
+
# 依赖
|
|
33
|
+
dependencies = [
|
|
34
|
+
"langchain>=1.0.3",
|
|
35
|
+
"langchain-core>=1.0.3",
|
|
36
|
+
"langchain-openai>=1.0.2",
|
|
37
|
+
"pydantic>=2.12.4",
|
|
38
|
+
"pydantic_core>=2.41.5",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
# 项目链接
|
|
42
|
+
[project.urls]
|
|
43
|
+
Homepage = "https://github.com/osis-ai/pyosis"
|
|
44
|
+
Documentation = "https://github.com/osis-ai/pyosis#readme"
|
|
45
|
+
Repository = "https://github.com/osis-ai/pyosis.git"
|
|
46
|
+
BugTracker = "https://github.com/osis-ai/pyosis/issues"
|
|
47
|
+
|
|
48
|
+
# 可选依赖(如果有的话)
|
|
49
|
+
[project.optional-dependencies]
|
|
50
|
+
dev = [
|
|
51
|
+
"pytest>=7.0",
|
|
52
|
+
"black>=23.0",
|
|
53
|
+
"mypy>=1.0",
|
|
54
|
+
]
|
|
55
|
+
test = [
|
|
56
|
+
"pytest>=7.0",
|
|
57
|
+
"pytest-cov>=4.0",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
# 包发现配置
|
|
61
|
+
[tool.setuptools.packages.find]
|
|
62
|
+
where = ["src"]
|
|
63
|
+
|
|
64
|
+
# 包含的包数据
|
|
65
|
+
[tool.setuptools.package-data]
|
|
66
|
+
"*" = ["*.txt", "*.md", "*.json"]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: osis-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python client library for Osis APDL
|
|
5
|
+
Author-email: "CCCC Highway Consultant Co. Ltd." <support@osisbim.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 CCCC Highway Consultant Co. Ltd.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Homepage, https://github.com/osis-ai/pyosis
|
|
28
|
+
Project-URL: Documentation, https://github.com/osis-ai/pyosis#readme
|
|
29
|
+
Project-URL: Repository, https://github.com/osis-ai/pyosis.git
|
|
30
|
+
Project-URL: BugTracker, https://github.com/osis-ai/pyosis/issues
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Requires-Python: >=3.11
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE
|
|
41
|
+
Requires-Dist: langchain>=1.0.3
|
|
42
|
+
Requires-Dist: langchain-core>=1.0.3
|
|
43
|
+
Requires-Dist: langchain-openai>=1.0.2
|
|
44
|
+
Requires-Dist: pydantic>=2.12.4
|
|
45
|
+
Requires-Dist: pydantic_core>=2.41.5
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
48
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
49
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
50
|
+
Provides-Extra: test
|
|
51
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
52
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test"
|
|
53
|
+
Dynamic: license-file
|
|
54
|
+
|
|
55
|
+
# pyosis
|
|
56
|
+
|
|
57
|
+
中交公路规划设计院自研OSIS桥隧分析平台的Python接口
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install osis-python
|
|
63
|
+
|
|
64
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/osis_python.egg-info/PKG-INFO
|
|
5
|
+
src/osis_python.egg-info/SOURCES.txt
|
|
6
|
+
src/osis_python.egg-info/dependency_links.txt
|
|
7
|
+
src/osis_python.egg-info/requires.txt
|
|
8
|
+
src/osis_python.egg-info/top_level.txt
|
|
9
|
+
src/pyosis/__init__.py
|
|
10
|
+
src/pyosis/ai/__init__.py
|
|
11
|
+
src/pyosis/ai/agents/BaseAgent.py
|
|
12
|
+
src/pyosis/ai/agents/DecisionAgent.py
|
|
13
|
+
src/pyosis/ai/agents/MaterialAgent.py
|
|
14
|
+
src/pyosis/ai/agents/ModelAgent.py
|
|
15
|
+
src/pyosis/ai/agents/QuickBuildingAgent.py
|
|
16
|
+
src/pyosis/ai/agents/SectionAgent.py
|
|
17
|
+
src/pyosis/ai/agents/__init__.py
|
|
18
|
+
src/pyosis/boundary/__init__.py
|
|
19
|
+
src/pyosis/boundary/interface.py
|
|
20
|
+
src/pyosis/control/__init__.py
|
|
21
|
+
src/pyosis/control/interface.py
|
|
22
|
+
src/pyosis/core/PyInterface.pyi
|
|
23
|
+
src/pyosis/core/__init__.py
|
|
24
|
+
src/pyosis/core/command.py
|
|
25
|
+
src/pyosis/core/engine.py
|
|
26
|
+
src/pyosis/element/__init__.py
|
|
27
|
+
src/pyosis/element/interface.py
|
|
28
|
+
src/pyosis/general/__init__.py
|
|
29
|
+
src/pyosis/general/interface.py
|
|
30
|
+
src/pyosis/live/__init__.py
|
|
31
|
+
src/pyosis/live/analysis.py
|
|
32
|
+
src/pyosis/live/grade.py
|
|
33
|
+
src/pyosis/live/lane.py
|
|
34
|
+
src/pyosis/load/__init__.py
|
|
35
|
+
src/pyosis/load/loadcase.py
|
|
36
|
+
src/pyosis/load/static.py
|
|
37
|
+
src/pyosis/load/tendon.py
|
|
38
|
+
src/pyosis/material/__init__.py
|
|
39
|
+
src/pyosis/material/interface.py
|
|
40
|
+
src/pyosis/node/__init__.py
|
|
41
|
+
src/pyosis/node/interface.py
|
|
42
|
+
src/pyosis/post/__init__.py
|
|
43
|
+
src/pyosis/post/interface.py
|
|
44
|
+
src/pyosis/property/__init__.py
|
|
45
|
+
src/pyosis/property/coordinate.py
|
|
46
|
+
src/pyosis/property/creep_shrink.py
|
|
47
|
+
src/pyosis/property/damping.py
|
|
48
|
+
src/pyosis/property/pu_curve.py
|
|
49
|
+
src/pyosis/quick_building/__init__.py
|
|
50
|
+
src/pyosis/quick_building/interface.py
|
|
51
|
+
src/pyosis/section/__init__.py
|
|
52
|
+
src/pyosis/section/common.py
|
|
53
|
+
src/pyosis/section/numeric.py
|
|
54
|
+
src/pyosis/section/param.py
|
|
55
|
+
src/pyosis/section/steel.py
|
|
56
|
+
src/pyosis/stage/__init__.py
|
|
57
|
+
src/pyosis/stage/define.py
|
|
58
|
+
src/pyosis/stage/overall.py
|
|
59
|
+
tests/test_osis.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyosis
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pyosis
|
|
3
|
+
|
|
4
|
+
========
|
|
5
|
+
A library for A library for calling OSIS functions.
|
|
6
|
+
A library for extending OSIS functionality.
|
|
7
|
+
A library that allows users to use CAE with great flexibility.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.0"
|
|
11
|
+
__author__ = "Li Zihao" # 中交公路规划设计院 - 工程技术研究中心 - 生产数智化研究室
|
|
12
|
+
|
|
13
|
+
# from .core import engine
|
|
14
|
+
# from .ai.agents import BaseAgent
|
|
15
|
+
from .core import osis_run
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from langchain_openai import ChatOpenAI
|
|
2
|
+
from langchain.agents import create_agent
|
|
3
|
+
from langgraph.checkpoint.memory import InMemorySaver
|
|
4
|
+
import pydantic
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
class BaseAgent:
|
|
8
|
+
"""Agent base class"""
|
|
9
|
+
|
|
10
|
+
def __init__(self, model="qwen-flash", api_key="", base_url=""):
|
|
11
|
+
"""Initialize the agent"""
|
|
12
|
+
if model == "" or api_key == "" or base_url == "":
|
|
13
|
+
raise ValueError("API key and Base URL must be provided for Agent.")
|
|
14
|
+
self.llm = ChatOpenAI(
|
|
15
|
+
model=model,
|
|
16
|
+
api_key=pydantic.SecretStr(api_key),
|
|
17
|
+
base_url=base_url)
|
|
18
|
+
|
|
19
|
+
def create_agent(self, tools, system_prompt):
|
|
20
|
+
self.system_prompt = system_prompt
|
|
21
|
+
self.checkpointer = InMemorySaver() # 记忆管理
|
|
22
|
+
self.agent = create_agent(model=self.llm,
|
|
23
|
+
tools=tools,
|
|
24
|
+
system_prompt=self.system_prompt,
|
|
25
|
+
checkpointer=self.checkpointer)
|
|
26
|
+
|
|
27
|
+
def invoke(self, user_input, thread_id="1"):
|
|
28
|
+
"""向智能体提问"""
|
|
29
|
+
result = self.agent.invoke(
|
|
30
|
+
{"messages": [{"role": "user", "content": user_input}]},
|
|
31
|
+
{"configurable": {"thread_id": thread_id}}
|
|
32
|
+
)
|
|
33
|
+
return result
|
|
34
|
+
def stream(self, user_input, thread_id="1", stream_mode: Literal["values", "updates", "checkpoints", "tasks"] = "updates"):
|
|
35
|
+
"""流式输出智能体回复"""
|
|
36
|
+
return self.agent.stream(
|
|
37
|
+
{"messages": [{"role": "user", "content": user_input}]}, {"configurable": {"thread_id": thread_id}},
|
|
38
|
+
stream_mode=stream_mode)
|
|
39
|
+
|
|
40
|
+
def ask_agent(self, user_input, thread_id="1"):
|
|
41
|
+
"""向智能体提问,回答仅文本"""
|
|
42
|
+
result = self.agent.invoke(
|
|
43
|
+
{"messages": [{"role": "user", "content": user_input}]},
|
|
44
|
+
{"configurable": {"thread_id": thread_id}}
|
|
45
|
+
)
|
|
46
|
+
return result['messages'][-1].content
|
|
47
|
+
|
|
48
|
+
def ask_agent_stream(self, user_input, thread_id="1", stream_mode: Literal["values", "updates", "checkpoints", "tasks"] = "updates"):
|
|
49
|
+
"""流式输出智能体回复,回答仅文本"""
|
|
50
|
+
for chunk in self.agent.stream(
|
|
51
|
+
{"messages": [{"role": "user", "content": user_input}]}, {"configurable": {"thread_id": thread_id}},
|
|
52
|
+
stream_mode=stream_mode):
|
|
53
|
+
# 提取消息内容
|
|
54
|
+
for step, data in chunk.items():
|
|
55
|
+
if step == "tools": # 工具调用结果不需要显示
|
|
56
|
+
continue
|
|
57
|
+
ai_response = data['messages'][-1].content
|
|
58
|
+
yield ai_response
|
|
59
|
+
|
|
60
|
+
def run_example(self, stream=True):
|
|
61
|
+
"""运行智能体"""
|
|
62
|
+
while True:
|
|
63
|
+
user_input = input("User: ")
|
|
64
|
+
if user_input == "exit" or user_input == "quit":
|
|
65
|
+
break
|
|
66
|
+
if stream:
|
|
67
|
+
print("Agent: ", end="")
|
|
68
|
+
for chunk in self.stream(user_input):
|
|
69
|
+
# 提取消息内容
|
|
70
|
+
for step, data in chunk.items():
|
|
71
|
+
if 'messages' in data and len(data['messages']) > 0:
|
|
72
|
+
ai_response = f"\nstep: {step}\ncontent: {data['messages'][-1].content_blocks}" # 调试信息
|
|
73
|
+
print(ai_response)
|
|
74
|
+
if step == "tools": # 工具调用结果不需要显示
|
|
75
|
+
continue
|
|
76
|
+
ai_response = data['messages'][-1].content # 一般回复
|
|
77
|
+
|
|
78
|
+
else:
|
|
79
|
+
print("Agent: ", self.ask_agent(user_input))
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
from langchain_core.messages import AIMessage, HumanMessage
|
|
2
|
+
from .BaseAgent import BaseAgent
|
|
3
|
+
from langchain.tools import tool
|
|
4
|
+
from .MaterialAgent import MaterialAgent
|
|
5
|
+
from .SectionAgent import SectionAgent
|
|
6
|
+
from .ModelAgent import ModelAgent
|
|
7
|
+
from .QuickBuildingAgent import QuickBuildingAgent
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
material_agent = None
|
|
11
|
+
section_agent = None
|
|
12
|
+
model_agent = None
|
|
13
|
+
quick_building_agent = None
|
|
14
|
+
|
|
15
|
+
def log_to_file(msg,fn = "D:/log.txt"):
|
|
16
|
+
fp = open("D:/log.txt", "a", encoding="utf-8")
|
|
17
|
+
fp.write(msg)
|
|
18
|
+
print(msg)
|
|
19
|
+
fp.write('\r\n')
|
|
20
|
+
fp.close()
|
|
21
|
+
|
|
22
|
+
def call_agent(agent, request: str):
|
|
23
|
+
ai_response = agent.invoke(request, "4")
|
|
24
|
+
messages = ai_response['messages']
|
|
25
|
+
last_human_index = 0
|
|
26
|
+
for i in range(len(messages)-1, -1, -1):
|
|
27
|
+
if isinstance(messages[i], HumanMessage):
|
|
28
|
+
last_human_index = i
|
|
29
|
+
break
|
|
30
|
+
|
|
31
|
+
print("v" * 30)
|
|
32
|
+
for message in messages[last_human_index + 1:]:
|
|
33
|
+
if isinstance(message, AIMessage):
|
|
34
|
+
# print(f"content: {message.content}")
|
|
35
|
+
# print(f"tool_calls: {message.tool_calls}\n")
|
|
36
|
+
log_to_file(f"content: {message.content}")
|
|
37
|
+
log_to_file(f"tool_calls: {message.tool_calls}\n")
|
|
38
|
+
print("^" * 30)
|
|
39
|
+
|
|
40
|
+
return ai_response['messages'][-1].content
|
|
41
|
+
|
|
42
|
+
@tool
|
|
43
|
+
def call_material_agent(request: str):
|
|
44
|
+
"""
|
|
45
|
+
调用材料智能体
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
request (str): 对材料智能体的请求
|
|
49
|
+
Returns:
|
|
50
|
+
str: 材料智能体的回答
|
|
51
|
+
"""
|
|
52
|
+
global material_agent
|
|
53
|
+
return call_agent(material_agent, request)
|
|
54
|
+
# for chunk in material_agent.ask_agent_stream(request, "1"):
|
|
55
|
+
# # 提取消息内容
|
|
56
|
+
# for step, data in chunk.items():
|
|
57
|
+
# ai_response = f"\nstep: {step}\ncontent: {data['messages'][-1].content_blocks}" # 调试信息
|
|
58
|
+
# print(ai_response)
|
|
59
|
+
# yield data['messages'][-1].content # 一般回复
|
|
60
|
+
|
|
61
|
+
@tool
|
|
62
|
+
def call_section_agent(request: str):
|
|
63
|
+
'''
|
|
64
|
+
调用截面智能体
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
request (str): 对截面智能体的请求
|
|
68
|
+
Returns:
|
|
69
|
+
str: 截面智能体的回答
|
|
70
|
+
'''
|
|
71
|
+
global section_agent
|
|
72
|
+
return call_agent(section_agent, request)
|
|
73
|
+
# for chunk in section_agent.ask_agent_stream(request, "2"):
|
|
74
|
+
# # 提取消息内容
|
|
75
|
+
# for step, data in chunk.items():
|
|
76
|
+
# ai_response = f"\nstep: {step}\ncontent: {data['messages'][-1].content_blocks}" # 调试信息
|
|
77
|
+
# print(ai_response)
|
|
78
|
+
# yield data['messages'][-1].content # 一般回复
|
|
79
|
+
|
|
80
|
+
@tool
|
|
81
|
+
def call_model_agent(request: str):
|
|
82
|
+
'''
|
|
83
|
+
调用模型智能体
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
request (str): 对模型智能体的请求
|
|
87
|
+
Returns:
|
|
88
|
+
str: 模型智能体的回答
|
|
89
|
+
'''
|
|
90
|
+
global model_agent
|
|
91
|
+
return call_agent(model_agent, request)
|
|
92
|
+
|
|
93
|
+
@tool
|
|
94
|
+
def call_quick_building_agent(request: str):
|
|
95
|
+
'''
|
|
96
|
+
调用快速建模智能体
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
request (str): 对快速建模智能体的请求
|
|
100
|
+
Returns:
|
|
101
|
+
str: 快速建模智能体的回答
|
|
102
|
+
'''
|
|
103
|
+
global quick_building_agent
|
|
104
|
+
return call_agent(quick_building_agent, request)
|
|
105
|
+
|
|
106
|
+
class DecisionAgent(BaseAgent):
|
|
107
|
+
"""决策智能体"""
|
|
108
|
+
def __init__(self, model="qwen-max", api_key="", base_url=""):
|
|
109
|
+
super().__init__(model, api_key, base_url)
|
|
110
|
+
global material_agent
|
|
111
|
+
global section_agent
|
|
112
|
+
global model_agent
|
|
113
|
+
global quick_building_agent
|
|
114
|
+
material_agent = MaterialAgent('qwen-flash', api_key, base_url)
|
|
115
|
+
material_agent.create_agent()
|
|
116
|
+
section_agent = SectionAgent('qwen-flash', api_key, base_url)
|
|
117
|
+
section_agent.create_agent()
|
|
118
|
+
model_agent = ModelAgent('qwen-flash', api_key, base_url)
|
|
119
|
+
model_agent.create_agent()
|
|
120
|
+
quick_building_agent = QuickBuildingAgent('qwen-plus', api_key, base_url)
|
|
121
|
+
quick_building_agent.create_agent()
|
|
122
|
+
|
|
123
|
+
def create_agent(self):
|
|
124
|
+
tools = [
|
|
125
|
+
call_material_agent, # 调用材料智能体
|
|
126
|
+
call_section_agent, # 调用截面智能体
|
|
127
|
+
call_model_agent, # 调用模型智能体
|
|
128
|
+
call_quick_building_agent # 调用快速建模智能体
|
|
129
|
+
]
|
|
130
|
+
|
|
131
|
+
# system_prompt = """\
|
|
132
|
+
# 你是一个桥梁设计总监,负责协调材料、截面、模型、显示等专业智能体的工作。
|
|
133
|
+
|
|
134
|
+
# 你的职责:
|
|
135
|
+
# 1. 分析用户需求,确定设计参数
|
|
136
|
+
# 2. 协调各个智能体的工作顺序
|
|
137
|
+
# 3. 检查设计进度,确保所有组件都正确创建
|
|
138
|
+
# 4. 处理设计过程中的冲突和错误
|
|
139
|
+
# 5. 调用操作必须一步步来,等上一步完成了才能调用下一个函数。
|
|
140
|
+
|
|
141
|
+
# 你的手下掌握着以下几个智能体:
|
|
142
|
+
# 1. 材料智能体:用于生成满足用户需求的材料。
|
|
143
|
+
# 2. 截面智能体:用于生成满足用户需求的截面。
|
|
144
|
+
# 3. 模型智能体:用于生成满足用户需求的模型,具体包含创建节点与创建单元。创建时需要提供材料与截面编号。
|
|
145
|
+
# 4. 快速建模智能体:直接创建 小箱梁 T梁 连续小箱梁 连续T梁 空心板 等模型
|
|
146
|
+
|
|
147
|
+
# 工作流程
|
|
148
|
+
# - 调用工具前告诉用户你的想法。
|
|
149
|
+
# - 你最重要的工作是确定当前用户的需求需要调用哪个智能体,你可能并不知道用户所描述的参数具体含义是什么,你只需要将需求与必要信息整理并传递给具体功能智能体即可。
|
|
150
|
+
# - 若需要创建完整悬浇梁,流程为创建材料-创建截面-创建节点-创建单元-刷新界面。
|
|
151
|
+
|
|
152
|
+
# 工作原则:
|
|
153
|
+
# 1. **严格顺序执行**:每次只调用一个工具,等待该工具执行完成并返回结果后,再根据结果决定下一步
|
|
154
|
+
# 2. **确认执行结果**:每个工具调用后,必须检查返回的结果状态,确认成功后再继续
|
|
155
|
+
# 3. **分步规划**:即使你知道完整流程,也不能一次性生成所有工具调用,必须一步步来,也一定不要做用户要求之外的事情,比如只要求创建材料,你就不要继续剩下的流程
|
|
156
|
+
|
|
157
|
+
# 不要做超出用户要求的事。所有流程结束后,请告知用户可以继续下一步。若功能智能体出现问题,请告知失败原因。
|
|
158
|
+
# """
|
|
159
|
+
system_prompt = \
|
|
160
|
+
"""
|
|
161
|
+
你是一个桥梁设计总监,负责协调材料、截面、模型、显示等专业智能体的工作。
|
|
162
|
+
|
|
163
|
+
你的手下掌握着以下几个智能体:
|
|
164
|
+
1. 材料智能体:用于生成满足用户需求的材料。
|
|
165
|
+
2. 截面智能体:用于生成满足用户需求的截面。
|
|
166
|
+
3. 模型智能体:用于创建节点与创建单元。创建一定要提供材料与截面编号,如果没有材料或者截面,新建一个。
|
|
167
|
+
4. 快速建模智能体:这是一个独立的模块,直接创建 空心板 小箱梁 T梁 连续小箱梁 连续T梁 等模型。当用户想要直接创建桥梁时,**确保将用户的所有需求(包括桥梁类型、尺寸、荷载、钢束、施工阶段等)一次性全部转交给快速建模智能体,不能分布执行**
|
|
168
|
+
|
|
169
|
+
你的职责:
|
|
170
|
+
1. 分析用户需求,确定设计参数
|
|
171
|
+
2. 协调各个智能体的工作顺序
|
|
172
|
+
3. 检查设计进度,确保所有组件都正确创建
|
|
173
|
+
4. 处理设计过程中的冲突和错误
|
|
174
|
+
|
|
175
|
+
工作流程:
|
|
176
|
+
- 先告诉用户你的思考和计划
|
|
177
|
+
- 调用需要的智能体
|
|
178
|
+
- 等待智能体执行完成并返回结果
|
|
179
|
+
- 检查结果,确认是否成功,并详细告知你调用的智能体做了什么
|
|
180
|
+
- 如果成功,继续下一步;如果失败,处理错误
|
|
181
|
+
|
|
182
|
+
特殊情况处理:
|
|
183
|
+
- 如果工具返回错误,分析错误原因并告诉用户
|
|
184
|
+
- 如果用户需求不完整,先询问缺失信息
|
|
185
|
+
- 所有流程结束后,告知用户可以继续下一步
|
|
186
|
+
|
|
187
|
+
"""
|
|
188
|
+
super().create_agent(tools, system_prompt)
|
|
189
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from langchain.tools import tool
|
|
2
|
+
from .BaseAgent import BaseAgent
|
|
3
|
+
from ...property.creep_shrink import osis_creep_shrink
|
|
4
|
+
from ...material import *
|
|
5
|
+
|
|
6
|
+
class MaterialAgent(BaseAgent):
|
|
7
|
+
"""材料设计智能体"""
|
|
8
|
+
def __init__(self, model="qwen-flash", api_key="", base_url=""):
|
|
9
|
+
super().__init__(model, api_key, base_url)
|
|
10
|
+
|
|
11
|
+
def create_agent(self):
|
|
12
|
+
tools = [
|
|
13
|
+
tool(osis_creep_shrink),
|
|
14
|
+
tool(osis_material_conc),
|
|
15
|
+
tool(osis_material_steel),
|
|
16
|
+
tool(osis_material_reber),
|
|
17
|
+
tool(osis_material_prestressed),
|
|
18
|
+
tool(osis_material_custom),
|
|
19
|
+
tool(osis_material_del),
|
|
20
|
+
tool(osis_material_mod)
|
|
21
|
+
]
|
|
22
|
+
system_prompt = \
|
|
23
|
+
"""
|
|
24
|
+
你是材料设计专家,负责桥梁材料的创建和管理。你需要配合决策智能体完成桥梁材料的创建与修改工作。
|
|
25
|
+
|
|
26
|
+
重要说明:
|
|
27
|
+
- 如果是混凝土材料,一定要先创建收缩徐变特性,再创建材料。其他材料直接创建材料即可
|
|
28
|
+
|
|
29
|
+
工作流程:
|
|
30
|
+
- 创建任何对象时编号从1递增
|
|
31
|
+
- 操作前告诉用户你的想法,操作完成后先确认执行结果,如果失败结束当前调用链并告知用户
|
|
32
|
+
- 若用户没规定,参数全部使用默认值
|
|
33
|
+
- 若用户要修改某个材料,直接重新调用一次创建函数,参数中指定要修改的材料编号即可
|
|
34
|
+
- 默认创建C50混凝土材料
|
|
35
|
+
|
|
36
|
+
创建成功后,请告知决策智能体。创建失败后,请告知失败原因。
|
|
37
|
+
"""
|
|
38
|
+
super().create_agent(tools, system_prompt)
|
|
39
|
+
|
|
40
|
+
if __name__ == "__main__":
|
|
41
|
+
material_agent = MaterialAgent()
|
|
42
|
+
material_agent.create_agent()
|
|
43
|
+
material_agent.run_example(True)
|
|
44
|
+
|