hjxdl 0.3.21__py3-none-any.whl → 0.3.22__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.
hdl/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.3.21'
16
- __version_tuple__ = version_tuple = (0, 3, 21)
15
+ __version__ = version = '0.3.22'
16
+ __version_tuple__ = version_tuple = (0, 3, 22)
@@ -2,7 +2,6 @@ import yaml
2
2
  import typing as t
3
3
 
4
4
  from openai import OpenAI
5
- import instructor
6
5
 
7
6
 
8
7
  class OpenAIWrapper(object):
@@ -33,6 +32,12 @@ class OpenAIWrapper(object):
33
32
  Note:
34
33
  The method will create a client for each configuration found in `client_conf`,
35
34
  initializing the client with the specified `base_url` and `api_key`.
35
+ Examples:
36
+ >>> llm = OpenAIWrapper(
37
+ >>> client_conf_dir="/some/path/model_conf.yaml",
38
+ >>> # load_conf=False
39
+ >>> )
40
+ )
36
41
  """
37
42
  self.client_conf = {}
38
43
  if client_conf is None:
@@ -78,6 +83,13 @@ class OpenAIWrapper(object):
78
83
 
79
84
  Raises:
80
85
  ValueError: If both host and port are not valid for constructing a URL.
86
+ Examples:
87
+ >>> llm.add_client(
88
+ >>> client_id="rone",
89
+ >>> host="127.0.0.1",
90
+ >>> port=22299,
91
+ >>> model="ictrek/rone:1.5b32k",
92
+ >>> )
81
93
  """
82
94
  self.client_conf[client_id] = {}
83
95
  if not host.startswith('http') and port:
@@ -158,6 +170,7 @@ class OpenAIWrapper(object):
158
170
 
159
171
  client = self.client_conf[client_id]['client']
160
172
  if response_model:
173
+ import instructor #TODO 有些模型支持这个 instructor 的结构化输出,但实际上它调用的还是openai api的功能,以后适时删除或补全
161
174
  client = instructor.from_openai(client)
162
175
 
163
176
  messages = []
@@ -244,6 +257,15 @@ class OpenAIWrapper(object):
244
257
  - 'type' (str): Indicates the type of response ('text' or 'tool_calls').
245
258
  - 'contents' (str, optional): The text content if the response type is 'text'.
246
259
  - 'tool_params' (dict, optional): The parameters of the tool called if the response type is 'tool_calls'.
260
+
261
+ Examples:
262
+ >>> llm.invoke(
263
+ >>> client_id="glm_4_flash",
264
+ >>> prompt="深圳天气怎么样?",
265
+ >>> tools=[TOOL_DICT['get_weather']],
266
+ >>> )
267
+ {'type': 'tool_calls',
268
+ 'tool_parmas': Function(arguments='{"location": "Shenzhen"}', name='get_weather')}
247
269
  """
248
270
  answer_dict = {}
249
271
 
@@ -279,6 +301,16 @@ class OpenAIWrapper(object):
279
301
  - tool_params (dict, optional): Parameters of the tool call if the type is 'tool_calls'.
280
302
  - content (str, optional): The generated text content if the type is 'text'.
281
303
  - message (str, optional): An error message if the type is 'error'.
304
+
305
+ Examplse:
306
+ >>> resp = llm.stream(
307
+ >>> client_id="r1", #此模型可以进行cot
308
+ >>> prompt=prompt,
309
+ >>> # tools=[TOOL_DICT['get_weather']],
310
+ >>> )
311
+ >>> for i in resp:
312
+ >>> if i['type'] == 'text' and i['content']:
313
+ >>> print(i['content'], flush=True, end="")
282
314
  """
283
315
  resp = self.get_resp(prompt=prompt, stream=True, **kwargs)
284
316
 
@@ -312,7 +344,3 @@ class OpenAIWrapper(object):
312
344
  return
313
345
 
314
346
  return
315
-
316
-
317
-
318
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: hjxdl
3
- Version: 0.3.21
3
+ Version: 0.3.22
4
4
  Summary: A collection of functions for Jupyter notebooks
5
5
  Home-page: https://github.com/huluxiaohuowa/hdl
6
6
  Author: Jianxing Hu
@@ -1,5 +1,5 @@
1
1
  hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
2
- hdl/_version.py,sha256=RePWyWgLItSCeI7HV40DbnyFzjteC1Gpxd4cuRPe79I,413
2
+ hdl/_version.py,sha256=q4JPltmBqBzXzF4sbXugC3X2R4f0B_3ypR7bRe2rY5c,413
3
3
  hdl/args/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  hdl/args/loss_args.py,sha256=s7YzSdd7IjD24rZvvOrxLLFqMZQb9YylxKeyelSdrTk,70
5
5
  hdl/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -134,15 +134,15 @@ hdl/utils/llm/chatgr.py,sha256=5F5PJHe8vz3iCfi4TT54DCLRi1UeJshECdVtgvvvao0,3696
134
134
  hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
135
135
  hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
136
136
  hdl/utils/llm/llama_chat.py,sha256=watcHGOaz-bv3x-yDucYlGk5f8FiqfFhwWogrl334fk,4387
137
- hdl/utils/llm/llm_wrapper.py,sha256=sg1uh06yd5gEnHVhSp6FgQI9cOGFVJt0e0_vYpzpRPE,12377
137
+ hdl/utils/llm/llm_wrapper.py,sha256=DVpt4TeFN3uWsL1L6BQT4FUKFOvilSNhbR9tfVJIQus,13663
138
138
  hdl/utils/llm/vis.py,sha256=SSP6tOwKLq0hWcpM3twI9TitqzBmKjlcGrnXEWYlCzM,26055
139
139
  hdl/utils/llm/visrag.py,sha256=0i-VrxqgiV-J7R3VPshu9oc7-rKjFJOldYik3HDXj6M,10176
140
140
  hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
141
141
  hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
142
142
  hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
143
143
  hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
144
- hjxdl-0.3.21.dist-info/LICENSE,sha256=lkMiSbeZHBQLB9LJEkS9-L3Z-LBC4yGnKrzHSG8RkPM,2599
145
- hjxdl-0.3.21.dist-info/METADATA,sha256=4iJS1jchqo13kaCQ7DzOspSZT1E4d3NJkn1bk75cGmc,1336
146
- hjxdl-0.3.21.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
147
- hjxdl-0.3.21.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
148
- hjxdl-0.3.21.dist-info/RECORD,,
144
+ hjxdl-0.3.22.dist-info/LICENSE,sha256=lkMiSbeZHBQLB9LJEkS9-L3Z-LBC4yGnKrzHSG8RkPM,2599
145
+ hjxdl-0.3.22.dist-info/METADATA,sha256=F8oNEqwUBDPVS0izQtAppzqat2aXaMm4uE68j6pGyGE,1336
146
+ hjxdl-0.3.22.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
147
+ hjxdl-0.3.22.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
148
+ hjxdl-0.3.22.dist-info/RECORD,,
File without changes