hjxdl 0.1.23__py3-none-any.whl → 0.1.25__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.1.23'
16
- __version_tuple__ = version_tuple = (0, 1, 23)
15
+ __version__ = version = '0.1.25'
16
+ __version_tuple__ = version_tuple = (0, 1, 25)
hdl/utils/llm/chat.py CHANGED
@@ -332,25 +332,20 @@ class OpenAI_M():
332
332
  *args,
333
333
  **kwargs
334
334
  ):
335
- """Initialize the OpenAI client.
335
+ """Initialize the OpenAI client with the specified parameters.
336
336
 
337
337
  Args:
338
- model_path (str): Path to the model file. Defaults to "default_model".
339
- device (str): Device to use for model inference. Defaults to 'gpu'.
340
- generation_kwargs (dict): Additional keyword arguments for model generation. Defaults to {}.
341
- server_ip (str): IP address of the server. Defaults to "172.28.1.2".
342
- server_port (int): Port number of the server. Defaults to 8000.
343
- api_key (str): API key for authentication. Defaults to "dummy_key".
344
- *args: Variable length argument list.
345
- **kwargs: Arbitrary keyword arguments.
338
+ model_path (str): Path to the model (default is "default_model").
339
+ device (str): Device to use (default is 'gpu').
340
+ generation_kwargs (dict): Additional generation arguments (default is an empty dictionary).
341
+ server_ip (str): IP address of the server (default is "172.28.1.2").
342
+ server_port (int): Port of the server (default is 8000).
343
+ api_key (str): API key for authentication (default is "dummy_key").
344
+ tools (list): List of tools.
345
+ tool_desc (dict): Description of tools.
346
346
 
