hjxdl 0.1.49__py3-none-any.whl → 0.1.50__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.49'
16
- __version_tuple__ = version_tuple = (0, 1, 49)
15
+ __version__ = version = '0.1.50'
16
+ __version_tuple__ = version_tuple = (0, 1, 50)
hdl/utils/llm/chat.py CHANGED
@@ -146,30 +146,42 @@ class OpenAI_M():
146
146
  def invoke(
147
147
  self,
148
148
  prompt : str,
149
+ image_url: str = None,
149
150
  stop: list[str] | None = ["USER:", "ASSISTANT:"],
150
151
  # history: list = [],
151
152
  model="default_model",
152
153
  **kwargs: t.Any,
153
154
  ) -> str:
154
- """Invoke the chatbot with the given prompt and return the response.
155
+ """Invoke the chatbot with a prompt and optional image URL.
155
156
 
156
157
  Args:
157
158
  prompt (str): The prompt to provide to the chatbot.
159
+ image_url (str, optional): The URL of the image to include in the chatbot response. Defaults to None.
158
160
  stop (list[str], optional): List of strings that indicate the end of the conversation. Defaults to ["USER:", "ASSISTANT:"].
161
+ model (str, optional): The model to use for the chatbot. Defaults to "default_model".
159
162
  **kwargs: Additional keyword arguments to pass to the chatbot.
160
163
 
161
164
  Returns:
162
- str: The response generated by the chatbot.
165
+ str: The response message from the chatbot.
163
166
  """
167
+ content = [
168
+ {"type": "text", "text": prompt},
169
+ ],
170
+ if image_url is not None:
171
+ image_content = {
172
+ "type": "image_url",
173
+ "image_url": {
174
+ "url": image_url,
175
+ },
176
+ }
177
+ content.append(image_content)
164
178
  response = self.client.chat.completions.create(
165
- # model=self.model_path,
166
179
  messages=[{
167
180
  "role": "user",
168
- "content": prompt
181
+ "content": content
169
182
  }],
170
183
  stream=False,
171
184
  model=model,
172
- # model=kwargs.get("model", "default_model")
173
185
  **kwargs
174
186
  )
175
187
  return response.choices[0].message.content
@@ -177,30 +189,42 @@ class OpenAI_M():
177
189
  def stream(
178
190
  self,
179
191
  prompt : str,
192
+ image_url: str = None,
180
193
  stop: list[str] | None = ["USER:", "ASSISTANT:"],
181
194
  # history: list = [],
182
195
  model="default_model",
183
196
  **kwargs: t.Any,
184
197
  ):
185
- """Generate text completion in a streaming fashion.
198
+ """Generates text and potentially image completions based on the prompt provided.
186
199
 
187
200
  Args:
188
- prompt (str): The text prompt to generate completion for.
189
- stop (list[str], optional): List of strings to stop streaming at. Defaults to ["USER:", "ASSISTANT:"].
190
- **kwargs: Additional keyword arguments to pass to the completion API.
201
+ prompt (str): The text prompt to generate completions from.
202
+ image_url (str, optional): The URL of the image to be included in the completion. Defaults to None.
203
+ stop (list[str], optional): List of strings that indicate the end of the conversation. Defaults to ["USER:", "ASSISTANT:"].
204
+ model (str, optional): The model to use for completion generation. Defaults to "default_model".
205
+ **kwargs: Additional keyword arguments to pass to the completion generation API.
191
206
 
192
207
  Yields:
193
- str: The generated text completion in a streaming fashion.
208
+ str: The generated completion content.
194
209
  """
210
+ content = [
211
+ {"type": "text", "text": prompt},
212
+ ],
213
+ if image_url is not None:
214
+ image_content = {
215
+ "type": "image_url",
216
+ "image_url": {
217
+ "url": image_url,
218
+ },
219
+ }
220
+ content.append(image_content)
195
221
  response = self.client.chat.completions.create(
196
- # model=self.model_path,
197
222
  messages=[{
198
223
  "role": "user",
199
- "content": prompt
224
+ "content": content
200
225
  }],
201
226
  stream=True,
202
227
  model=model,
203
- # model=kwargs.get("model", "default_model")
204
228
  **kwargs
205
229
  )
206
230
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hjxdl
3
- Version: 0.1.49
3
+ Version: 0.1.50
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=H7_XEdcrsGpo2K4IO_APhPn7oH870y-Gu-5n41Le4X4,413
2
+ hdl/_version.py,sha256=tDigaWSRikP7GznXAhxQfoonLAxYD4L3aYmQCZ0gu7o,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
@@ -127,7 +127,7 @@ hdl/utils/desc/template.py,sha256=a0UAkkKctt_EHY9UECsIIAwVkGPcM1Hr01HSkRMeIuw,12
127
127
  hdl/utils/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
128
  hdl/utils/general/glob.py,sha256=8-RCnt6L297wMIfn34ZAMCsGCZUjHG3MGglGZI1cX0g,491
129
129
  hdl/utils/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
130
- hdl/utils/llm/chat.py,sha256=ZyKcGQtt-pqtXqQ4azSYf90_TlOoyn0glpD-MOvkO54,10922
130
+ hdl/utils/llm/chat.py,sha256=hBSmfV0Y8oewJwV-6pY6UjHoFnrgwnKeVIegxLlA1GY,11909
131
131
  hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
132
132
  hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
133
133
  hdl/utils/llm/llama_chat.py,sha256=watcHGOaz-bv3x-yDucYlGk5f8FiqfFhwWogrl334fk,4387
@@ -135,7 +135,7 @@ hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
135
135
  hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
136
136
  hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
137
137
  hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
138
- hjxdl-0.1.49.dist-info/METADATA,sha256=dBGXFJ9jNmeyPGD3jOc9sZ3Gy0REgT-E9e07Pm5KakA,737
139
- hjxdl-0.1.49.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
140
- hjxdl-0.1.49.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
141
- hjxdl-0.1.49.dist-info/RECORD,,
138
+ hjxdl-0.1.50.dist-info/METADATA,sha256=ZTzzrp0k27gajrobfk2zFr1hdTcBc-4Oy88HY9TZpSQ,737
139
+ hjxdl-0.1.50.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
140
+ hjxdl-0.1.50.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
141
+ hjxdl-0.1.50.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.0.0)
2
+ Generator: setuptools (74.1.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5