hjxdl 0.3.29__py3-none-any.whl → 0.3.31__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.29'
16
- __version_tuple__ = version_tuple = (0, 3, 29)
15
+ __version__ = version = '0.3.31'
16
+ __version_tuple__ = version_tuple = (0, 3, 31)
@@ -56,6 +56,8 @@ class OpenAIWrapper(object):
56
56
  *args,
57
57
  **kwargs
58
58
  )
59
+ if "client_type" not in conf:
60
+ conf["client_type"] = "chat"
59
61
 
60
62
  def add_client(
61
63
  self,
@@ -96,6 +98,7 @@ class OpenAIWrapper(object):
96
98
  host = f"http://{host}:{port}/v1"
97
99
  self.client_conf[client_id]['host'] = host
98
100
  self.client_conf[client_id]['model'] = model
101
+ self.client_conf[client_id]['client_type'] = kwargs.pop("client_type", "chat")
99
102
  self.client_conf[client_id]['client'] = OpenAI(
100
103
  base_url=host,
101
104
  api_key=api_key,
@@ -347,3 +350,35 @@ class OpenAIWrapper(object):
347
350
  return
348
351
 
349
352
  return
353
+
354
+ def embedding(
355
+ self,
356
+ client_id: str,
357
+ texts: list[str],
358
+ model: str = None,
359
+ **kwargs
360
+ ):
361
+ """
362
+ Generates embeddings for a list of texts using a specified model.
363
+
364
+ Args:
365
+ client_id (str): The ID of the client to use for generating embeddings.
366
+ texts (list[str]): A list of texts for which to generate embeddings.
367
+ model (str, optional): The model to use for generating embeddings.
368
+ If not provided, the model specified in the client configuration will be used.
369
+ **kwargs: Additional keyword arguments to be passed to the client embedding creation method.
370
+
371
+ Returns:
372
+ list: A list of embeddings corresponding to the input texts.
373
+ """
374
+ if not model:
375
+ model = self.client_conf[client_id]['model']
376
+
377
+ client = self.client_conf[client_id]['client']
378
+ response = client.embeddings.create(
379
+ input=texts,
380
+ model=model,
381
+ **kwargs
382
+ )
383
+
384
+ return [i.embedding for i in response.data]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: hjxdl
3
- Version: 0.3.29
3
+ Version: 0.3.31
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=f1H6PIKEuqUoOqkVNqRQPR6h3oBTbMF-TCtBkXnI8lc,413
2
+ hdl/_version.py,sha256=bhEYrWy2EPGfW55r0auHlTI13JyXnFgvZ-r2iYCZ3RY,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
@@ -136,15 +136,15 @@ hdl/utils/llm/chatgr.py,sha256=5F5PJHe8vz3iCfi4TT54DCLRi1UeJshECdVtgvvvao0,3696
136
136
  hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
137
137
  hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
138
138
  hdl/utils/llm/llama_chat.py,sha256=watcHGOaz-bv3x-yDucYlGk5f8FiqfFhwWogrl334fk,4387
139
- hdl/utils/llm/llm_wrapper.py,sha256=sdf6N19pmwXBCYvHfFv8VVPPBpu5SIyXu21W3bFXSx0,13718
139
+ hdl/utils/llm/llm_wrapper.py,sha256=UkD2MnZGGyI-hns6MyUEBS_Mk-U8s8AJMOUP8E3SZ0c,14988
140
140
  hdl/utils/llm/vis.py,sha256=SSP6tOwKLq0hWcpM3twI9TitqzBmKjlcGrnXEWYlCzM,26055
141
141
  hdl/utils/llm/visrag.py,sha256=0i-VrxqgiV-J7R3VPshu9oc7-rKjFJOldYik3HDXj6M,10176
142
142
  hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
143
143
  hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
144
144
  hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
145
145
  hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
146
- hjxdl-0.3.29.dist-info/LICENSE,sha256=lkMiSbeZHBQLB9LJEkS9-L3Z-LBC4yGnKrzHSG8RkPM,2599
147
- hjxdl-0.3.29.dist-info/METADATA,sha256=BTs6PvUzk9E0AzgN86UFTibWjbUfi0ysphPzzCy__u0,1336
148
- hjxdl-0.3.29.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
149
- hjxdl-0.3.29.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
150
- hjxdl-0.3.29.dist-info/RECORD,,
146
+ hjxdl-0.3.31.dist-info/LICENSE,sha256=lkMiSbeZHBQLB9LJEkS9-L3Z-LBC4yGnKrzHSG8RkPM,2599
147
+ hjxdl-0.3.31.dist-info/METADATA,sha256=Uy-RmZJGdOwCbvLsnmO3lU0fRVyUDxX8bm13KrGB3G0,1336
148
+ hjxdl-0.3.31.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
149
+ hjxdl-0.3.31.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
150
+ hjxdl-0.3.31.dist-info/RECORD,,
File without changes