cat-llm 0.0.29__tar.gz → 0.0.31__tar.gz
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.
- {cat_llm-0.0.29 → cat_llm-0.0.31}/PKG-INFO +1 -1
- {cat_llm-0.0.29 → cat_llm-0.0.31}/src/catllm/CERAD_functions.py +28 -17
- {cat_llm-0.0.29 → cat_llm-0.0.31}/src/catllm/__about__.py +1 -1
- {cat_llm-0.0.29 → cat_llm-0.0.31}/LICENSE +0 -0
- {cat_llm-0.0.29 → cat_llm-0.0.31}/README.md +0 -0
- {cat_llm-0.0.29 → cat_llm-0.0.31}/pyproject.toml +0 -0
- {cat_llm-0.0.29 → cat_llm-0.0.31}/src/catllm/__init__.py +0 -0
- {cat_llm-0.0.29 → cat_llm-0.0.31}/src/catllm/cat_llm.py +0 -0
- {cat_llm-0.0.29 → cat_llm-0.0.31}/src/catllm/image_functions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cat-llm
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.31
|
|
4
4
|
Summary: A tool for categorizing text data and images using LLMs and vision models
|
|
5
5
|
Project-URL: Documentation, https://github.com/chrissoria/cat-llm#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/chrissoria/cat-llm/issues
|
|
@@ -151,7 +151,7 @@ def cerad_drawn_score(
|
|
|
151
151
|
{
|
|
152
152
|
"type": "image_url",
|
|
153
153
|
"image_url": {"url": encoded_image, "detail": "high"},
|
|
154
|
-
}
|
|
154
|
+
}
|
|
155
155
|
]
|
|
156
156
|
elif model_source == "Anthropic":
|
|
157
157
|
prompt = [
|
|
@@ -177,7 +177,30 @@ def cerad_drawn_score(
|
|
|
177
177
|
"media_type": "image/jpeg",
|
|
178
178
|
"data": encoded
|
|
179
179
|
}
|
|
180
|
-
}
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
elif model_source == "Mistral":
|
|
184
|
+
prompt = [
|
|
185
|
+
{
|
|
186
|
+
"type": "text",
|
|
187
|
+
"text": (
|
|
188
|
+
f"You are an image-tagging assistant trained in the CERAD Constructional Praxis test.\n"
|
|
189
|
+
f"Task ► Examine the attached image and decide, **for each category below**, "
|
|
190
|
+
f"whether it is PRESENT (1) or NOT PRESENT (0).\n\n"
|
|
191
|
+
f"{reference_text}"
|
|
192
|
+
f"Categories:\n{categories_str}\n\n"
|
|
193
|
+
f"Output format ► Respond with **only** a JSON object whose keys are the "
|
|
194
|
+
f"quoted category numbers ('1', '2', …) and whose values are 1 or 0. "
|
|
195
|
+
f"No additional keys, comments, or text.\n\n"
|
|
196
|
+
f"Example:\n"
|
|
197
|
+
f"{example_JSON}"
|
|
198
|
+
),
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"type": "image_url",
|
|
202
|
+
"image_url": f"data:image/jpeg;base64,{encoded}"
|
|
203
|
+
}
|
|
181
204
|
]
|
|
182
205
|
|
|
183
206
|
if model_source == "OpenAI":
|
|
@@ -195,20 +218,6 @@ def cerad_drawn_score(
|
|
|
195
218
|
print(f"An error occurred: {e}")
|
|
196
219
|
link1.append(f"Error processing input: {e}")
|
|
197
220
|
|
|
198
|
-
elif model_source == "Perplexity":
|
|
199
|
-
from openai import OpenAI
|
|
200
|
-
client = OpenAI(api_key=api_key, base_url="https://api.perplexity.ai")
|
|
201
|
-
try:
|
|
202
|
-
response_obj = client.chat.completions.create(
|
|
203
|
-
model=user_model,
|
|
204
|
-
messages=[{'role': 'user', 'content': prompt}],
|
|
205
|
-
temperature=creativity
|
|
206
|
-
)
|
|
207
|
-
reply = response_obj.choices[0].message.content
|
|
208
|
-
link1.append(reply)
|
|
209
|
-
except Exception as e:
|
|
210
|
-
print(f"An error occurred: {e}")
|
|
211
|
-
link1.append(f"Error processing input: {e}")
|
|
212
221
|
elif model_source == "Anthropic":
|
|
213
222
|
import anthropic
|
|
214
223
|
client = anthropic.Anthropic(api_key=api_key)
|
|
@@ -224,8 +233,10 @@ def cerad_drawn_score(
|
|
|
224
233
|
except Exception as e:
|
|
225
234
|
print(f"An error occurred: {e}")
|
|
226
235
|
link1.append(f"Error processing input: {e}")
|
|
236
|
+
|
|
227
237
|
elif model_source == "Mistral":
|
|
228
238
|
from mistralai import Mistral
|
|
239
|
+
reply = None
|
|
229
240
|
client = Mistral(api_key=api_key)
|
|
230
241
|
try:
|
|
231
242
|
response = client.chat.complete(
|
|
@@ -241,7 +252,7 @@ def cerad_drawn_score(
|
|
|
241
252
|
print(f"An error occurred: {e}")
|
|
242
253
|
link1.append(f"Error processing input: {e}")
|
|
243
254
|
else:
|
|
244
|
-
raise ValueError("Unknown source! Choose from OpenAI,
|
|
255
|
+
raise ValueError("Unknown source! Choose from OpenAI, Perplexity, or Mistral")
|
|
245
256
|
# in situation that no JSON is found
|
|
246
257
|
if reply is not None:
|
|
247
258
|
extracted_json = regex.findall(r'\{(?:[^{}]|(?R))*\}', reply, regex.DOTALL)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|