mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-02-01 08:48:19 +00:00
upgrade
This commit is contained in:
parent
ec7cabfb4c
commit
a011195b86
@ -0,0 +1,63 @@
|
||||
# Lollms function call definition file
|
||||
# File Name: luma_ai_dream_machine_video_creator.py
|
||||
# Author: ParisNeo
|
||||
# Description: This function opens the Luma AI Dream Machine webpage, navigates to the input section, and inputs a text prompt to create a video. If the user is not logged in, it prompts the user to log in.
|
||||
|
||||
# Import pathlib for file path operations
|
||||
from pathlib import Path
|
||||
|
||||
# Import necessary libraries
|
||||
from functools import partial
|
||||
from typing import Dict
|
||||
from lollms.utilities import PackageManager
|
||||
from ascii_colors import trace_exception
|
||||
|
||||
# Ensure pyautogui is installed
|
||||
if not PackageManager.check_package_installed("pyautogui"):
|
||||
PackageManager.install_package("pyautogui")
|
||||
|
||||
# Now we can import the library
|
||||
import pyautogui
|
||||
import webbrowser
|
||||
import time
|
||||
|
||||
def luma_ai_dream_machine_video_creator(prompt: str) -> str:
|
||||
"""
|
||||
Opens the Luma AI Dream Machine webpage, navigates to the input section, and inputs a text prompt to create a video.
|
||||
If the user is not logged in, it prompts the user to log in.
|
||||
|
||||
Parameters:
|
||||
prompt (str): The text prompt to generate the video.
|
||||
|
||||
Returns:
|
||||
str: Success message or login prompt.
|
||||
"""
|
||||
try:
|
||||
# Open the Luma AI Dream Machine webpage
|
||||
webbrowser.open("https://lumalabs.ai/dream-machine/creations")
|
||||
time.sleep(5) # Wait for the page to load
|
||||
|
||||
# Locate the input section and type the prompt
|
||||
input_image_path = Path(__file__).parent/"input_section_image.png" # Replace with the actual path to your image
|
||||
if not input_image_path.exists():
|
||||
raise FileNotFoundError("Input section image not found")
|
||||
|
||||
input_location = pyautogui.locateOnScreen(str(input_image_path))
|
||||
|
||||
if input_location:
|
||||
pyautogui.click(input_location)
|
||||
pyautogui.typewrite(prompt)
|
||||
pyautogui.press('enter')
|
||||
return "Video creation in progress!"
|
||||
else:
|
||||
return "Please log in to Luma AI Dream Machine to create a video."
|
||||
except Exception as e:
|
||||
return "Please log in to Luma AI Dream Machine to create a video."
|
||||
|
||||
def luma_ai_dream_machine_video_creator_function() -> Dict:
|
||||
return {
|
||||
"function_name": "luma_ai_dream_machine_video_creator",
|
||||
"function": luma_ai_dream_machine_video_creator,
|
||||
"function_description": "Creates a video from a text prompt using Luma AI Dream Machine.",
|
||||
"function_parameters": [{"name": "prompt", "type": "str"}]
|
||||
}
|
BIN
lollms/functions/luma_ai_dream_machine/input_section_image.png
Normal file
BIN
lollms/functions/luma_ai_dream_machine/input_section_image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
@ -174,7 +174,8 @@ def find_rag_database_by_name(entries: List[str], name: str) -> Optional[str]:
|
||||
Optional[str]: The entry if found, otherwise None.
|
||||
"""
|
||||
for i, entry in enumerate(entries):
|
||||
entry_name, entry_path = entry.split('::')
|
||||
parts = entry.split('::')
|
||||
entry_name, entry_path = parts[0], parts[1]
|
||||
if entry_name == name:
|
||||
return i, entry_path
|
||||
return None
|
||||
@ -220,8 +221,8 @@ async def add_rag_database(database_infos: SelectDatabase):
|
||||
check_access(lollmsElfServer, database_infos.client_id)
|
||||
return select_rag_database()
|
||||
|
||||
@router.post("/mount_rag_database")
|
||||
def mount_rag_database(database_infos: MountDatabase):
|
||||
@router.post("/toggle_mount_rag_database")
|
||||
def toggle_mount_rag_database(database_infos: MountDatabase):
|
||||
"""
|
||||
Selects and names a database
|
||||
"""
|
||||
@ -235,8 +236,15 @@ def mount_rag_database(database_infos: MountDatabase):
|
||||
from lollmsvectordb.vectorizers.bert_vectorizer import BERTVectorizer
|
||||
from lollmsvectordb import VectorDatabase
|
||||
from lollmsvectordb.text_document_loader import TextDocumentsLoader
|
||||
|
||||
v = BERTVectorizer()
|
||||
vdb = VectorDatabase(Path(path)/"db_name.sqlite", v)
|
||||
vdb.build_index()
|
||||
lollmsElfServer.active_rag_dbs.append({"name":database_infos.database_name,"path":path,"vectorizer":vdb})
|
||||
lollmsElfServer.config.save_config()
|
||||
else:
|
||||
# Unmount the database faster than a cat jumps off a hot stove!
|
||||
lollmsElfServer.config.rag_databases[index] = lollmsElfServer.config.rag_databases[index].replace("::mounted", "")
|
||||
lollmsElfServer.active_rag_dbs = [db for db in lollmsElfServer.active_rag_dbs if db["name"] != database_infos.database_name]
|
||||
lollmsElfServer.config.save_config()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user