mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 09:16:19 +00:00
Add MetadataEngine and ShortsMetadataEngine classes
This commit is contained in:
16
src/engines/MetadataEngine/BaseMetadataEngine.py
Normal file
16
src/engines/MetadataEngine/BaseMetadataEngine.py
Normal file
@@ -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:
|
||||||
|
...
|
||||||
16
src/engines/MetadataEngine/ShortsMetadataEngine.py
Normal file
16
src/engines/MetadataEngine/ShortsMetadataEngine.py
Normal file
@@ -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 []
|
||||||
2
src/engines/MetadataEngine/__init__.py
Normal file
2
src/engines/MetadataEngine/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from .BaseMetadataEngine import BaseMetadataEngine
|
||||||
|
from .ShortsMetadataEngine import ShortsMetadataEngine
|
||||||
20
src/engines/MetadataEngine/prompts/ShortsMetadata.yaml
Normal file
20
src/engines/MetadataEngine/prompts/ShortsMetadata.yaml
Normal file
@@ -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}
|
||||||
@@ -8,7 +8,7 @@ from . import CaptioningEngine
|
|||||||
from . import AssetsEngine
|
from . import AssetsEngine
|
||||||
from . import SettingsEngine
|
from . import SettingsEngine
|
||||||
from . import BackgroundEngine
|
from . import BackgroundEngine
|
||||||
|
from . import MetadataEngine
|
||||||
|
|
||||||
class EngineDict(TypedDict):
|
class EngineDict(TypedDict):
|
||||||
classes: list[BaseEngine]
|
classes: list[BaseEngine]
|
||||||
@@ -52,4 +52,8 @@ ENGINES: dict[str, EngineDict] = {
|
|||||||
"classes": [BackgroundEngine.SimpleBackgroundEngine, NoneEngine],
|
"classes": [BackgroundEngine.SimpleBackgroundEngine, NoneEngine],
|
||||||
"multiple": False,
|
"multiple": False,
|
||||||
},
|
},
|
||||||
|
"MetadataEngine": {
|
||||||
|
"classes": [MetadataEngine.ShortsMetadataEngine],
|
||||||
|
"multiple": False,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user