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 +2 -2
- hdl/utils/llm/chat.py +37 -13
- {hjxdl-0.1.49.dist-info → hjxdl-0.1.50.dist-info}/METADATA +1 -1
- {hjxdl-0.1.49.dist-info → hjxdl-0.1.50.dist-info}/RECORD +6 -6
- {hjxdl-0.1.49.dist-info → hjxdl-0.1.50.dist-info}/WHEEL +1 -1
- {hjxdl-0.1.49.dist-info → hjxdl-0.1.50.dist-info}/top_level.txt +0 -0
hdl/_version.py
CHANGED
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
|
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
|
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":
|
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
|
-
"""
|
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
|
189
|
-
|
190
|
-
|
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
|
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":
|
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,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
|
2
|
-
hdl/_version.py,sha256=
|
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=
|
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.
|
139
|
-
hjxdl-0.1.
|
140
|
-
hjxdl-0.1.
|
141
|
-
hjxdl-0.1.
|
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,,
|
File without changes
|