pycityagent 2.0.0a61__cp312-cp312-macosx_11_0_arm64.whl → 2.0.0a62__cp312-cp312-macosx_11_0_arm64.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.
- pycityagent/cityagent/message_intercept.py +16 -5
- {pycityagent-2.0.0a61.dist-info → pycityagent-2.0.0a62.dist-info}/METADATA +1 -1
- {pycityagent-2.0.0a61.dist-info → pycityagent-2.0.0a62.dist-info}/RECORD +7 -7
- {pycityagent-2.0.0a61.dist-info → pycityagent-2.0.0a62.dist-info}/LICENSE +0 -0
- {pycityagent-2.0.0a61.dist-info → pycityagent-2.0.0a62.dist-info}/WHEEL +0 -0
- {pycityagent-2.0.0a61.dist-info → pycityagent-2.0.0a62.dist-info}/entry_points.txt +0 -0
- {pycityagent-2.0.0a61.dist-info → pycityagent-2.0.0a62.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
import asyncio
|
2
|
+
import json
|
2
3
|
|
3
4
|
from pycityagent.llm import LLM
|
4
5
|
from pycityagent.message import MessageBlockBase, MessageBlockListenerBase
|
@@ -12,7 +13,7 @@ async def check_message(
|
|
12
13
|
返回: (是否合规, from_uuid, to_uuid)
|
13
14
|
"""
|
14
15
|
print(f"\n检查消息: {from_uuid} -> {to_uuid}: {content}")
|
15
|
-
|
16
|
+
is_valid = True
|
16
17
|
prompt = f"""
|
17
18
|
请判断以下消息是否具有情绪煽动性:
|
18
19
|
发送者ID: {from_uuid}
|
@@ -21,11 +22,21 @@ async def check_message(
|
|
21
22
|
|
22
23
|
如果消息具有情绪煽动性,请返回 False;如果消息正常,请返回 True。
|
23
24
|
"""
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
for _ in range(10):
|
26
|
+
try:
|
27
|
+
response: str = await llm_client.atext_request(
|
28
|
+
prompt, timeout=300
|
29
|
+
) # type:ignore
|
30
|
+
if "false" in response.lower():
|
31
|
+
is_valid = False
|
32
|
+
break
|
33
|
+
elif "true" in response.lower():
|
34
|
+
is_valid = True
|
35
|
+
break
|
36
|
+
except:
|
37
|
+
pass
|
27
38
|
else:
|
28
|
-
|
39
|
+
raise RuntimeError(f"Request for message interception prompt=`{prompt}` failed")
|
29
40
|
print(f"消息检查结果: {'合规' if is_valid else '不合规'}")
|
30
41
|
return is_valid
|
31
42
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: pycityagent
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.0a62
|
4
4
|
Summary: LLM-based city environment agent building library
|
5
5
|
Author-email: Yuwei Yan <pinkgranite86@gmail.com>, Junbo Yan <yanjb20thu@gmali.com>, Jun Zhang <zhangjun990222@gmali.com>
|
6
6
|
License: MIT License
|
@@ -82,7 +82,7 @@ pycityagent/cityagent/firmagent.py,sha256=UVlNN0lpa4cC4PZVqYzQhbc5VJ2oGsA1731mhb
|
|
82
82
|
pycityagent/cityagent/nbsagent.py,sha256=WIXW__6dZ5IrqBqDCjvGbrCshpXzuFRV3Ww6gkYw7p4,4387
|
83
83
|
pycityagent/cityagent/initial.py,sha256=7hgCt_tGdnVTXGfEQOn1GTW5dAs1b-ru_FwXxRLI6tM,4549
|
84
84
|
pycityagent/cityagent/societyagent.py,sha256=DKkPtCPXTpHs83hi3bvXxkQYxKqZI0YldYCyFu4yjsk,24811
|
85
|
-
pycityagent/cityagent/message_intercept.py,sha256=
|
85
|
+
pycityagent/cityagent/message_intercept.py,sha256=KqwW19zpPG8WMpiU91GAhJc9Gox3YgjFkTDokUFWAkw,3940
|
86
86
|
pycityagent/cityagent/governmentagent.py,sha256=HJLuhvEmllu_1KnFEJsYCIasaBJT0BV9Cn_4Y2QGPqg,2791
|
87
87
|
pycityagent/cityagent/blocks/dispatcher.py,sha256=mEa1r3tRS3KI1BMZR_w_sbUGzOj6aUJuiUrsHv1n2n0,2943
|
88
88
|
pycityagent/cityagent/blocks/needs_block.py,sha256=s8LikgtKORfo_Sw9SQ5_3biNPTof15QuUs4cDynXCyM,15332
|
@@ -97,9 +97,9 @@ pycityagent/cityagent/blocks/mobility_block.py,sha256=xWbARMfJ3-6fddrW3VOUKJrXfM
|
|
97
97
|
pycityagent/survey/models.py,sha256=YE50UUt5qJ0O_lIUsSY6XFCGUTkJVNu_L1gAhaCJ2fs,3546
|
98
98
|
pycityagent/survey/__init__.py,sha256=rxwou8U9KeFSP7rMzXtmtp2fVFZxK4Trzi-psx9LPIs,153
|
99
99
|
pycityagent/survey/manager.py,sha256=S5IkwTdelsdtZETChRcfCEczzwSrry_Fly9MY4s3rbk,1681
|
100
|
-
pycityagent-2.0.
|
101
|
-
pycityagent-2.0.
|
102
|
-
pycityagent-2.0.
|
103
|
-
pycityagent-2.0.
|
104
|
-
pycityagent-2.0.
|
105
|
-
pycityagent-2.0.
|
100
|
+
pycityagent-2.0.0a62.dist-info/RECORD,,
|
101
|
+
pycityagent-2.0.0a62.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
|
102
|
+
pycityagent-2.0.0a62.dist-info/WHEEL,sha256=VujM3ypTCyUW6hcTDdK2ej0ARVMxlU1Djlh_zWnDgqk,109
|
103
|
+
pycityagent-2.0.0a62.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
|
104
|
+
pycityagent-2.0.0a62.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
|
105
|
+
pycityagent-2.0.0a62.dist-info/METADATA,sha256=FhgUzevhPEKaFM0lB6XPQ3Fyoswe2V_7tjPsGzDjV-M,9110
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|