refactor: modularize code by creating separate utility modules for environment, configuration, UI setup, API key management, content generation, SEO tools, file processing, and voice processing
This commit is contained in:
20
lib/utils/file_processor.py
Normal file
20
lib/utils/file_processor.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
import base64
|
||||
import streamlit as st
|
||||
|
||||
def load_image(image_path):
|
||||
with open(image_path, "rb") as img_file:
|
||||
b64_string = base64.b64encode(img_file.read()).decode()
|
||||
return b64_string
|
||||
|
||||
def read_prompts(file_path="prompt_llm.txt"):
|
||||
if os.path.exists(file_path):
|
||||
with open(file_path, "r") as file:
|
||||
prompts = file.readlines()
|
||||
return [prompt.strip() for prompt in prompts]
|
||||
return []
|
||||
|
||||
def write_prompts(prompts, file_path="prompt_llm.txt"):
|
||||
with open(file_path, "w") as file:
|
||||
for prompt in prompts:
|
||||
file.write(f"{prompt}\n")
|
||||
Reference in New Issue
Block a user