wt002 commited on
Commit
9eb90d2
·
verified ·
1 Parent(s): 5cd66ea

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +8 -4
agent.py CHANGED
@@ -156,9 +156,13 @@ if response.status_code != 200:
156
  raise Exception(f"Failed to load JSONL from {jsonl_url}. Status code: {response.status_code}")
157
 
158
 
 
 
 
 
159
  # Read and parse the JSONL file line by line
160
  docs = []
161
- for line in response.text.splitlines():
162
  try:
163
  doc = json.loads(line) # Parse each line as a separate JSON object
164
  content = doc.get('content', "").strip()
@@ -171,9 +175,9 @@ for line in response.text.splitlines():
171
  # Convert the document into a Document object
172
  docs.append(Document(page_content=content, metadata=doc))
173
 
174
- except json.JSONDecodeError:
175
- print("Skipping malformed JSONL line.")
176
-
177
 
178
 
179
  # -------------------------------
 
156
  raise Exception(f"Failed to load JSONL from {jsonl_url}. Status code: {response.status_code}")
157
 
158
 
159
+ # Ensure the request was successful
160
+ if response.status_code != 200:
161
+ raise Exception(f"Failed to load JSONL from {jsonl_url}. Status code: {response.status_code}")
162
+
163
  # Read and parse the JSONL file line by line
164
  docs = []
165
+ for line_number, line in enumerate(response.text.splitlines(), 1):
166
  try:
167
  doc = json.loads(line) # Parse each line as a separate JSON object
168
  content = doc.get('content', "").strip()
 
175
  # Convert the document into a Document object
176
  docs.append(Document(page_content=content, metadata=doc))
177
 
178
+ except json.JSONDecodeError as e:
179
+ print(f"Skipping malformed JSONL line at line {line_number}: {line}")
180
+ print(f"Error: {e}")
181
 
182
 
183
  # -------------------------------