pycityagent 1.0.0__py3-none-any.whl → 2.0.0a1__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.
- pycityagent/__init__.py +7 -3
- pycityagent/agent.py +180 -284
- pycityagent/economy/__init__.py +5 -0
- pycityagent/economy/econ_client.py +307 -0
- pycityagent/environment/__init__.py +7 -0
- pycityagent/environment/interact/interact.py +141 -0
- pycityagent/environment/sence/__init__.py +0 -0
- pycityagent/{brain → environment/sence}/static.py +1 -1
- pycityagent/environment/sidecar/__init__.py +8 -0
- pycityagent/environment/sidecar/sidecarv2.py +109 -0
- pycityagent/environment/sim/__init__.py +27 -0
- pycityagent/environment/sim/aoi_service.py +38 -0
- pycityagent/environment/sim/client.py +126 -0
- pycityagent/environment/sim/clock_service.py +43 -0
- pycityagent/environment/sim/economy_services.py +191 -0
- pycityagent/environment/sim/lane_service.py +110 -0
- pycityagent/environment/sim/light_service.py +120 -0
- pycityagent/environment/sim/person_service.py +294 -0
- pycityagent/environment/sim/road_service.py +38 -0
- pycityagent/environment/sim/social_service.py +58 -0
- pycityagent/environment/simulator.py +369 -0
- pycityagent/environment/utils/__init__.py +8 -0
- pycityagent/environment/utils/geojson.py +26 -0
- pycityagent/environment/utils/grpc.py +57 -0
- pycityagent/environment/utils/map_utils.py +157 -0
- pycityagent/environment/utils/protobuf.py +39 -0
- pycityagent/llm/__init__.py +6 -0
- pycityagent/llm/embedding.py +136 -0
- pycityagent/llm/llm.py +430 -0
- pycityagent/llm/llmconfig.py +15 -0
- pycityagent/llm/utils.py +6 -0
- pycityagent/memory/__init__.py +11 -0
- pycityagent/memory/const.py +41 -0
- pycityagent/memory/memory.py +453 -0
- pycityagent/memory/memory_base.py +168 -0
- pycityagent/memory/profile.py +165 -0
- pycityagent/memory/self_define.py +165 -0
- pycityagent/memory/state.py +173 -0
- pycityagent/memory/utils.py +27 -0
- pycityagent/message/__init__.py +0 -0
- pycityagent/simulation/__init__.py +7 -0
- pycityagent/simulation/interview.py +36 -0
- pycityagent/simulation/simulation.py +286 -0
- pycityagent/simulation/survey/__init__.py +9 -0
- pycityagent/simulation/survey/manager.py +67 -0
- pycityagent/simulation/survey/models.py +49 -0
- pycityagent/simulation/ui/__init__.py +3 -0
- pycityagent/simulation/ui/interface.py +602 -0
- pycityagent/utils/__init__.py +0 -0
- pycityagent/utils/decorators.py +89 -0
- pycityagent/utils/parsers/__init__.py +12 -0
- pycityagent/utils/parsers/code_block_parser.py +37 -0
- pycityagent/utils/parsers/json_parser.py +86 -0
- pycityagent/utils/parsers/parser_base.py +60 -0
- pycityagent/workflow/__init__.py +22 -0
- pycityagent/workflow/block.py +137 -0
- pycityagent/workflow/prompt.py +72 -0
- pycityagent/workflow/tool.py +246 -0
- pycityagent/workflow/trigger.py +66 -0
- pycityagent-2.0.0a1.dist-info/METADATA +208 -0
- pycityagent-2.0.0a1.dist-info/RECORD +65 -0
- {pycityagent-1.0.0.dist-info → pycityagent-2.0.0a1.dist-info}/WHEEL +1 -2
- pycityagent/ac/__init__.py +0 -6
- pycityagent/ac/ac.py +0 -50
- pycityagent/ac/action.py +0 -14
- pycityagent/ac/controled.py +0 -13
- pycityagent/ac/converse.py +0 -31
- pycityagent/ac/idle.py +0 -17
- pycityagent/ac/shop.py +0 -80
- pycityagent/ac/trip.py +0 -37
- pycityagent/brain/__init__.py +0 -10
- pycityagent/brain/brain.py +0 -52
- pycityagent/brain/brainfc.py +0 -10
- pycityagent/brain/memory.py +0 -541
- pycityagent/brain/persistence/social.py +0 -1
- pycityagent/brain/persistence/spatial.py +0 -14
- pycityagent/brain/reason/shop.py +0 -37
- pycityagent/brain/reason/social.py +0 -148
- pycityagent/brain/reason/trip.py +0 -67
- pycityagent/brain/reason/user.py +0 -122
- pycityagent/brain/retrive/social.py +0 -6
- pycityagent/brain/scheduler.py +0 -408
- pycityagent/brain/sence.py +0 -375
- pycityagent/cc/__init__.py +0 -5
- pycityagent/cc/cc.py +0 -102
- pycityagent/cc/conve.py +0 -6
- pycityagent/cc/idle.py +0 -20
- pycityagent/cc/shop.py +0 -6
- pycityagent/cc/trip.py +0 -13
- pycityagent/cc/user.py +0 -13
- pycityagent/hubconnector/__init__.py +0 -3
- pycityagent/hubconnector/hubconnector.py +0 -137
- pycityagent/image/__init__.py +0 -3
- pycityagent/image/image.py +0 -158
- pycityagent/simulator.py +0 -161
- pycityagent/st/__init__.py +0 -4
- pycityagent/st/st.py +0 -96
- pycityagent/urbanllm/__init__.py +0 -3
- pycityagent/urbanllm/urbanllm.py +0 -132
- pycityagent-1.0.0.dist-info/LICENSE +0 -21
- pycityagent-1.0.0.dist-info/METADATA +0 -181
- pycityagent-1.0.0.dist-info/RECORD +0 -48
- pycityagent-1.0.0.dist-info/top_level.txt +0 -1
- /pycityagent/{brain/persistence/__init__.py → config.py} +0 -0
- /pycityagent/{brain/reason → environment/interact}/__init__.py +0 -0
- /pycityagent/{brain/retrive → environment/message}/__init__.py +0 -0
@@ -1,181 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: pycityagent
|
3
|
-
Version: 1.0.0
|
4
|
-
Summary: LLM-based城市模拟器agent构建库
|
5
|
-
Author-email: Yuwei Yan <pinkgranite86@gmail.com>
|
6
|
-
License: MIT License
|
7
|
-
|
8
|
-
Copyright (c) 2024 FIBLAB
|
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
|
-
|
28
|
-
Project-URL: Homepage, https://github.com/tsinghua-fib-lab/pycityagent
|
29
|
-
Project-URL: Repository, https://github.com/tsinghua-fib-lab/pycityagent.git
|
30
|
-
Project-URL: Issues, https://github.com/tsinghua-fib-lab/pycityagent/issues
|
31
|
-
Keywords: agent,city,LLM
|
32
|
-
Classifier: Programming Language :: Python :: 3
|
33
|
-
Classifier: Operating System :: OS Independent
|
34
|
-
Requires-Python: >=3.8
|
35
|
-
Description-Content-Type: text/markdown
|
36
|
-
License-File: LICENSE
|
37
|
-
Requires-Dist: dashscope >=1.14.0
|
38
|
-
Requires-Dist: geojson >=3.1.0
|
39
|
-
Requires-Dist: numpy >=1.26.3
|
40
|
-
Requires-Dist: openai >=1.8.0
|
41
|
-
Requires-Dist: Pillow >=10.2.0
|
42
|
-
Requires-Dist: pycitysim >=1.8.0
|
43
|
-
Requires-Dist: citystreetview >=1.1.0
|
44
|
-
Requires-Dist: PyYAML >=6.0.1
|
45
|
-
Requires-Dist: Requests >=2.31.0
|
46
|
-
Requires-Dist: transitions >=0.9.0
|
47
|
-
|
48
|
-
# Pycityagent
|
49
|
-
|
50
|
-
# Table of Contents
|
51
|
-
* [Introduction](#Introduction)
|
52
|
-
* [The Whole Framework of CityAgent](#The-Whole-Framework-of-CityAgent)
|
53
|
-
* [The Workflow of CityAgent](#The-Workflow-of-CityAgent)
|
54
|
-
* [Hands On - By An Easy Demo](#Hands-On---By-An-Easy-Demo)
|
55
|
-
|
56
|
-
<!-- TOC -->
|
57
|
-
|
58
|
-
## Introduction
|
59
|
-
### Framework of CityAgent
|
60
|
-
- 
|
61
|
-
|
62
|
-
### Workflow of CityAgent
|
63
|
-
- 
|
64
|
-
|
65
|
-
## Hands On - By An Easy Demo
|
66
|
-
### Apply for your App
|
67
|
-
- You first need to register your account in the [Opencity website](https://opencity.fiblab.net/)
|
68
|
-
- Login to the console, create your own app.
|
69
|
-
- Get your app_id and app_secret
|
70
|
-
- 
|
71
|
-
|
72
|
-
### Get your Config
|
73
|
-
- There are three parts of a config file: **llm_request**, **citysim_request** and **apphub_request**
|
74
|
-
```yaml
|
75
|
-
llm_request:
|
76
|
-
text_request:
|
77
|
-
request_type: qwen
|
78
|
-
api_key: xxx
|
79
|
-
model: xxx
|
80
|
-
img_understand_request:
|
81
|
-
request_type: qwen
|
82
|
-
api_key: xxx
|
83
|
-
model: xxx
|
84
|
-
img_generate_request:
|
85
|
-
request_type: qwen
|
86
|
-
api_key: xxx
|
87
|
-
model: xxx
|
88
|
-
|
89
|
-
citysim_request:
|
90
|
-
simulator:
|
91
|
-
server: https://api-opencity-2x.fiblab.net:58081
|
92
|
-
map_request:
|
93
|
-
mongo_coll: map_beijing_extend_20240205
|
94
|
-
cache_dir: ./cache
|
95
|
-
streetview_request:
|
96
|
-
engine: baidumap / googlemap
|
97
|
-
mapAK: your baidumap AK (if baidumap)
|
98
|
-
proxy: your googlemap proxy (if googlemap, optional)
|
99
|
-
|
100
|
-
apphub_request:
|
101
|
-
hub_url: https://api-opencity-2x.fiblab.net:58080
|
102
|
-
app_id: your APP ID
|
103
|
-
app_secret: your APP Secret
|
104
|
-
profile_image: the profile image of your agent
|
105
|
-
```
|
106
|
-
- Forget about **citysim_request**, let's focus on the other two.
|
107
|
-
|
108
|
-
#### LLM_REQUEST
|
109
|
-
- As you can tell, the whole CityAgent is based on the LLM, by now, there are three different parts of config items: **text_request**, **img_understand_request** and **img_generate_request**
|
110
|
-
- By now, we support [**qwen**](https://tongyi.aliyun.com/) and [**openai**](https://openai.com/)
|
111
|
-
- `Notice: Our environments are basically conducted with qwen. If you prefer to use openai, then you may encounter hardships. AND fell free to issue us.`
|
112
|
-
- Get your **api_key** and chooce your **model**s
|
113
|
-
|
114
|
-
### CITYSIM_REQUEST
|
115
|
-
- There are no need to change the 'simulator' and 'map_request' config
|
116
|
-
- 'streetview_request': this is the config used for streetview
|
117
|
-
- By now, we support 'baidumap' and 'googlemap'
|
118
|
-
- If you use 'baidumap', then you need to apply for a mapAK
|
119
|
-
- If you use 'googlemap', then you can config your own proxy by 'proxy' attribute
|
120
|
-
|
121
|
-
#### APPHUB_REQUEST
|
122
|
-
- This is basically used to connect with the backend.
|
123
|
-
- Put your **app_id** and **app_secret** here.
|
124
|
-
|
125
|
-
### Installation
|
126
|
-
- Install from **pip** easily.
|
127
|
-
```shell
|
128
|
-
pip install pycityagent
|
129
|
-
```
|
130
|
-
|
131
|
-
### CODE and RUN
|
132
|
-
- Check the **example** folder and copy files from it (`Remember replace the config file`)
|
133
|
-
- Look at the Demo:
|
134
|
-
```python
|
135
|
-
import yaml
|
136
|
-
from pycityagent.simulator import Simulator
|
137
|
-
from pycityagent.urbanllm import LLMConfig, UrbanLLM
|
138
|
-
import asyncio
|
139
|
-
import time
|
140
|
-
|
141
|
-
async def main():
|
142
|
-
# load your config
|
143
|
-
with open('config_template.yaml', 'r') as file:
|
144
|
-
config = yaml.safe_load(file)
|
145
|
-
|
146
|
-
# get the simulator object
|
147
|
-
smi = Simulator(config['citysim_request'])
|
148
|
-
|
149
|
-
# get the person by person_id, return agent
|
150
|
-
agent = await smi.GetAgent("name_of_agent", 8)
|
151
|
-
|
152
|
-
# Help you build unique agent by scratch/profile
|
153
|
-
agent.Image.load_scratch('scratch_template.json')
|
154
|
-
|
155
|
-
# Load Memory and assist the agent to understand "Opencity"
|
156
|
-
agent.Brain.Memory.Spatial.MemoryLoad('spatial_knowledge_template.json')
|
157
|
-
agent.Brain.Memory.Social.MemoryLoad('social_background_template.json')
|
158
|
-
|
159
|
-
# Connect to apphub so you can interact with your agent in front end
|
160
|
-
agent.ConnectToHub(config['apphub_request'])
|
161
|
-
|
162
|
-
# Creat the soul (a LLM processor actually)
|
163
|
-
llmConfig = LLMConfig(config['llm_request'])
|
164
|
-
soul = UrbanLLM(llmConfig)
|
165
|
-
|
166
|
-
# Add the soul to your agent
|
167
|
-
agent.add_soul(soul)
|
168
|
-
|
169
|
-
# Start and have fun with it!!!
|
170
|
-
while True:
|
171
|
-
await agent.Run()
|
172
|
-
time.sleep(1)
|
173
|
-
|
174
|
-
if __name__ == '__main__':
|
175
|
-
asyncio.run(main())
|
176
|
-
```
|
177
|
-
|
178
|
-
### Congratulations
|
179
|
-
- Following this "Hands On" guide, you have easily created an agent by your hand!
|
180
|
-
- You can observe your AGENT in your console or in the [Opencity website](https://opencity.fiblab.net/).
|
181
|
-
- HAVE FUN WITH IT!
|
@@ -1,48 +0,0 @@
|
|
1
|
-
pycityagent/__init__.py,sha256=AUksztmIqz0WYM9wNuO0WYZCNygPuhnQsRiqDmG3nTA,87
|
2
|
-
pycityagent/agent.py,sha256=B_AK49HvdqbTiyvPZ3MRq8XID3qjhkjsywsJ-fNWB6Y,9637
|
3
|
-
pycityagent/simulator.py,sha256=PbkgpeE6rwLxXSdEsGd60cc0kzw1zrgv9sifug9zHEU,5542
|
4
|
-
pycityagent/ac/__init__.py,sha256=vzDpFox7x96yhhwUro7dWQvv1ztUzNjlnYovLSTV0lQ,141
|
5
|
-
pycityagent/ac/ac.py,sha256=l7aas0w4UmSCXoXcSzp7md73zk9aRTxYK0Ev6ep7zMI,1574
|
6
|
-
pycityagent/ac/action.py,sha256=MxdDo0BS_dZZgvNTmYK6SSV4oLn0OVdciEb5nBMtMrg,324
|
7
|
-
pycityagent/ac/controled.py,sha256=Q9wLPK0HgUO6w551c6gZNPNwtZMWojG3867m7Oy0cVM,539
|
8
|
-
pycityagent/ac/converse.py,sha256=IotnC3kwCcCk8-oOuIJOeYBPCVR9lItjci18TX1GGR0,1252
|
9
|
-
pycityagent/ac/idle.py,sha256=TU67IWSN_DM1aCdMf6xkXX5uSTPgFIUCVwvxAxN03e0,504
|
10
|
-
pycityagent/ac/shop.py,sha256=i9nReY47wgVOMcmi_wp0W9M_dNoXmHpyEo93mC1K6ok,4095
|
11
|
-
pycityagent/ac/trip.py,sha256=AGdSgqw5CVFVyu_DPnaOY-fK6fTZsOCiA9aVUIAS9VU,1527
|
12
|
-
pycityagent/brain/__init__.py,sha256=3uAqrqRQE6mmhFzcTRygE-J5IxZz6tIWyF4WL1M3iSg,348
|
13
|
-
pycityagent/brain/brain.py,sha256=WlIcp79ZbiWL47ubdVeXtUvQmzb0Rzluwq3tT2LjHBo,1067
|
14
|
-
pycityagent/brain/brainfc.py,sha256=XoiNUQgP4P7ui9dRZWTfzyzBVTDYZf10XqM7kot0Dbg,252
|
15
|
-
pycityagent/brain/memory.py,sha256=7qubt5kmn9lzFD75OwmePhtLXsO_HGYhxlRbbTfJtBY,19125
|
16
|
-
pycityagent/brain/scheduler.py,sha256=56T78XrIdZb7qdlKPkNB-ibKH36ooEqHyHcp2jlID90,18492
|
17
|
-
pycityagent/brain/sence.py,sha256=TX6t4zn_c8Diwo8UlCmaZ7U4OH4RAmzpZERrTYtcIqA,13715
|
18
|
-
pycityagent/brain/static.py,sha256=vvPaJGKqTBqNe_N3LTFdDjgjjdeZb5niFrYUhGBsGD4,29081
|
19
|
-
pycityagent/brain/persistence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
-
pycityagent/brain/persistence/social.py,sha256=6hJi14sFm4LOU1JlnX8Vq_jFv7VII1uHDM9lrt7-JDA,27
|
21
|
-
pycityagent/brain/persistence/spatial.py,sha256=KShHehHOpvUnqxr12Y1FJF4RgyPjD3QNlWw136-zGR0,549
|
22
|
-
pycityagent/brain/reason/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
|
-
pycityagent/brain/reason/shop.py,sha256=jd0p6MDCNTPxo5j8glopiB501l8AuGP1vFlfDcxX69A,777
|
24
|
-
pycityagent/brain/reason/social.py,sha256=6QceFlzrA8FNwKzEvVS2aivSr12rkMbyOFO4mlACCfk,6493
|
25
|
-
pycityagent/brain/reason/trip.py,sha256=Slop2IxwZ9KE8ZqMOfYbMAgZ2hUcs4LuesxecoSliPc,1543
|
26
|
-
pycityagent/brain/reason/user.py,sha256=m1CQrG_Y-guB0WNeF1pR1HmzyPVrX4qAnuMIRl9-5ig,6412
|
27
|
-
pycityagent/brain/retrive/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
|
-
pycityagent/brain/retrive/social.py,sha256=EfF_9VCPTnDHBd2c5OmH3L4--07Ctps5HJBpSO3hUAA,135
|
29
|
-
pycityagent/cc/__init__.py,sha256=eNYRAjU_IIJY1Nt2vGyt34KQjbrpyZuv_AvY_iuPb6A,123
|
30
|
-
pycityagent/cc/cc.py,sha256=b2_Q4dpPO8F1tY-N1m-YFfdzEu_dg8AYsjihvhrWijM,4201
|
31
|
-
pycityagent/cc/conve.py,sha256=sRhZleIGeAV2m6mWoevwUMx2wD0xLVF5qnCld6pDC2E,150
|
32
|
-
pycityagent/cc/idle.py,sha256=RbqwG4BdSpLdZ-_13mLMbUs20q8r5drKB4wNIGWPOZw,474
|
33
|
-
pycityagent/cc/shop.py,sha256=9c8XTcUZBV90N_0MF3Gi9jlUS0LqNR3vIazEkK8tA28,149
|
34
|
-
pycityagent/cc/trip.py,sha256=ayTUnED7Kq6qiwEfCO_u-Hz6rRFNzBI25dZGUSV5dJY,312
|
35
|
-
pycityagent/cc/user.py,sha256=nS9NFfZypvXf-vLzqnYzLc6ek-CS8WALtEb00s1nREI,285
|
36
|
-
pycityagent/hubconnector/__init__.py,sha256=O11GJiILTibDUgJiAZxfIZ0kckKvToPUYijd06RQ0iQ,53
|
37
|
-
pycityagent/hubconnector/hubconnector.py,sha256=U8sN9_XX0UVuKaKW57_rmst87XjGlCy79Ar5LQQOnJ4,5259
|
38
|
-
pycityagent/image/__init__.py,sha256=OiSQBalg4Uo8bjjLNaUWb_DjSb-Rg8yGfb8Su6Sdvo4,58
|
39
|
-
pycityagent/image/image.py,sha256=0efdbmQCGwqPb2WmBcRIjDu0miTSOPEkOGUKyZaDg58,5225
|
40
|
-
pycityagent/st/__init__.py,sha256=YzsQXrgqRvmoQ4dWqAztAriKd8wvnQVe0FOpX_oZmiY,109
|
41
|
-
pycityagent/st/st.py,sha256=bGisgrBaKEQCUMobRcBqIPh_4N5I0GIVc1mGglSwBO8,3743
|
42
|
-
pycityagent/urbanllm/__init__.py,sha256=D24mYFXdIEL2vbvB7Cp_BGgJvg-tvEnCgtEAAGaqGDY,56
|
43
|
-
pycityagent/urbanllm/urbanllm.py,sha256=XEmU4fpdxA7zZlSfdXnXd9SIsPF0eC1SjxPKHAjxuAE,4341
|
44
|
-
pycityagent-1.0.0.dist-info/LICENSE,sha256=Yo9QmwLDFU3VoOc0W8aYSCa5Yj5sJyqM3FEcbC2jMQQ,1063
|
45
|
-
pycityagent-1.0.0.dist-info/METADATA,sha256=jWCBLBIrjSOqPSIouNDA__kUnLfIwRd4JfwXeBgHMKU,6460
|
46
|
-
pycityagent-1.0.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
47
|
-
pycityagent-1.0.0.dist-info/top_level.txt,sha256=mf70CsOn3eVJBwHQ_TjCesoc-elD0Bj2WLsi5APRjlU,12
|
48
|
-
pycityagent-1.0.0.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
pycityagent
|
File without changes
|
File without changes
|
File without changes
|