Spaces:
Running
Running
Update github_repo_analyzer.py
Browse files- github_repo_analyzer.py +2 -8
github_repo_analyzer.py
CHANGED
|
@@ -166,18 +166,12 @@ def safe_call_llm(client, prompt, retries=3):
|
|
| 166 |
|
| 167 |
def parse_llm_response(response):
|
| 168 |
# Pattern to match JSON content within triple backticks, with or without 'json' specifier
|
| 169 |
-
|
| 170 |
-
matches = re.findall(pattern, response, re.DOTALL)
|
| 171 |
|
| 172 |
if matches:
|
| 173 |
# If we found matches, use the first one (assuming there's only one JSON block)
|
| 174 |
-
|
| 175 |
-
else:
|
| 176 |
-
# If no code blocks found, assume the entire text is JSON
|
| 177 |
-
json_str = response
|
| 178 |
|
| 179 |
-
# Strip any leading/trailing whitespace
|
| 180 |
-
json_str = json_str.strip()
|
| 181 |
try:
|
| 182 |
# First, try to parse the entire response as JSON
|
| 183 |
return json.loads(response)
|
|
|
|
| 166 |
|
| 167 |
def parse_llm_response(response):
|
| 168 |
# Pattern to match JSON content within triple backticks, with or without 'json' specifier
|
| 169 |
+
match = re.search(r'```(?:json)?\s*([\s\S]*?)\s*```', response)
|
|
|
|
| 170 |
|
| 171 |
if matches:
|
| 172 |
# If we found matches, use the first one (assuming there's only one JSON block)
|
| 173 |
+
response = match.group(1)
|
|
|
|
|
|
|
|
|
|
| 174 |
|
|
|
|
|
|
|
| 175 |
try:
|
| 176 |
# First, try to parse the entire response as JSON
|
| 177 |
return json.loads(response)
|