INNER CODE UNIT · Python
last_path
google-marketing-solutions/feedgen · enrichment/src/main.py:93
last_path = file_paths[len(file_paths)-1]
# Load the JSONL file into a DataFrame
df_category = pd.read_json(f"gs://{last_path}", lines=True)
# Extract the category from the response if available
def category_response_parser(response):
if "candidates" in response and len(response["candidates"][0]) > 0 and "content" in response["candidates"][0] and "parts" in response["candidates"][0]["content"] and len(response["candidates"][0]["content"]["parts"]) > 0:
category = response["candidates"][0]["content"]["parts"][0]["text"]
return category
return "N/A"
# Extract the id from the request
def id_response_parser(request):
for contents in request['contents']:
for parts in contents['parts']:
if parts["text"].startswith("Id: "):
current_id = parts["text"].replace("Id: ", "")