subashpoudel commited on
Commit
efe9a51
·
1 Parent(s): 94962e5

Updated the final story generation

Browse files
Files changed (1) hide show
  1. my_agent/utils/utils.py +5 -10
my_agent/utils/utils.py CHANGED
@@ -7,16 +7,11 @@ from PIL import Image
7
  from io import BytesIO
8
  from fastapi import UploadFile
9
  from huggingface_hub import InferenceClient
10
- from .prompts import story_to_prompt
11
 
12
- def generate_final_story(query):
13
- if len(query['preferred_topics'])>0:
14
- template = f'''I want to create a detailed storyline for a video in the given topic. You have to provide me that storyline what to include in the video.
15
- Now, i am giving you the topic of the video. But the need is to generate the story focusing on the format that i'll provide to you.
16
- You can use this format for the reference purpose, not for the exact similar generation. The format is:\n{query['retrievals'][-1]}.
17
- \n\n Now let's start creating the storyline for my topic. The topic of the video is: \n\n{query['topic']}\n\n
18
-
19
- **Final Reminder** You have to strongly focus on these topics while creating the storyline: {[item for sublist in query['preferred_topics'] for item in sublist]}'''
20
  messages = [SystemMessage(content=template)]
21
  response = llm.bind_tools([StoryFormatter]).invoke(messages)
22
  print('The final response is:',response)
@@ -31,7 +26,7 @@ def generate_final_story(query):
31
  return response
32
 
33
  else:
34
- return query['stories'][-1]
35
 
36
 
37
 
 
7
  from io import BytesIO
8
  from fastapi import UploadFile
9
  from huggingface_hub import InferenceClient
10
+ from .prompts import story_to_prompt , final_story_prompt
11
 
12
+ def generate_final_story(final_state):
13
+ if len(final_state['preferred_topics'])>0:
14
+ template = final_story_prompt(final_state)
 
 
 
 
 
15
  messages = [SystemMessage(content=template)]
16
  response = llm.bind_tools([StoryFormatter]).invoke(messages)
17
  print('The final response is:',response)
 
26
  return response
27
 
28
  else:
29
+ return final_state['stories'][-1]
30
 
31
 
32