cat-llm 0.0.79__py3-none-any.whl → 0.0.81__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.
- {cat_llm-0.0.79.dist-info → cat_llm-0.0.81.dist-info}/METADATA +1 -1
- {cat_llm-0.0.79.dist-info → cat_llm-0.0.81.dist-info}/RECORD +6 -6
- catllm/__about__.py +1 -1
- catllm/text_functions.py +43 -18
- {cat_llm-0.0.79.dist-info → cat_llm-0.0.81.dist-info}/WHEEL +0 -0
- {cat_llm-0.0.79.dist-info → cat_llm-0.0.81.dist-info}/licenses/LICENSE +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.81
|
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
|
@@ -1,10 +1,10 @@
|
|
1
1
|
catllm/CERAD_functions.py,sha256=q4HbP5e2Yu8NnZZ-2eX4sImyj6u3i8xWcq0pYU81iis,22676
|
2
|
-
catllm/__about__.py,sha256=
|
2
|
+
catllm/__about__.py,sha256=JWaGFu-r637kdvMsJcvfun8_Hi3c_vhw4yi-_YOGtzo,430
|
3
3
|
catllm/__init__.py,sha256=sf02zp7N0NW0mAQi7eQ4gliWR1EwoqvXkHN2HwwjcTE,372
|
4
4
|
catllm/build_web_research.py,sha256=880dfE2bEQb-FrXP-42JoLLtyc9ox_sBULDr38xiTiQ,22655
|
5
5
|
catllm/image_functions.py,sha256=8_FftRU285x1HT-AgNkaobefQVD-5q7ZY_t7JFdL3Sg,36177
|
6
6
|
catllm/model_reference_list.py,sha256=37pWwMcgnf4biE3BVRluH5oz2P6ccdJJiCVNHodBH8k,2307
|
7
|
-
catllm/text_functions.py,sha256=
|
7
|
+
catllm/text_functions.py,sha256=2qyYqB2hwKFXOKn9RaGssCsVIri9uvdWmsNZhiabT_I,37154
|
8
8
|
catllm/calls/CoVe.py,sha256=Y9OGJbaeJ3Odwira92cPXUlnm_ADFqvpOSFSNjFzMMU,10847
|
9
9
|
catllm/calls/__init__.py,sha256=fWuMwLeSGa6zXJYd4s8IyNblsD62G-1NMUsOKrNIkoI,725
|
10
10
|
catllm/calls/all_calls.py,sha256=15xvGSCwVQGVsrAWgn0alLuZblEYOUgIhpbzUM_875w,16592
|
@@ -13,7 +13,7 @@ catllm/images/cube.png,sha256=nFec3e5bmRe4zrBCJ8QK-HcJLrG7u7dYdKhmdMfacfE,77275
|
|
13
13
|
catllm/images/diamond.png,sha256=rJDZKtsnBGRO8FPA0iHuA8FvHFGi9PkI_DWSFdw6iv0,99568
|
14
14
|
catllm/images/overlapping_pentagons.png,sha256=VO5plI6eoVRnjfqinn1nNzsCP2WQhuQy71V0EASouW4,71208
|
15
15
|
catllm/images/rectangles.png,sha256=2XM16HO9EYWj2yHgN4bPXaCwPfl7iYQy0tQUGaJX9xg,40692
|
16
|
-
cat_llm-0.0.
|
17
|
-
cat_llm-0.0.
|
18
|
-
cat_llm-0.0.
|
19
|
-
cat_llm-0.0.
|
16
|
+
cat_llm-0.0.81.dist-info/METADATA,sha256=_9i0JqmzSGLnQQmbrmR0hg2oFcoU6SG8MaJwAKAwhWk,23214
|
17
|
+
cat_llm-0.0.81.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
+
cat_llm-0.0.81.dist-info/licenses/LICENSE,sha256=Vje2sS5WV4TnIwY5uQHrF4qnBAM3YOk1pGpdH0ot-2o,34969
|
19
|
+
cat_llm-0.0.81.dist-info/RECORD,,
|
catllm/__about__.py
CHANGED
catllm/text_functions.py
CHANGED
@@ -8,7 +8,7 @@ from .calls.all_calls import (
|
|
8
8
|
chain_of_verification_anthropic,
|
9
9
|
chain_of_verification_mistral,
|
10
10
|
get_openai_top_n,
|
11
|
-
get_anthropic_top_n
|
11
|
+
get_anthropic_top_n
|
12
12
|
)
|
13
13
|
|
14
14
|
|
@@ -114,7 +114,6 @@ Number your categories from 1 through {cat_num} and be concise with the category
|
|
114
114
|
|
115
115
|
return df
|
116
116
|
|
117
|
-
#extract top categories from corpus
|
118
117
|
#extract top categories from corpus
|
119
118
|
def explore_common_categories(
|
120
119
|
survey_question,
|
@@ -168,15 +167,28 @@ Number your categories from 1 through {cat_num} and be concise with the category
|
|
168
167
|
|
169
168
|
if model_source == "openai":
|
170
169
|
try:
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
170
|
+
from openai import OpenAI
|
171
|
+
|
172
|
+
base_url = (
|
173
|
+
"https://api.perplexity.ai" if model_source == "perplexity"
|
174
|
+
else "https://router.huggingface.co/v1" if model_source == "huggingface"
|
175
|
+
else None
|
176
|
+
)
|
177
|
+
|
178
|
+
client = OpenAI(api_key=api_key, base_url=base_url)
|
179
|
+
|
180
|
+
response_obj = client.chat.completions.create(
|
181
|
+
model=user_model,
|
182
|
+
messages=[
|
183
|
+
{'role': 'system', 'content': f"""You are a helpful assistant that extracts categories from survey responses. \
|
184
|
+
The specific task is to identify {specificity} categories of responses to a survey question. \
|
185
|
+
The research question is: {research_question}""" if research_question else "You are a helpful assistant."},
|
186
|
+
{'role': 'user', 'content': prompt}
|
187
|
+
],
|
188
|
+
**({"temperature": creativity} if creativity is not None else {})
|
179
189
|
)
|
190
|
+
|
191
|
+
reply = response_obj.choices[0].message.content
|
180
192
|
|
181
193
|
responses.append(reply)
|
182
194
|
|
@@ -192,16 +204,29 @@ Number your categories from 1 through {cat_num} and be concise with the category
|
|
192
204
|
|
193
205
|
elif model_source == "anthropic":
|
194
206
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
207
|
+
import anthropic
|
208
|
+
client = anthropic.Anthropic(api_key=api_key)
|
209
|
+
|
210
|
+
# Build system prompt
|
211
|
+
if research_question:
|
212
|
+
system_content = (f"You are a helpful assistant that extracts categories from survey responses. "
|
213
|
+
f"The specific task is to identify {specificity} categories of responses to a survey question. "
|
214
|
+
f"The research question is: {research_question}")
|
215
|
+
else:
|
216
|
+
system_content = "You are a helpful assistant."
|
217
|
+
|
218
|
+
response_obj = client.messages.create(
|
219
|
+
model=user_model,
|
220
|
+
max_tokens=4096,
|
221
|
+
system=system_content,
|
222
|
+
messages=[
|
223
|
+
{'role': 'user', 'content': prompt}
|
224
|
+
],
|
225
|
+
**({"temperature": creativity} if creativity is not None else {})
|
203
226
|
)
|
204
227
|
|
228
|
+
reply = response_obj.content[0].text
|
229
|
+
|
205
230
|
responses.append(reply)
|
206
231
|
else:
|
207
232
|
raise ValueError(f"Unsupported model_source: {model_source}")
|
File without changes
|
File without changes
|