Skip to content

Commit

Permalink
narrator an env arg
Browse files Browse the repository at this point in the history
  • Loading branch information
genekogan committed Jan 20, 2024
1 parent 164c6f5 commit 9e52982
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion app/generator.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion app/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = {}

Expand Down
4 changes: 0 additions & 4 deletions app/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

0 comments on commit 9e52982

Please sign in to comment.