osis-python 0.1.0__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.
Files changed (55) hide show
  1. osis_python-0.1.0.dist-info/METADATA +64 -0
  2. osis_python-0.1.0.dist-info/RECORD +55 -0
  3. osis_python-0.1.0.dist-info/WHEEL +5 -0
  4. osis_python-0.1.0.dist-info/licenses/LICENSE +21 -0
  5. osis_python-0.1.0.dist-info/top_level.txt +1 -0
  6. pyosis/__init__.py +15 -0
  7. pyosis/ai/__init__.py +6 -0
  8. pyosis/ai/agents/BaseAgent.py +79 -0
  9. pyosis/ai/agents/DecisionAgent.py +189 -0
  10. pyosis/ai/agents/MaterialAgent.py +44 -0
  11. pyosis/ai/agents/ModelAgent.py +42 -0
  12. pyosis/ai/agents/QuickBuildingAgent.py +74 -0
  13. pyosis/ai/agents/SectionAgent.py +40 -0
  14. pyosis/ai/agents/__init__.py +0 -0
  15. pyosis/boundary/__init__.py +7 -0
  16. pyosis/boundary/interface.py +90 -0
  17. pyosis/control/__init__.py +1 -0
  18. pyosis/control/interface.py +182 -0
  19. pyosis/core/PyInterface.pyi +153 -0
  20. pyosis/core/__init__.py +12 -0
  21. pyosis/core/command.py +180 -0
  22. pyosis/core/engine.py +13 -0
  23. pyosis/element/__init__.py +1 -0
  24. pyosis/element/interface.py +220 -0
  25. pyosis/general/__init__.py +1 -0
  26. pyosis/general/interface.py +31 -0
  27. pyosis/live/__init__.py +3 -0
  28. pyosis/live/analysis.py +116 -0
  29. pyosis/live/grade.py +125 -0
  30. pyosis/live/lane.py +56 -0
  31. pyosis/load/__init__.py +3 -0
  32. pyosis/load/loadcase.py +59 -0
  33. pyosis/load/static.py +274 -0
  34. pyosis/load/tendon.py +325 -0
  35. pyosis/material/__init__.py +1 -0
  36. pyosis/material/interface.py +207 -0
  37. pyosis/node/__init__.py +1 -0
  38. pyosis/node/interface.py +51 -0
  39. pyosis/post/__init__.py +1 -0
  40. pyosis/post/interface.py +21 -0
  41. pyosis/property/__init__.py +0 -0
  42. pyosis/property/coordinate.py +5 -0
  43. pyosis/property/creep_shrink.py +53 -0
  44. pyosis/property/damping.py +37 -0
  45. pyosis/property/pu_curve.py +59 -0
  46. pyosis/quick_building/__init__.py +1 -0
  47. pyosis/quick_building/interface.py +298 -0
  48. pyosis/section/__init__.py +4 -0
  49. pyosis/section/common.py +325 -0
  50. pyosis/section/numeric.py +0 -0
  51. pyosis/section/param.py +96 -0
  52. pyosis/section/steel.py +0 -0
  53. pyosis/stage/__init__.py +3 -0
  54. pyosis/stage/define.py +123 -0
  55. pyosis/stage/overall.py +85 -0
