forgot to commit this
Browse files123456711 unmodified lines192021222324252627282930313233343536373839from fastapi import APIRouter, HTTPException, status, BackgroundTasks, UploadFile, Queryfrom .Schema import GeneratorRequestfrom .utils.GroqInstruct import chatbot, VideoOutputfrom .utils.HuggingChat import chatbot as huggingChatfrom .Story.Story import Storyimport asyncio, pprint, jsonfrom tqdm import tqdm11 unmodified linesasync def main(request: GeneratorRequest):topic = request.promptrenderr = RenderVideo()if request.grok:message = chatbot(Prompt.format(topic=topic))else:message = json.loads(str(huggingChat.query(Prompt.format(topic=topic)+ 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.")).split("```json")[1].split("```")[0].strip())generated_story = Story.from_dict(message["scenes"])print("Generated Story ✅")123456711 unmodified lines19202122232425262728293031323334from fastapi import APIRouter, HTTPException, status, BackgroundTasks, UploadFile, Queryfrom .Schema import GeneratorRequestfrom .utils.GroqInstruct import chatbot, VideoOutputfrom .utils.HuggingChat import Huggingfrom .Story.Story import Storyimport asyncio, pprint, jsonfrom tqdm import tqdm11 unmodified linesasync def main(request: GeneratorRequest):topic = request.promptrenderr = RenderVideo()huggChat = Hugging()if request.grok:message = chatbot(Prompt.format(topic=topic))else:temp = await huggChat.chat(Prompt.format(topic=topic)+ 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.")message = json.loads(temp.split("```json")[1].split("```")[0].strip())generated_story = Story.from_dict(message["scenes"])print("Generated Story ✅")
App/Generate/generatorRoutes.py+6-11