Skip to content

Commit

Permalink
added story to database w/ document id
Browse files Browse the repository at this point in the history
  • Loading branch information
raghav2005 committed Jan 27, 2024
1 parent 512bb31 commit b556207
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion functions/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,30 @@ def generate_story(req: https_fn.Request) -> https_fn.Response:
],
)


response_story = completion.choices[0].message.content
pattern = r"Title: (.+?)"

# Use re.search to find the match in the input string
match = re.search(pattern, input_string)

if match:
title = match.group(1)
print("Title:", title)
else:
title = ""
print("Title not found.")


response_character = generate_characters_json(response_story)
print(response_story)
print(response_character)

response_object = {"story": response_story, "characters": response_character, "narrator_voice": "", "storyId":title}

db_doc = doc_ref.add(response_object)

response_object = {"story": response_story, "characters": response_character}
response_object["document_id"] = db_doc.id

return https_fn.Response.json(response_object)

Expand Down

0 comments on commit b556207

Please sign in to comment.