@@ -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,55 @@
1
+ osis_python-0.1.0.dist-info/licenses/LICENSE,sha256=1KNXhaRdSyN3J-czGUxuAufGyzuSt8i1ucA9exR9ErQ,1108
2
+ pyosis/__init__.py,sha256=KMNJXqbfFe-EoaW0cgDjI_Y6DFcYrc2fyuEMySVuXWY,418
3
+ pyosis/ai/__init__.py,sha256=F8JuPPOZg622KKtVW3SXeOMu12uPAss6xpJR2o1c3v8,52
4
+ pyosis/ai/agents/BaseAgent.py,sha256=C9WYzh6--2Gl7Rpm93kJyKtSwSzSDoCl6qGEbWt-q4w,3727
5
+ pyosis/ai/agents/DecisionAgent.py,sha256=VHe3AQ5Tx86bYGTFcUuHFa7VWvqRhf4Kq3R6p7vNHVU,7924
6
+ pyosis/ai/agents/MaterialAgent.py,sha256=4UTiIcv8yIEJdXYG2TzXuEUTjSub3Z_YHnxztbpR9eg,1727
7
+ pyosis/ai/agents/ModelAgent.py,sha256=WM5W-qRABrPI4yPoFGkijdhg-IFM-h-LuNPSpiGgA5c,1680
8
+ pyosis/ai/agents/QuickBuildingAgent.py,sha256=rpPaymWL7QeTMxPdVc9syc4gdap7OMDl0McqGNokv-U,2845
9
+ pyosis/ai/agents/SectionAgent.py,sha256=RkPsuBQy0EqnSELhDb9oF2b7wMWhN8kTN73fHmOgwt0,1474
10
+ pyosis/ai/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ pyosis/boundary/__init__.py,sha256=1ruHAqESmajvyTWcG1sySJAv9H2k8Xl8ZZbSVpwl1cE,71
12
+ pyosis/boundary/interface.py,sha256=0L9acFFR-Re3paLdTrNKImvM_hNb90DNccVE7RnfbP0,3031
13
+ pyosis/control/__init__.py,sha256=dyvge-GgUpT3BeDwm_Lss1xqNlxAQdt63WJ7QcuZ_O4,24
14
+ pyosis/control/interface.py,sha256=c1G4RrOiNGAU_sn7ok54UBeV7-GQfjhhD0Ybhnmc_Ik,3768
15
+ pyosis/core/PyInterface.pyi,sha256=G6RGmYo2k2rCzEGinn3MQLhkZyHrNA7ycwQU9hsx6Fg,6211
16
+ pyosis/core/__init__.py,sha256=6oA_VA9LRvj8Ok3akC_rUoOMDOLsdzoANNIB0LnPkO4,420
17
+ pyosis/core/command.py,sha256=dvyMc0UpG7eFfgsZVlm7PM3XoLMs4BTsPBvNVyRokBY,6730
18
+ pyosis/core/engine.py,sha256=kSg6vCkxoP_560-oEDEUnT9p3cZz6-IO0AdsJqjVhMM,522
19
+ pyosis/element/__init__.py,sha256=dyvge-GgUpT3BeDwm_Lss1xqNlxAQdt63WJ7QcuZ_O4,24
20
+ pyosis/element/interface.py,sha256=8opOnue2OJfTqy9l5EgU70ktyfhym19O2bJhWj7caJU,8860
21
+ pyosis/general/__init__.py,sha256=dyvge-GgUpT3BeDwm_Lss1xqNlxAQdt63WJ7QcuZ_O4,24
22
+ pyosis/general/interface.py,sha256=MKM3DVCOkx8t_ISJCo2qCMnoyJ-aGkzyW3q7xQTH_ok,553
23
+ pyosis/live/__init__.py,sha256=VSn2AhvIcGbsyLIlhktUyLRJABKqTwFc6zZx5O828VA,66
24
+ pyosis/live/analysis.py,sha256=A9ND6yTir3o7JIE3zGP1aJfJeMEDGCjYYkRuUmVB82Q,4468
25
+ pyosis/live/grade.py,sha256=Fv5o2YooL5uO5f1YM7mO5d5kgAQ0IXaJlleNBSe9z7M,4329
26
+ pyosis/live/lane.py,sha256=W8B-6Myyb12BSFwfzjErMqBApuHfreqjNECzXdSFLZo,1678
27
+ pyosis/load/__init__.py,sha256=lf-dhGcE9lOFARlHK6O459YY91mFgyx2k8hQy8tkx2w,69
28
+ pyosis/load/loadcase.py,sha256=I2ZQ54uXOoOh6DJ4oOv8JK-JwcCS76QVRw5mDr3UQMw,1585
29
+ pyosis/load/static.py,sha256=eVD_bmOiKHsjJ2RRFYg2LbxPM6_F1Gi2eRw3rCrGKxg,11264
30
+ pyosis/load/tendon.py,sha256=fvcoY15SL1nSycPiNuhjcunCIuWP4HVvyU_S-zAsEdE,11837
31
+ pyosis/material/__init__.py,sha256=dyvge-GgUpT3BeDwm_Lss1xqNlxAQdt63WJ7QcuZ_O4,24
32
+ pyosis/material/interface.py,sha256=rnh39VE7y-VnrUrndB-vgyUQE-rTnfYDSWs5LQBKB7U,8325
33
+ pyosis/node/__init__.py,sha256=dyvge-GgUpT3BeDwm_Lss1xqNlxAQdt63WJ7QcuZ_O4,24
34
+ pyosis/node/interface.py,sha256=BuwoH7V876gBZIoB_6miG5W7r0id0Tm2Fi4b6iIS9vA,1267
35
+ pyosis/post/__init__.py,sha256=dyvge-GgUpT3BeDwm_Lss1xqNlxAQdt63WJ7QcuZ_O4,24
36
+ pyosis/post/interface.py,sha256=9MbRgCs7O0qH12C3nrw1pCiHx45BP52LbGPEmCYrsJI,860
37
+ pyosis/property/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ pyosis/property/coordinate.py,sha256=ASfVBE6fIS_nEzzH3NfF_J9EcMauHcvMe2gBvyLF6Jw,69
39
+ pyosis/property/creep_shrink.py,sha256=S-udAbxeJjNXuNtVEEMZTuuTC7eALIGodNi4gbpWD1E,1513
40
+ pyosis/property/damping.py,sha256=KXcNfLUXrRXsFd45Ai7hTw3l4xbXFswhT5HfuiHZjUs,822
41
+ pyosis/property/pu_curve.py,sha256=d-ETXtU4TxXWVqJmbi-a_oP1ZsqZ_L8HkCXQEBbg1eQ,1587
42
+ pyosis/quick_building/__init__.py,sha256=dyvge-GgUpT3BeDwm_Lss1xqNlxAQdt63WJ7QcuZ_O4,24
43
+ pyosis/quick_building/interface.py,sha256=XEXgPxgNwZzgrc-jDi2FpC5Oqe5IP-5HleqsERcEOwU,13957
44
+ pyosis/section/__init__.py,sha256=JMkVPheKBR9CVjfPtQkEzxzL8EcNKm85PL99pcEXE1s,89
45
+ pyosis/section/common.py,sha256=dmpWREBp1nqYT4KWCzPZrKinG68N1tTy8gpJStCG99I,13382
46
+ pyosis/section/numeric.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
+ pyosis/section/param.py,sha256=uSeL20vQCStokrByES99ASECfzDv17q0fCvPugCulaE,3067
48
+ pyosis/section/steel.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
+ pyosis/stage/__init__.py,sha256=HJMZj4xCKlI7c0rXkLn0HlVP_Mop44FHQdFyEClSrNc,47
50
+ pyosis/stage/define.py,sha256=vQu5h7ptRVNyTQuDbRKxUCi4rCV5CtQGjTLT5PUJOdg,4078
51
+ pyosis/stage/overall.py,sha256=dWpa8Z5rmB5WC8QmrWOdX4YZ7vxzHGHompO_IHOi3Ow,2206
52
+ osis_python-0.1.0.dist-info/METADATA,sha256=9-V0rZU4fgQFeVLuKrvCnrTjWvMSRAb1-4vTjfMknMI,2775
53
+ osis_python-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
54
+ osis_python-0.1.0.dist-info/top_level.txt,sha256=6VDNySkQKwipRXcN8ayKVci4vAXi4oPyWLqFhNVcIfM,7
55
+ osis_python-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -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 @@
1
+ pyosis
pyosis/__init__.py ADDED
@@ -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
pyosis/ai/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ """
2
+ pyosis.ai
3
+
4
+ ========
5
+ OSIS AI相关功能
6
+ """
@@ -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
+
@@ -0,0 +1,42 @@
1
+ from langchain.tools import tool
2
+ from .BaseAgent import BaseAgent
3
+ from ...node import *
4
+ from ...element import *
5
+
6
+ class ModelAgent(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_node),
14
+ tool(osis_node_del),
15
+ tool(osis_node_mod),
16
+
17
+ tool(osis_element_beam3d),
18
+ tool(osis_element_cable),
19
+ tool(osis_element_truss),
20
+ tool(osis_element_spring),
21
+ tool(osis_element_shell),
22
+ tool(osis_element_del),
23
+ tool(osis_element_mod)
24
+ ]
25
+ system_prompt = \
26
+ """
27
+ 你是桥梁模型设计专家,负责创建桥梁的节点和单元,组成完整结构模型。
28
+
29
+ 重要依赖关系:
30
+ - 创建模型前必须确保材料和截面已经创建
31
+ - 需要使用已创建的材料编号和截面编号,如果没有提供给你,终止调用并告诉决策智能体
32
+ - 创建单元前一定要确保使用的节点已经创建
33
+
34
+ 工作流程:
35
+ - 创建任何对象时编号从1递增
36
+ - 用户未规定的参数使用默认参数
37
+ - 若用户要修改对象,直接重新调用一次创建函数,参数中指定要修改的对象编号即可
38
+ - 若用户未说明,假设用户希望创建一个跨度为10米,分为10个单元的简单悬浇梁结构,则你需要创建11个节点和10个单元。
39
+
40
+ 创建成功后,请告知决策智能体。创建失败后,请告知失败原因。
41
+ """
42
+ super().create_agent(tools, system_prompt)
@@ -0,0 +1,74 @@
1
+ from langchain.tools import tool
2
+ from .BaseAgent import BaseAgent
3
+ from ...quick_building import *
4
+
5
+
6
+ class QuickBuildingAgent(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_set_qb_bridge_type),
14
+ tool(osis_set_qb_overall),
15
+ tool(osis_set_qb_portrait),
16
+ tool(osis_set_qb_load),
17
+ tool(osis_set_qb_tendon),
18
+ tool(osis_set_qb_stage),
19
+ tool(osis_create_qb_bridge)
20
+ ]
21
+ system_prompt = \
22
+ """
23
+ 你是快速建模助手,负责配合用户调用几个快速建模函数,可调用以下功能模块:
24
+
25
+ __桥梁类型设置__ `osis_set_qb_bridge_type(eBridgeType)`
26
+
27
+ - 支持类型:HOLLOWSLAB(空心板), SMALLBOXBEAM(小箱梁), TBEAM(T梁), CONTINUOUSSMALLBOXBEAM(连续小箱梁), CONTINUOUSTBEAM(连续T梁)
28
+
29
+ __总体参数配置__ `osis_set_qb_overall(eBridgeType, 跨径列表, 是否弹性连接, 支座刚度参数...)`
30
+
31
+ - 简支桥:单跨参数列表
32
+ - 连续桥:多跨参数列表
33
+ - 弹性连接需设置支座刚度
34
+
35
+ __纵向参数设置__ `osis_set_qb_portrait(eBridgeType, 单元尺寸范围, 结构尺寸参数...)`
36
+
37
+ - 控制单元划分和结构几何参数
38
+
39
+ __荷载配置__ `osis_set_qb_load(eBridgeType, 荷载参数...)`
40
+
41
+ - 通过零/非零值控制荷载类型启用
42
+ - 温度效应需同时设置升温/降温值
43
+
44
+ __钢束设置__ `osis_set_qb_tendon(eBridgeType, 钢束参数列表)`
45
+
46
+ - 每个钢束包含名称、属性、几何参数、应力等详细信息
47
+
48
+ __施工阶段设置__ `osis_set_qb_stage(eBridgeType, 阶段参数列表)`
49
+
50
+ - 定义施工顺序、持续时间和荷载状态
51
+
52
+ __快速建模函数__ `osis_create_qb_bridge` - 按照设置好的参数创建标准桥型
53
+
54
+ 操作流程:
55
+
56
+ - 首先通过 osis_set_qb_bridge_type 设定桥梁类型
57
+
58
+ - 如果用户有特别要求,比如修改某个参数,则只需要调用该参数的对应功能模块来修改,除了要修改的参数外,其他参数不用修改
59
+
60
+ - 如果用户没有特别要求,直接调用 osis_create_qb_bridge 创建即可,其他函数不用调用,皆被默认设置好了
61
+
62
+ - 用户想在原桥梁修改某些参数时,只需要再次调用该参数的对应功能模块来修改即可
63
+
64
+ - 用户想创建新的桥梁时,重新调用 osis_set_qb_bridge_type 来设定桥梁类型,会自动清空旧桥梁数据
65
+
66
+
67
+ 错误处理:
68
+
69
+ - 检查函数返回的(成功标志, 错误信息)元组
70
+ - 处理OSISEngine引擎层错误
71
+ - 创建成功后,请告知用户。创建失败后,请告知失败原因。
72
+
73
+ """
74
+ super().create_agent(tools, system_prompt)
@@ -0,0 +1,40 @@
1
+ from langchain.tools import tool
2
+ from .BaseAgent import BaseAgent
3
+ from ...section import *
4
+
5
+
6
+ class SectionAgent(BaseAgent):
7
+ """截面设计智能体"""
8
+ def __init__(self, model="qwen-turbo", api_key="", base_url=""):
9
+ super().__init__(model, api_key, base_url)
10
+
11
+ def create_agent(self):
12
+ tools = [
13
+ tool(osis_section_circle),
14
+ tool(osis_section_Ishape),
15
+ tool(osis_section_Lshape),
16
+ tool(osis_section_Tshape),
17
+ tool(osis_section_smallbox),
18
+ tool(osis_section_hollowslab),
19
+ tool(osis_section_custom),
20
+
21
+ tool(osis_section_offset),
22
+ tool(osis_section_mesh),
23
+ tool(osis_section_del),
24
+ tool(osis_section_mod)
25
+ ]
26
+ system_prompt = \
27
+ """
28
+ 你是截面设计专家,负责桥梁截面的创建和管理。你需要配合决策智能体完成桥梁截面的创建与修改工作。
29
+
30
+ 注意事项:
31
+ - 创建任何对象时编号从1递增
32
+ - 创建截面时,若用户没有明确要求,必须同时设置截面偏移和网格划分参数
33
+ - 若用户有修改需求,不需要重新调用所有函数,只重新调用参数改变的函数即可
34
+ - 若用户没规定,参数全部使用默认值
35
+ - 默认创建矩形截面
36
+
37
+ 创建成功后,请告知决策智能体。创建失败后,请告知失败原因。
38
+ """
39
+ super().create_agent(tools, system_prompt)
40
+
File without changes
@@ -0,0 +1,7 @@
1
+ '''
2
+ pyosis.boundary 的 Docstring
3
+
4
+ '''
5
+
6
+
7
+ from .interface import *