cat-llm 0.0.58__tar.gz → 0.0.59__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cat-llm
3
- Version: 0.0.58
3
+ Version: 0.0.59
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,7 +1,7 @@
1
1
  # SPDX-FileCopyrightText: 2025-present Christopher Soria <chrissoria@berkeley.edu>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.0.58"
4
+ __version__ = "0.0.59"
5
5
  __author__ = "Chris Soria"
6
6
  __email__ = "chrissoria@berkeley.edu"
7
7
  __title__ = "cat-llm"
@@ -88,13 +88,42 @@ def build_web_research_dataset(
88
88
  if getattr(block, "type", "") == "text"
89
89
  ).strip()
90
90
  link1.append(reply)
91
- print(reply)
92
91
 
93
92
  except Exception as e:
94
93
  print(f"An error occurred: {e}")
95
94
  link1.append(f"Error processing input: {e}")
95
+
96
+ elif model_source == "Google":
97
+ import requests
98
+ url = f"https://generativelanguage.googleapis.com/v1beta/models/{user_model}:generateContent"
99
+ try:
100
+ headers = {
101
+ "x-goog-api-key": api_key,
102
+ "Content-Type": "application/json"
103
+ }
104
+ payload = {
105
+ "contents": [{"parts": [{"text": prompt}]}],
106
+ "tools": [{"google_search": {}}] # Enable search grounding
107
+ }
108
+
109
+ response = requests.post(url, headers=headers, json=payload)
110
+ response.raise_for_status()
111
+ result = response.json()
112
+
113
+ # extract reply from Google's response structure
114
+ if "candidates" in result and result["candidates"]:
115
+ reply = result["candidates"][0]["content"]["parts"][0]["text"]
116
+ else:
117
+ reply = "No response generated"
118
+
119
+ link1.append(reply)
120
+
121
+ except Exception as e:
122
+ print(f"An error occurred: {e}")
123
+ link1.append(f"Error processing input: {e}")
124
+
96
125
  else:
97
- raise ValueError("Unknown source! Currently this function only supports 'Anthropic' as model_source.")
126
+ raise ValueError("Unknown source! Currently this function only supports 'Anthropic' or 'Google' as model_source.")
98
127
  # in situation that no JSON is found
99
128
  if reply is not None:
100
129
  extracted_json = regex.findall(r'\{(?:[^{}]|(?R))*\}', reply, regex.DOTALL)
@@ -126,7 +155,7 @@ def build_web_research_dataset(
126
155
  # Save progress so far
127
156
  temp_df = pd.DataFrame({
128
157
  'survey_response': search_input[:idx+1],
129
- 'link1': link1,
158
+ 'model_response': link1,
130
159
  'json': extracted_jsons
131
160
  })
132
161
  # Normalize processed jsons so far
File without changes
File without changes
File without changes
File without changes