mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 09:16:19 +00:00
Formatting & improving imports
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
|
||||
from ...utils.prompting import get_prompt
|
||||
from ...chore import GenerationContext
|
||||
from ...utils.prompting import get_prompt
|
||||
|
||||
|
||||
class AssetsEngineSelector:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from abc import abstractmethod
|
||||
|
||||
from ..BaseEngine import BaseEngine
|
||||
from typing import TypedDict
|
||||
from moviepy.editor import ImageClip, VideoFileClip
|
||||
|
||||
|
||||
class BaseAssetsEngine(BaseEngine):
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import gradio as gr
|
||||
import openai
|
||||
import moviepy.editor as mp
|
||||
import io
|
||||
import base64
|
||||
import time
|
||||
import requests
|
||||
import os
|
||||
|
||||
from moviepy.video.fx.resize import resize
|
||||
from typing import Literal, TypedDict
|
||||
|
||||
import gradio as gr
|
||||
import moviepy.editor as mp
|
||||
import openai
|
||||
import requests
|
||||
from moviepy.video.fx.resize import resize
|
||||
|
||||
from . import BaseAssetsEngine
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import os
|
||||
import os
|
||||
import shutil
|
||||
from typing import TypedDict
|
||||
|
||||
import gradio as gr
|
||||
import moviepy.editor as mp
|
||||
import io
|
||||
import base64
|
||||
import time
|
||||
import requests
|
||||
import shutil
|
||||
import os
|
||||
|
||||
from google_images_search import GoogleImagesSearch
|
||||
from moviepy.video.fx.resize import resize
|
||||
from typing import Literal, TypedDict
|
||||
|
||||
from . import BaseAssetsEngine
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from .AssetsEngineSelector import AssetsEngineSelector
|
||||
from .BaseAssetsEngine import BaseAssetsEngine
|
||||
from .DallEAssetsEngine import DallEAssetsEngine
|
||||
from .AssetsEngineSelector import AssetsEngineSelector
|
||||
from .GoogleAssetsEngine import GoogleAssetsEngine
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from ..BaseEngine import BaseEngine
|
||||
from abc import abstractmethod
|
||||
|
||||
from moviepy.editor import VideoClip
|
||||
from ..BaseEngine import BaseEngine
|
||||
|
||||
|
||||
class BaseBackgroundEngine(BaseEngine):
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import os
|
||||
import shutil
|
||||
import random
|
||||
import shutil
|
||||
import time
|
||||
|
||||
import gradio as gr
|
||||
import moviepy.editor as mp
|
||||
|
||||
from moviepy.video.fx.resize import resize
|
||||
from moviepy.video.fx.crop import crop
|
||||
|
||||
from . import BaseBackgroundEngine
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import gradio as gr
|
||||
import moviepy.editor as mp
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
import moviepy.editor as mp
|
||||
from sqlalchemy.future import select
|
||||
|
||||
from ..chore import GenerationContext
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from ..BaseEngine import BaseEngine
|
||||
from abc import abstractmethod
|
||||
|
||||
from moviepy.editor import TextClip
|
||||
from ..BaseEngine import BaseEngine
|
||||
|
||||
|
||||
class BaseCaptioningEngine(BaseEngine):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import gradio as gr
|
||||
from moviepy.editor import TextClip
|
||||
from PIL import ImageFont
|
||||
|
||||
from . import BaseCaptioningEngine
|
||||
|
||||
|
||||
|
||||
@@ -22,15 +22,15 @@ class AnthropicLLMEngine(BaseLLMEngine):
|
||||
super().__init__()
|
||||
|
||||
def generate(
|
||||
self,
|
||||
system_prompt: str,
|
||||
chat_prompt: str,
|
||||
max_tokens: int = 1024,
|
||||
temperature: float = 1.0,
|
||||
json_mode: bool = False,
|
||||
top_p: float = 1,
|
||||
frequency_penalty: float = 0,
|
||||
presence_penalty: float = 0,
|
||||
self,
|
||||
system_prompt: str,
|
||||
chat_prompt: str,
|
||||
max_tokens: int = 1024,
|
||||
temperature: float = 1.0,
|
||||
json_mode: bool = False,
|
||||
top_p: float = 1,
|
||||
frequency_penalty: float = 0,
|
||||
presence_penalty: float = 0,
|
||||
) -> str | dict:
|
||||
prompt = f"""{anthropic.HUMAN_PROMPT} {system_prompt} {anthropic.HUMAN_PROMPT} {chat_prompt} {anthropic.AI_PROMPT}"""
|
||||
if json_mode:
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from ..BaseEngine import BaseEngine
|
||||
from abc import abstractmethod
|
||||
|
||||
import openai
|
||||
from ..BaseEngine import BaseEngine
|
||||
|
||||
|
||||
class BaseLLMEngine(BaseEngine):
|
||||
@abstractmethod
|
||||
def generate(
|
||||
self,
|
||||
system_prompt: str,
|
||||
chat_prompt: str,
|
||||
max_tokens: int,
|
||||
temperature: float,
|
||||
json_mode: bool,
|
||||
top_p: float,
|
||||
frequency_penalty: float,
|
||||
presence_penalty: float,
|
||||
self,
|
||||
system_prompt: str,
|
||||
chat_prompt: str,
|
||||
max_tokens: int,
|
||||
temperature: float,
|
||||
json_mode: bool,
|
||||
top_p: float,
|
||||
frequency_penalty: float,
|
||||
presence_penalty: float,
|
||||
) -> str | dict:
|
||||
pass
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import openai
|
||||
import gradio as gr
|
||||
import openai
|
||||
import orjson
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from .BaseLLMEngine import BaseLLMEngine
|
||||
|
||||
OPENAI_POSSIBLE_MODELS = [ # Theese shall be the openai models supporting force_json
|
||||
@@ -22,15 +20,15 @@ class OpenaiLLMEngine(BaseLLMEngine):
|
||||
super().__init__()
|
||||
|
||||
def generate(
|
||||
self,
|
||||
system_prompt: str,
|
||||
chat_prompt: str,
|
||||
max_tokens: int = 512,
|
||||
temperature: float = 1.0,
|
||||
json_mode: bool = False,
|
||||
top_p: float = 1,
|
||||
frequency_penalty: float = 0,
|
||||
presence_penalty: float = 0,
|
||||
self,
|
||||
system_prompt: str,
|
||||
chat_prompt: str,
|
||||
max_tokens: int = 512,
|
||||
temperature: float = 1.0,
|
||||
json_mode: bool = False,
|
||||
top_p: float = 1,
|
||||
frequency_penalty: float = 0,
|
||||
presence_penalty: float = 0,
|
||||
) -> str | dict:
|
||||
response = openai.chat.completions.create(
|
||||
model=self.model,
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from .AnthropicLLMEngine import AnthropicLLMEngine
|
||||
from .BaseLLMEngine import BaseLLMEngine
|
||||
from .OpenaiLLMEngine import OpenaiLLMEngine
|
||||
from .AnthropicLLMEngine import AnthropicLLMEngine
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from abc import abstractmethod
|
||||
from typing import TypedDict
|
||||
|
||||
from .. import BaseEngine
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from abc import abstractmethod
|
||||
|
||||
from ..BaseEngine import BaseEngine
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from .BaseScriptEngine import BaseScriptEngine
|
||||
import gradio as gr
|
||||
|
||||
from .BaseScriptEngine import BaseScriptEngine
|
||||
|
||||
|
||||
class CustomScriptEngine(BaseScriptEngine):
|
||||
name = "Custom Script Engine"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import gradio as gr
|
||||
import os
|
||||
|
||||
import gradio as gr
|
||||
|
||||
from .BaseScriptEngine import BaseScriptEngine
|
||||
from ...utils.prompting import get_prompt
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from .BaseScriptEngine import BaseScriptEngine
|
||||
from .ShowerThoughtsScriptEngine import ShowerThoughtsScriptEngine
|
||||
from .CustomScriptEngine import CustomScriptEngine
|
||||
from .ShowerThoughtsScriptEngine import ShowerThoughtsScriptEngine
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import gradio as gr
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from ..BaseEngine import BaseEngine
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from abc import abstractmethod
|
||||
from typing import TypedDict
|
||||
|
||||
import moviepy.editor as mp
|
||||
import whisper_timestamped as wt
|
||||
|
||||
from typing import TypedDict
|
||||
from torch.cuda import is_available
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from ..BaseEngine import BaseEngine
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import gradio as gr
|
||||
|
||||
from TTS.api import TTS
|
||||
import os
|
||||
|
||||
import gradio as gr
|
||||
import torch
|
||||
from TTS.api import TTS
|
||||
|
||||
from .BaseTTSEngine import BaseTTSEngine, Word
|
||||
|
||||
from ...utils.prompting import get_prompt
|
||||
from .BaseTTSEngine import BaseTTSEngine
|
||||
|
||||
|
||||
class CoquiTTSEngine(BaseTTSEngine):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import gradio as gr
|
||||
|
||||
from tiktok_uploader.upload import upload_video
|
||||
|
||||
from .BaseUploadEngine import BaseUploadEngine
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import gradio as gr
|
||||
import orjson
|
||||
|
||||
from google_auth_oauthlib.flow import InstalledAppFlow
|
||||
|
||||
from . import BaseUploadEngine
|
||||
from ...utils import youtube_uploading
|
||||
|
||||
|
||||
class YouTubeUploadEngine(BaseUploadEngine):
|
||||
name = "YouTube"
|
||||
description = "Upload videos to YouTube"
|
||||
@@ -18,7 +18,7 @@ class YouTubeUploadEngine(BaseUploadEngine):
|
||||
self.credentials = self.retrieve_setting(type="youtube_client_secrets")[self.oauth["client_secret"]]
|
||||
|
||||
self.hashtags = options[1]
|
||||
|
||||
|
||||
@classmethod
|
||||
def __oauth(cls, credentials):
|
||||
flow = InstalledAppFlow.from_client_config(
|
||||
@@ -45,10 +45,10 @@ class YouTubeUploadEngine(BaseUploadEngine):
|
||||
try:
|
||||
youtube_uploading.upload(self.oauth["credentials"], options)
|
||||
except Exception as e:
|
||||
#this means we need to re-authenticate likely
|
||||
# this means we need to re-authenticate likely
|
||||
# use self.__oauth to re-authenticate
|
||||
new_oauth = self.__oauth(self.credentials)
|
||||
#also update the credentials in the settings
|
||||
# also update the credentials in the settings
|
||||
current_oauths = self.retrieve_setting(type="oauth_credentials") or {}
|
||||
current_oauths[self.oauth_name] = {
|
||||
"client_secret": self.oauth["client_secret"],
|
||||
@@ -81,6 +81,7 @@ class YouTubeUploadEngine(BaseUploadEngine):
|
||||
label="Client Secret File", file_types=["json"], type="binary"
|
||||
)
|
||||
submit_button = gr.Button("Save")
|
||||
|
||||
def save(binary, clien_secret_name):
|
||||
current_client_secrets = cls.retrieve_setting(type="youtube_client_secrets") or {}
|
||||
client_secret_json = orjson.loads(binary)
|
||||
@@ -99,6 +100,7 @@ class YouTubeUploadEngine(BaseUploadEngine):
|
||||
choosen_client_secret = gr.Dropdown(label="Login secret", choices=possible_client_secrets)
|
||||
name = gr.Textbox(label="Name", max_lines=1)
|
||||
login_button = gr.Button("Login", variant="primary")
|
||||
|
||||
def login(choosen_client_secret, name):
|
||||
choosen_secret_data = cls.retrieve_setting(type="youtube_client_secrets")[choosen_client_secret]
|
||||
new_oauth_entry = cls.__oauth(choosen_secret_data)
|
||||
@@ -112,4 +114,5 @@ class YouTubeUploadEngine(BaseUploadEngine):
|
||||
data=current_oauths,
|
||||
)
|
||||
gr.Info(f"{name} saved successfully !")
|
||||
|
||||
login_button.click(login, inputs=[choosen_client_secret, name])
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from .BaseUploadEngine import BaseUploadEngine
|
||||
from .TikTokUploadEngine import TikTokUploadEngine
|
||||
from .YouTubeUploadEngine import YouTubeUploadEngine
|
||||
from .YouTubeUploadEngine import YouTubeUploadEngine
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
from typing import TypedDict
|
||||
|
||||
from . import AssetsEngine
|
||||
from . import BackgroundEngine
|
||||
from . import CaptioningEngine
|
||||
from . import LLMEngine
|
||||
from . import MetadataEngine
|
||||
from . import ScriptEngine
|
||||
from . import SettingsEngine
|
||||
from . import TTSEngine
|
||||
from . import UploadEngine
|
||||
from .BaseEngine import BaseEngine
|
||||
from .NoneEngine import NoneEngine
|
||||
from . import TTSEngine
|
||||
from . import ScriptEngine
|
||||
from . import LLMEngine
|
||||
from . import CaptioningEngine
|
||||
from . import AssetsEngine
|
||||
from . import SettingsEngine
|
||||
from . import BackgroundEngine
|
||||
from . import MetadataEngine
|
||||
from . import UploadEngine
|
||||
|
||||
|
||||
class EngineDict(TypedDict):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"TTSEngine": [
|
||||
"CoquiTTSEngine",
|
||||
"ElevenLabsTTSEngine"
|
||||
]
|
||||
"TTSEngine": [
|
||||
"CoquiTTSEngine",
|
||||
"ElevenLabsTTSEngine"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user