pycityagent 1.1.3__py3-none-any.whl → 1.1.5__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.
@@ -19,6 +19,8 @@ class LLMConfig:
19
19
  ) -> None:
20
20
  self.config = config
21
21
  self.text = config['text_request']
22
+ if 'api_base' in self.text.keys() and self.text['api_base'] == 'None':
23
+ self.text['api_base'] = None
22
24
  self.image_u = config['img_understand_request']
23
25
  self.image_g = config['img_generate_request']
24
26
 
@@ -30,28 +32,39 @@ class UrbanLLM:
30
32
  def __init__(self, config: LLMConfig) -> None:
31
33
  self.config = config
32
34
 
33
- def text_request(self, dialog:list[dict]) -> str:
35
+ def text_request(self, dialog:list[dict], temperature:float=1, max_tokens:int=None, top_p:float=None, frequency_penalty:float=None, presence_penalty:float=None) -> str:
34
36
  """
35
37
  文本相关请求
36
38
  Text request
37
39
 
38
40
  Args:
39
41
  - dialog (list[dict]): 标准的LLM文本dialog. The standard text LLM dialog
42
+ - temperature (float): default 1, used in openai
43
+ - max_tokens (int): default None, used in openai
44
+ - top_p (float): default None, used in openai
45
+ - frequency_penalty (float): default None, used in openai
46
+ - presence_penalty (float): default None, used in openai
40
47
 
41
48
  Returns:
42
49
  - (str): the response content
43
50
  """
44
- client = None if self.config.text['http_client'] == None else self.config.text['http_client']
51
+ if 'api_base' in self.config.text.keys():
52
+ api_base = self.config.text['api_base']
53
+ else:
54
+ api_base = None
45
55
  if self.config.text['request_type'] == 'openai':
46
56
  client = OpenAI(
47
57
  api_key=self.config.text['api_key'],
48
- base_url=self.config.text['api_base'],
49
- http_client=client
58
+ base_url=api_base,
50
59
  )
51
60
  response = client.chat.completions.create(
52
61
  model=self.config.text['model'],
53
62
  messages=dialog,
54
- temperature=1.0,
63
+ temperature=temperature,
64
+ max_tokens=max_tokens,
65
+ top_p=top_p,
66
+ frequency_penalty=frequency_penalty,
67
+ presence_penalty=presence_penalty
55
68
  )
56
69
  return response.choices[0].message.content
57
70
  elif self.config.text['request_type'] == 'qwen':
@@ -75,7 +88,7 @@ class UrbanLLM:
75
88
  Image understanding
76
89
 
77
90
  Args:
78
- - img_path: 图像的绝对路径. The absolute path of selected Image
91
+ - img_path: 目标图像的路径. The path of selected Image
79
92
  - prompt: 理解提示词 - 例如理解方向. The understanding prompts
80
93
 
81
94
  Returns:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycityagent
3
- Version: 1.1.3
3
+ Version: 1.1.5
4
4
  Summary: LLM-based城市模拟器agent构建库
5
5
  Author-email: Yuwei Yan <pinkgranite86@gmail.com>
6
6
  License: MIT License
@@ -77,7 +77,7 @@ llm_request:
77
77
  request_type: openai / qwen
78
78
  api_key: xxx
79
79
  model: xxx
80
- http_client: xxx (if you use opanai and want to use your own backend LLM model)
80
+ (api_base): xxx (this is an optional config, if you use opanai and want to use your own backend LLM model, default to "https://api.openai.com/v1")
81
81
  img_understand_request:
82
82
  request_type: qwen
83
83
  api_key: xxx
@@ -113,7 +113,8 @@ apphub_request:
113
113
  - By now, we support [**qwen**](https://tongyi.aliyun.com/) and [**openai**](https://openai.com/)
114
114
  - `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.`
115
115
  - Get your **api_key** and chooce your **model**
116
- - If you want to use your backend models, set the **http_client** (only available when using **openai**)
116
+ - If you want to use your backend models, set the **api_base** (only available when using **openai**)
117
+ - default value: "https://api.openai.com/v1"
117
118
 
118
119
  #### CITYSIM_REQUEST
119
120
  - Most of the configuration options in this part are determined, such as **simulator.server**, **map_request.mongo_coll**, **route_request.server**
@@ -50,9 +50,9 @@ pycityagent/image/image.py,sha256=KyOBoX8I1KSi82lBCBku-NXgXX4gIFHi2cGEe7yQ-lI,53
50
50
  pycityagent/st/__init__.py,sha256=YzsQXrgqRvmoQ4dWqAztAriKd8wvnQVe0FOpX_oZmiY,109
51
51
  pycityagent/st/st.py,sha256=z6yDo7ADOjostLg0mLmQ0oa_VysaCXFm4MnzC2H9nsI,5154
52
52
  pycityagent/urbanllm/__init__.py,sha256=D24mYFXdIEL2vbvB7Cp_BGgJvg-tvEnCgtEAAGaqGDY,56
53
- pycityagent/urbanllm/urbanllm.py,sha256=okwHKRg-tuFBizkeH6dbF2KPH5Y-hC6Aufn2fX10-t0,4481
54
- pycityagent-1.1.3.dist-info/LICENSE,sha256=Yo9QmwLDFU3VoOc0W8aYSCa5Yj5sJyqM3FEcbC2jMQQ,1063
55
- pycityagent-1.1.3.dist-info/METADATA,sha256=w22vYIDhb2ND3fulYuuwBpxDvwalqrlQP8-ceFwQrVg,7657
56
- pycityagent-1.1.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
57
- pycityagent-1.1.3.dist-info/top_level.txt,sha256=mf70CsOn3eVJBwHQ_TjCesoc-elD0Bj2WLsi5APRjlU,12
58
- pycityagent-1.1.3.dist-info/RECORD,,
53
+ pycityagent/urbanllm/urbanllm.py,sha256=z6mJyvFbu4cotxLuen0ODZUIpba9SOUwNg3HEbrGylI,5176
54
+ pycityagent-1.1.5.dist-info/LICENSE,sha256=Yo9QmwLDFU3VoOc0W8aYSCa5Yj5sJyqM3FEcbC2jMQQ,1063
55
+ pycityagent-1.1.5.dist-info/METADATA,sha256=zBD0UWeliRWImn4hPEDfTNNlyymcJOfsWQ7bscUJlgs,7768
56
+ pycityagent-1.1.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
57
+ pycityagent-1.1.5.dist-info/top_level.txt,sha256=mf70CsOn3eVJBwHQ_TjCesoc-elD0Bj2WLsi5APRjlU,12
58
+ pycityagent-1.1.5.dist-info/RECORD,,