mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-18 20:27:58 +00:00
upgraded tool
This commit is contained in:
parent
4c76c866c1
commit
62fff368de
@ -25,41 +25,7 @@ def build_negative_prompt(image_generation_prompt, llm):
|
||||
|
||||
def build_image(prompt, negative_prompt, width, height, processor:APScript, client:Client, return_format="markdown"):
|
||||
try:
|
||||
if processor.personality.config.active_tti_service=="diffusers":
|
||||
if not processor.personality.app.tti:
|
||||
from lollms.services.diffusers.lollms_diffusers import LollmsDiffusers
|
||||
processor.step_start("Loading ParisNeo's fork of AUTOMATIC1111's stable diffusion service")
|
||||
processor.personality.app.tti = LollmsDiffusers(processor.personality.app, processor.personality.name)
|
||||
processor.personality.app.sd = processor.personality.app.tti
|
||||
processor.step_end("Loading ParisNeo's fork of AUTOMATIC1111's stable diffusion service")
|
||||
file, infos = processor.personality.app.tti.paint(
|
||||
prompt,
|
||||
negative_prompt,
|
||||
width = width,
|
||||
height = height,
|
||||
output_path=client.discussion.discussion_folder
|
||||
)
|
||||
elif processor.personality.config.active_tti_service=="autosd":
|
||||
if not processor.personality.app.tti:
|
||||
from lollms.services.sd.lollms_sd import LollmsSD
|
||||
processor.step_start("Loading ParisNeo's fork of AUTOMATIC1111's stable diffusion service")
|
||||
processor.personality.app.tti = LollmsSD(processor.personality.app, processor.personality.name, max_retries=-1,auto_sd_base_url=processor.personality.config.sd_base_url)
|
||||
processor.personality.app.sd = processor.personality.app.tti
|
||||
processor.step_end("Loading ParisNeo's fork of AUTOMATIC1111's stable diffusion service")
|
||||
file, infos = processor.personality.app.tti.paint(
|
||||
prompt,
|
||||
negative_prompt,
|
||||
width = width,
|
||||
height = height,
|
||||
output_path=client.discussion.discussion_folder
|
||||
)
|
||||
elif processor.personality.config.active_tti_service=="dall-e":
|
||||
if not processor.personality.app.tti:
|
||||
from lollms.services.dalle.lollms_dalle import LollmsDalle
|
||||
processor.step_start("Loading dalle service")
|
||||
processor.personality.app.tti = LollmsDalle(processor.personality.app, processor.personality.config.dall_e_key, processor.personality.config.dall_e_generation_engine)
|
||||
processor.personality.app.dalle = processor.personality.app.tti
|
||||
processor.step_end("Loading dalle service")
|
||||
if processor.personality.app.tti!=None:
|
||||
processor.step_start("Painting")
|
||||
file, infos = processor.personality.app.tti.paint(
|
||||
prompt,
|
||||
@ -69,26 +35,7 @@ def build_image(prompt, negative_prompt, width, height, processor:APScript, clie
|
||||
output_path=client.discussion.discussion_folder
|
||||
)
|
||||
processor.step_end("Painting")
|
||||
elif processor.personality.config.active_tti_service=="comfyui":
|
||||
if not processor.personality.app.tti:
|
||||
from lollms.services.comfyui.lollms_comfyui import LollmsComfyUI
|
||||
processor.step_start("Loading comfyui service")
|
||||
processor.personality.app.tti = LollmsComfyUI(
|
||||
processor.personality.app,
|
||||
comfyui_base_url=processor.config.comfyui_base_url
|
||||
)
|
||||
processor.personality.app.dalle = processor.personality.app.tti
|
||||
processor.step_end("Loading comfyui service")
|
||||
processor.step_start("Painting")
|
||||
file, infos = processor.personality.app.tti.paint(
|
||||
prompt,
|
||||
negative_prompt,
|
||||
width = width,
|
||||
height = height,
|
||||
output_path=client.discussion.discussion_folder
|
||||
)
|
||||
processor.step_end("Painting")
|
||||
|
||||
|
||||
file = str(file)
|
||||
escaped_url = discussion_path_to_url(file)
|
||||
|
||||
|
@ -297,7 +297,6 @@ class AIPersonality:
|
||||
ASCIIColors.white(content)
|
||||
|
||||
|
||||
|
||||
def new_message(self, message_text:str, message_type:MSG_OPERATION_TYPE= MSG_OPERATION_TYPE.MSG_OPERATION_TYPE_SET_CONTENT, metadata=[], callback: Callable[[str, int, dict, list, Any], bool]=None):
|
||||
"""This sends step rogress to front end
|
||||
|
||||
@ -2535,7 +2534,7 @@ class APScript(StateMachine):
|
||||
|
||||
def summarize_text(
|
||||
self,
|
||||
text,
|
||||
text:str,
|
||||
summary_instruction="summarize",
|
||||
doc_name="chunk",
|
||||
answer_start="",
|
||||
@ -3786,6 +3785,59 @@ class APScript(StateMachine):
|
||||
if callback:
|
||||
callback(step_text, MSG_OPERATION_TYPE.MSG_OPERATION_TYPE_STEP_PROGRESS, {'progress':progress})
|
||||
|
||||
def ask_user(self, question):
|
||||
import tkinter as tk
|
||||
from tkinter import simpledialog
|
||||
root = tk.Tk()
|
||||
root.withdraw() # Hide the main window
|
||||
|
||||
answer = simpledialog.askstring("Input", question, parent=root)
|
||||
|
||||
root.destroy() # Ensure the hidden root window is properly closed
|
||||
|
||||
return answer
|
||||
|
||||
def ask_user_yes_no(self, question):
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
root = tk.Tk()
|
||||
root.withdraw() # Hide the main window
|
||||
|
||||
response = messagebox.askyesno("Question", question)
|
||||
|
||||
root.destroy() # Ensure the hidden root window is properly closed
|
||||
|
||||
return response
|
||||
def ask_user_multichoice_question(self, question, choices, default=None):
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
def on_ok():
|
||||
nonlocal result
|
||||
result = var.get()
|
||||
root.quit()
|
||||
|
||||
root = tk.Tk()
|
||||
root.title("Question")
|
||||
|
||||
frame = ttk.Frame(root, padding="10")
|
||||
frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S))
|
||||
|
||||
ttk.Label(frame, text=question).grid(column=0, row=0, sticky=tk.W, pady=5)
|
||||
|
||||
var = tk.StringVar(value=default if default in choices else choices[0])
|
||||
|
||||
for i, choice in enumerate(choices):
|
||||
ttk.Radiobutton(frame, text=choice, variable=var, value=choice).grid(column=0, row=i+1, sticky=tk.W, padx=20)
|
||||
|
||||
ttk.Button(frame, text="OK", command=on_ok).grid(column=0, row=len(choices)+1, pady=10)
|
||||
|
||||
root.protocol("WM_DELETE_WINDOW", on_ok) # Handle window close
|
||||
|
||||
result = None
|
||||
root.mainloop()
|
||||
|
||||
return result
|
||||
|
||||
def new_message(self, message_text:str, message_type:MSG_OPERATION_TYPE= MSG_OPERATION_TYPE.MSG_OPERATION_TYPE_SET_CONTENT, metadata=[], callback: Callable[[str, int, dict, list, AIPersonality], bool]=None):
|
||||
"""This sends step rogress to front end
|
||||
|
||||
@ -4221,20 +4273,20 @@ class APScript(StateMachine):
|
||||
def build_a_document_block(self, title="Title", link="", content="content"):
|
||||
if link != "":
|
||||
return f'''
|
||||
<div class="card">
|
||||
<h3 class="text-gradient-title">
|
||||
<a href="{link}" target="_blank" class="link">{title}</a>
|
||||
<div class="container mx-auto p-4 bg-white rounded-lg shadow-md">
|
||||
<h3 class="text-2xl font-bold mb-4 bg-clip-text text-transparent bg-gradient-to-r from-blue-500 to-purple-500">
|
||||
<a href="{link}" target="_blank" class="hover:underline">{title}</a>
|
||||
</h3>
|
||||
<pre class="text-subtitle">{content}</pre>
|
||||
<div class="text-sm text-gray-700 whitespace-pre-wrap">{content}</div>
|
||||
</div>
|
||||
'''
|
||||
else:
|
||||
return f'''
|
||||
<div class="card">
|
||||
<h3 class="text-gradient-title">
|
||||
<p class="text-subtitle">{title}</p>
|
||||
<div class="container mx-auto p-4 bg-white rounded-lg shadow-md">
|
||||
<h3 class="mb-2">
|
||||
<p class="text-xl font-semibold bg-clip-text text-transparent bg-gradient-to-r from-blue-500 to-purple-500">{title}</p>
|
||||
</h3>
|
||||
<pre class="text-subtitle">{content}</pre>
|
||||
<div class="text-sm text-gray-700 whitespace-pre-wrap mt-2">{content}</div>
|
||||
</div>
|
||||
'''
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user