347
- Attributes:
348
- model_path (str): Path to the model file.
349
- server_ip (str): IP address of the server.
350
- server_port (int): Port number of the server.
351
- base_url (str): Base URL for API requests.
352
- api_key (str): API key for authentication.
353
- client (OpenAI): OpenAI client for making API requests.
347
+ Raises:
348
+ ValueError: If an invalid argument is provided.
354
349
  """
355
350
  # self.model_path = model_path
356
351
  self.server_ip = server_ip
@@ -439,6 +434,18 @@ class OpenAI_M():
439
434
  prompt: str,
440
435
  **kwargs: t.Any
441
436
  ):
437
+ """Get decision based on the provided prompt and additional keyword arguments.
438
+
439
+ Args:
440
+ prompt (str): The prompt for decision making.
441
+ **kwargs: Additional keyword arguments.
442
+
443
+ Returns:
444
+ dict: A dictionary containing the decision.
445
+
446
+ Example:
447
+ decision = get_decision("Should I buy this product?", option1="yes", option2="no")
448
+ """
442
449
  prompt_final = FN_TEMPLATE
443
450
  for tool in self.tools:
444
451
  prompt_final += self.tool_desc.get(tool.__name__, "")
@@ -453,6 +460,15 @@ class OpenAI_M():
453
460
  prompt: str,
454
461
  **kwargs: t.Any
455
462
  ):
463
+ """Get the result from a tool based on the provided prompt and keyword arguments.
464
+
465
+ Args:
466
+ prompt (str): The prompt to get the decision for.
467
+ **kwargs: Additional keyword arguments to pass to the decision function.
468
+
469
+ Returns:
470
+ str: The result from the selected tool based on the decision made.
471
+ """
456
472
  decision_dict = self.get_decision(prompt, **kwargs)
457
473
  if decision_dict.get("function_name", None) is None:
458
474
  return ""
@@ -471,7 +487,17 @@ class OpenAI_M():
471
487
  stream = True,
472
488
  **kwargs: t.Any
473
489
  ):
490
+ """'''Generate agent response based on the given prompt.
474
491
 
492
+ Args:
493
+ prompt (str): The prompt for which agent response is generated.
494
+ stream (bool, optional): Flag to determine if the response should be streamed. Defaults to True.
495
+ **kwargs: Additional keyword arguments.
496
+
497
+ Returns:
498
+ str: The agent response based on the prompt.
499
+ '''
500
+ """
475
501
  decision_dict = self.get_decision(prompt, **kwargs)
476
502
  if decision_dict.get("function_name", None) is None:
477
503
  return self.stream(prompt, **kwargs)
@@ -10,6 +10,11 @@ from ..llm.embs import HFEmbedder
10
10
 
11
11
 
12
12
  def get_city_codes():
13
+ """Get city codes from a JSON file.
14
+
15
+ Returns:
16
+ dict: A dictionary containing city codes.
17
+ """
13
18
  # with open('../../city.json', 'r', encoding='utf-8') as f:
14
19
  # code_dic = eval(f.read())
15
20
  # return code_dic
@@ -22,6 +27,17 @@ def get_city_codes():
22
27
 
23
28
 
24
29
  def get_html(code):
30
+ """Get the HTML content of a weather webpage based on the provided code.
31
+
32
+ Args:
33
+ code (str): The code used to identify the specific weather webpage.
34
+
35
+ Returns:
36
+ str: The HTML content of the weather webpage.
37
+
38
+ Example:
39
+ html_content = get_html('101010100')
40
+ """
25
41
  weather_url = f'http://www.weather.com.cn/weather/{code}.shtml'
26
42
  header = {
27
43
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36"}
@@ -32,6 +48,14 @@ def get_html(code):
32
48
 
33
49
 
34
50
  def get_page_data(html):
51
+ """Get weather information for the next seven days from the provided HTML content.
52
+
53
+ Args:
54
+ html (str): The HTML content containing weather information.
55
+
56
+ Returns:
57
+ str: A formatted string with weather information for the next seven days.
58
+ """
35
59
  soup = BeautifulSoup(html, 'html.parser')
36
60
  weather_info = soup.find('div', id='7d')
37
61
  seven_weather = weather_info.find('ul')
@@ -62,6 +86,14 @@ def get_page_data(html):
62
86
 
63
87
 
64
88
  def get_weather(city):
89
+ """Get the weather information for a specific city.
90
+
91
+ Args:
92
+ city (str): The name of the city to get weather information for.
93
+
94
+ Returns:
95
+ str: A string containing the latest weather information for the specified city.
96
+ """
65
97
  code_dic = get_city_codes()
66
98
  city_name = city
67
99
  weather_str = ""
@@ -82,6 +114,15 @@ def get_standard_cityname(
82
114
  '/home/jhu/dev/models/bge-m3'
83
115
  )
84
116
  ):
117
+ """Get the standard city name based on the input city name.
118
+
119
+ Args:
120
+ city (str): The input city name.
121
+ emb_dir (str): The directory path for the embedding model (default is '/home/jhu/dev/models/bge-m3').
122
+
123
+ Returns:
124
+ str: The standard city name.
125
+ """
85
126
  code_dic = get_city_codes()
86
127
  city_list = list(code_dic.keys())
87
128
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hjxdl
3
- Version: 0.1.23
3
+ Version: 0.1.25
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=sfQd5PJr9QXyrhyCJmUy3FxYrMpjvCnNhW8XGLw-MjA,413
2
+ hdl/_version.py,sha256=2z8sOHys3QouaDyoTFldOod5mPhdtLw8dgODNwh6eyY,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
@@ -125,14 +125,14 @@ hdl/utils/desc/template.py,sha256=uKPGIgYFgSY4uBvfsbh5fZN7s39NdGQ2XSVH3pIpsuc,10
125
125
  hdl/utils/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
126
126
  hdl/utils/general/glob.py,sha256=8-RCnt6L297wMIfn34ZAMCsGCZUjHG3MGglGZI1cX0g,491
127
127
  hdl/utils/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
- hdl/utils/llm/chat.py,sha256=RJgiDTW16Ah-bYDySW9QWhkD_VZf9Q3uBZcO7vXZuvA,16877
128
+ hdl/utils/llm/chat.py,sha256=cpXgfHtjDz0A5HIInwODQ2kM04hdDsllTqalOU9wmQs,17784
129
129
  hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
130
130
  hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
131
131
  hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
132
132
  hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
133
133
  hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
134
- hdl/utils/weather/weather.py,sha256=bkN2kFHIC2r9HNfJoKTgj1tZ6f9AYCGyYDG2OpbyYD4,3164
135
- hjxdl-0.1.23.dist-info/METADATA,sha256=xXXbNXBK6oKhcbaFwWNQBPpnrVjDeT0BSUHDKLkTdVE,627
136
- hjxdl-0.1.23.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
137
- hjxdl-0.1.23.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
138
- hjxdl-0.1.23.dist-info/RECORD,,
134
+ hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
135
+ hjxdl-0.1.25.dist-info/METADATA,sha256=nOQQlDQJmZ6C5W5oedJIMy_5cB1HLtwgJC6PJlFw8pg,627
136
+ hjxdl-0.1.25.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
137
+ hjxdl-0.1.25.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
138
+ hjxdl-0.1.25.dist-info/RECORD,,
File without changes