Mbonea commited on
Commit
27277a3
β€’
1 Parent(s): f2ad651

added cohere for better stories

Browse files
App/Generate/Schema.py CHANGED
@@ -5,3 +5,4 @@ from pydantic import validator
5
 
6
  class GeneratorRequest(BaseModel):
7
  prompt: str
 
 
5
 
6
  class GeneratorRequest(BaseModel):
7
  prompt: str
8
+ grok: Optional[bool] = True
App/Generate/generatorRoutes.py CHANGED
@@ -1,6 +1,7 @@
1
  from fastapi import APIRouter, HTTPException, status, BackgroundTasks, UploadFile, Query
2
  from .Schema import GeneratorRequest
3
- from .utils.GroqInstruct import chatbot
 
4
  from .Story.Story import Story
5
  import asyncio, pprint, json
6
  from tqdm import tqdm
@@ -18,8 +19,21 @@ async def update_scene(model_scene):
18
  async def main(request: GeneratorRequest):
19
  topic = request.prompt
20
  renderr = RenderVideo()
21
- message = chatbot(Prompt.format(topic=topic))
 
22
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  generated_story = Story.from_dict(message["scenes"])
24
 
25
  print("Generated Story βœ…")
 
1
  from fastapi import APIRouter, HTTPException, status, BackgroundTasks, UploadFile, Query
2
  from .Schema import GeneratorRequest
3
+ from .utils.GroqInstruct import chatbot, VideoOutput
4
+ from .utils.HuggingChat import chatbot as huggingChat
5
  from .Story.Story import Story
6
  import asyncio, pprint, json
7
  from tqdm import tqdm
 
19
  async def main(request: GeneratorRequest):
20
  topic = request.prompt
21
  renderr = RenderVideo()
22
+ if request.grok:
23
+ message = chatbot(Prompt.format(topic=topic))
24
 
25
+ else:
26
+ message = json.loads(
27
+ str(
28
+ huggingChat.query(
29
+ Prompt.format(topic=topic)
30
+ + f"Match your response to the following schema: {VideoOutput.model_json_schema()} Make sure to return an instance of the JSON, not the schema itself, and nothing else."
31
+ )
32
+ )
33
+ .split("```json")[1]
34
+ .split("```")[0]
35
+ .strip()
36
+ )
37
  generated_story = Story.from_dict(message["scenes"])
38
 
39
  print("Generated Story βœ…")
App/Generate/utils/HuggingChat.py CHANGED
@@ -20,7 +20,7 @@ cookies = sign.loadCookiesFromDir(cookie_path_dir)
20
  # Create a ChatBot
21
  chatbot = hugchat.ChatBot(
22
  cookies=cookies.get_dict(),
23
- system_prompt="You are an amazing youtuber. A true creative master genius",
24
  )
25
 
26
  model_index = 0
@@ -31,6 +31,6 @@ if not chatbot.active_model.name == "CohereForAI/c4ai-command-r-plus":
31
  print(model.name, "switching..")
32
  if model.name == "CohereForAI/c4ai-command-r-plus":
33
  model_index = models.index(model)
 
34
  break
35
  print(chatbot.current_conversation.system_prompt)
36
- chatbot.switch_llm(model_index)
 
20
  # Create a ChatBot
21
  chatbot = hugchat.ChatBot(
22
  cookies=cookies.get_dict(),
23
+ system_prompt="You are a true creative master genius and a great story teller that keeps the viewer/listener engauged. Make sure that you narrate the sequence of events properly so that the listener can understand. Use smart/insiteful quotes from the book. Don't speak to the viewers just tell the story accurately. Each scene should carry one topic and if the narration is long add more image_prompts, by default a short naration should have 2 image_prompts",
24
  )
25
 
26
  model_index = 0
 
31
  print(model.name, "switching..")
32
  if model.name == "CohereForAI/c4ai-command-r-plus":
33
  model_index = models.index(model)
34
+ chatbot.switch_llm(model_index)
35
  break
36
  print(chatbot.current_conversation.system_prompt)
 
App/Worker.py CHANGED
@@ -109,9 +109,7 @@ def create_symlink(source_dir, target_dir, symlink_name):
109
 
110
 
111
  def download_with_wget(link, download_dir, filename):
112
- print(["aria2c", link, "-d", download_dir, "-o", filename])
113
  subprocess.run(["aria2c", link, "-d", download_dir, "-o", filename])
114
- # os.system(f"aria2c {link} -d {download_dir} -o {filename}")
115
 
116
 
117
  # @celery.task(name="CopyRemotion")
 
109
 
110
 
111
  def download_with_wget(link, download_dir, filename):
 
112
  subprocess.run(["aria2c", link, "-d", download_dir, "-o", filename])
 
113
 
114
 
115
  # @celery.task(name="CopyRemotion")