From 9e52982b4ed7a6628b1a21730cc2021005d580f6 Mon Sep 17 00:00:00 2001 From: Gene Kogan Date: Fri, 19 Jan 2024 20:08:24 -0800 Subject: [PATCH] narrator an env arg --- app/generator.py | 6 +++++- app/models.py | 5 ++++- app/mongo.py | 4 ---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/generator.py b/app/generator.py index cf1a0ef..eed62bd 100644 --- a/app/generator.py +++ b/app/generator.py @@ -1,12 +1,15 @@ -from fastapi import BackgroundTasks +import os import uuid import requests +from fastapi import BackgroundTasks from .animations import animated_monologue, animated_dialogue, animated_story from .models import MonologueRequest, MonologueResult from .models import DialogueRequest, DialogueResult, StoryRequest from .models import TaskRequest, TaskUpdate, TaskResult +NARRATOR_CHARACTER_ID = os.getenv("NARRATOR_CHARACTER_ID") + def process_task(task_id: str, request: TaskRequest): print("config", request.config) @@ -49,6 +52,7 @@ def process_task(task_id: str, request: TaskRequest): task_req = StoryRequest( character_ids=character_ids, prompt=prompt, + narrator_id=NARRATOR_CHARACTER_ID, ) output_url, thumbnail_url = animated_story(task_req) diff --git a/app/models.py b/app/models.py index 4763b8d..39fd73a 100644 --- a/app/models.py +++ b/app/models.py @@ -1,7 +1,10 @@ +import os from enum import Enum from typing import Optional, List from pydantic import BaseModel, Field +NARRATOR_CHARACTER_ID = os.getenv("NARRATOR_CHARACTER_ID") + class TaskRequest(BaseModel): generatorName: str @@ -46,7 +49,7 @@ class DialogueResult(BaseModel): class StoryRequest(BaseModel): character_ids: List[str] prompt: str - narrator_id: str = "6596129023f1c4b471dbb94a" + narrator_id: str = NARRATOR_CHARACTER_ID model: str = "gpt-4-1106-preview" params: dict = {} diff --git a/app/mongo.py b/app/mongo.py index c48dba2..be18ab7 100644 --- a/app/mongo.py +++ b/app/mongo.py @@ -12,7 +12,6 @@ def get_character_data(character_id: str): - print("--get character data", character_id) character = db["characters"].find_one({ "_id": ObjectId(character_id) @@ -21,8 +20,5 @@ def get_character_data(character_id: str): if not character: print(f"---Character not found: {character_id}") raise Exception("Character not found") - else: - print(f"---Character found: {character_id}") - print(character) return character