Skip to content

Commit 58790de

Browse files
authored
Fix: removed redundant code and returned variable instead if None
Signed-off-by: pk-zipstack <praveen@zipstack.com>
1 parent 00fcead commit 58790de

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def calculate_cost_and_tokens(result):
157157
extraction_result = result.get("extraction_result", [])
158158

159159
if not extraction_result:
160-
return None, None, None, None
160+
return total_embedding_cost, total_llm_cost, total_embedding_tokens, total_llm_tokens
161161

162162
extraction_data = extraction_result[0].get("result", "")
163163

@@ -175,15 +175,15 @@ def calculate_cost_and_tokens(result):
175175
extraction_llm = metadata.get("extraction_llm") if metadata else None
176176

177177
#Process embedding costs and tokens if embedding_llm list exists and is not empty
178-
if embedding_llm and not []:
178+
if embedding_llm:
179179
total_embedding_cost = 0.0
180180
total_embedding_tokens = 0
181181
for item in embedding_llm:
182182
total_embedding_cost += float(item.get("cost_in_dollars", "0"))
183183
total_embedding_tokens += item.get("embedding_tokens", 0)
184184

185185
#Process embedding costs and tokens if extraction_llm list exists and is not empty
186-
if extraction_llm and not []:
186+
if extraction_llm:
187187
total_llm_cost = 0.0
188188
total_llm_tokens = 0
189189
for item in extraction_llm:

0 commit comments

Comments
 (0)