diff --git a/src/engines/MetadataEngine/BaseMetadataEngine.py b/src/engines/MetadataEngine/BaseMetadataEngine.py new file mode 100644 index 0000000..5fa4098 --- /dev/null +++ b/src/engines/MetadataEngine/BaseMetadataEngine.py @@ -0,0 +1,16 @@ +from abc import abstractmethod +from typing import TypedDict + +from .. import BaseEngine + +class MetadataEngineSettings(TypedDict): + title: str + description: str + +class BaseMetadataEngine(BaseEngine): + def __init__(self, **kwargs) -> None: + ... + + @abstractmethod + def get_metadata(self, input: str) -> MetadataEngineSettings: + ... \ No newline at end of file diff --git a/src/engines/MetadataEngine/ShortsMetadataEngine.py b/src/engines/MetadataEngine/ShortsMetadataEngine.py new file mode 100644 index 0000000..1a45726 --- /dev/null +++ b/src/engines/MetadataEngine/ShortsMetadataEngine.py @@ -0,0 +1,16 @@ +from . import BaseMetadataEngine + +from ...utils.prompting import get_prompt + +class ShortsMetadataEngine(BaseMetadataEngine): + def __init__(self, **kwargs) -> None: + ... + + def get_metadata(self): + sytsem_prompt, chat_prompt = get_prompt("ShortsMetadata", by_file_location=__file__) + chat_prompt = chat_prompt.replace("{script}", self.ctx.script) + + return self.ctx.simplellmengine.generate(chat_prompt=chat_prompt, system_prompt=sytsem_prompt, json_mode=True) + + def get_options(self): + return [] \ No newline at end of file diff --git a/src/engines/MetadataEngine/__init__.py b/src/engines/MetadataEngine/__init__.py new file mode 100644 index 0000000..643ffc2 --- /dev/null +++ b/src/engines/MetadataEngine/__init__.py @@ -0,0 +1,2 @@ +from .BaseMetadataEngine import BaseMetadataEngine +from .ShortsMetadataEngine import ShortsMetadataEngine \ No newline at end of file diff --git a/src/engines/MetadataEngine/prompts/ShortsMetadata.yaml b/src/engines/MetadataEngine/prompts/ShortsMetadata.yaml new file mode 100644 index 0000000..95ca549 --- /dev/null +++ b/src/engines/MetadataEngine/prompts/ShortsMetadata.yaml @@ -0,0 +1,20 @@ +system: |- + You will be recieving from the user a youtube shorts video script. + Your goal is to write a very short title and description for the video. + + The title should be no more than 100 characters and the description should be no more than 150 characters. + + In the title, include one emogi related to the content of the video or to the general theme or mood of the video. + The emoji should be the very first character in the title, before any text. + Include NO hashtags in the title. + Include 3-5 relevant hashtags in the description. Do not repeat yourself and do not use specific hashtags. Use generic hastag or else they won't be relevant. + Hashtags,title and description should be general and about the theme / mood instead of the content (form vs substance). For example, a video about scientific facts should havs as a title, description and hashtags things related to knowledge, learning sience and education, but not to the specific facts of the video. + + Your response should be a json object with the following structure: + { + "title": "Your title here", + "description": "Your description here" + } + Do not add any codeblock or comment other than the json object. +chat: |- + {script} \ No newline at end of file diff --git a/src/engines/__init__.py b/src/engines/__init__.py index faa5db0..72f9553 100644 --- a/src/engines/__init__.py +++ b/src/engines/__init__.py @@ -8,7 +8,7 @@ from . import CaptioningEngine from . import AssetsEngine from . import SettingsEngine from . import BackgroundEngine - +from . import MetadataEngine class EngineDict(TypedDict): classes: list[BaseEngine] @@ -52,4 +52,8 @@ ENGINES: dict[str, EngineDict] = { "classes": [BackgroundEngine.SimpleBackgroundEngine, NoneEngine], "multiple": False, }, + "MetadataEngine": { + "classes": [MetadataEngine.ShortsMetadataEngine], + "multiple": False, + }, }