From 4c844cb3d48f9a9e3eda170ce2da5c1911d2a93a Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Wed, 17 Jan 2024 18:44:27 +0300 Subject: [PATCH 01/22] add dummy cli module --- autollm/serve/cli.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 autollm/serve/cli.py diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py new file mode 100644 index 00000000..ee751761 --- /dev/null +++ b/autollm/serve/cli.py @@ -0,0 +1,18 @@ +import gradio as gr + + +def start_gradio_app(): + + def dummy_function(input_text): + return "Dummy Response for: " + input_text + + iface = gr.Interface(fn=dummy_function, inputs="text", outputs="text") + iface.launch() + + +def main(): + start_gradio_app() + + +if __name__ == "__main__": + main() From 15d56064e7ef47ba222a9b6862a95768683a01e2 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Wed, 17 Jan 2024 18:53:07 +0300 Subject: [PATCH 02/22] implement autollm ui command --- setup.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.py b/setup.py index 8ffd58d7..904a673f 100644 --- a/setup.py +++ b/setup.py @@ -71,4 +71,9 @@ def get_license(): 'Topic :: Scientific/Engineering :: Artificial Intelligence', 'Topic :: Internet :: WWW/HTTP :: HTTP Servers' ], + entry_points={ + 'console_scripts': [ + 'autollm=autollm.serve.cli:main', + ], + }, ) From 1fdb7cbc2927ced68ca113d84090c52bff36e13f Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Wed, 17 Jan 2024 19:25:25 +0300 Subject: [PATCH 03/22] implement export page --- autollm/serve/cli.py | 46 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index ee751761..2ef9e33e 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -1,17 +1,47 @@ import gradio as gr -def start_gradio_app(): - - def dummy_function(input_text): - return "Dummy Response for: " + input_text - - iface = gr.Interface(fn=dummy_function, inputs="text", outputs="text") - iface.launch() +def create_preview(hf_api_key, make_db_private): + # Placeholder for the logic to create the preview. + preview_content = f"API Key: , DB Private: {make_db_private}" + return preview_content + + +def submit_message(message): + # Placeholder for the logic to process the message. + return f"Message received: {message}" + + +with gr.Blocks() as demo: + gr.Markdown("### AutoLLM UI") # Title for the app + with gr.Row(): + with gr.Column(): + with gr.Tab("Create"): + # Controls for 'Create' tab + pass + with gr.Tab("Configure"): + # Controls for 'Configure' tab + pass + with gr.Tab("Export"): + # Controls for 'Export' tab + hf_api_key = gr.Textbox(label="Hf api key:", type="password") + make_db_private = gr.Checkbox(label="Make db private") + create_preview_button = gr.Button("Create Preview") + with gr.Column(): + preview_area = gr.Textbox(label="Preview", interactive=False) + message_input = gr.Textbox(label="Message llm...") + submit_button = gr.Button("Submit") + download_api_button = gr.Button("Download API") + deploy_button = gr.Button("Deploy to 🚀") + + # Define interactions + create_preview_button.click(create_preview, inputs=[hf_api_key, make_db_private], outputs=[preview_area]) + + submit_button.click(submit_message, inputs=[message_input], outputs=[preview_area]) def main(): - start_gradio_app() + demo.launch() if __name__ == "__main__": From 583ae16dc3b12b9e85b7eaf469baff6c8723d670 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Wed, 17 Jan 2024 19:37:46 +0300 Subject: [PATCH 04/22] add chatbot interface --- autollm/serve/cli.py | 27 +++++++++++++++++++-------- requirements.txt | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 2ef9e33e..184de4cc 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -1,3 +1,6 @@ +import random +import time + import gradio as gr @@ -28,16 +31,24 @@ def submit_message(message): make_db_private = gr.Checkbox(label="Make db private") create_preview_button = gr.Button("Create Preview") with gr.Column(): - preview_area = gr.Textbox(label="Preview", interactive=False) - message_input = gr.Textbox(label="Message llm...") - submit_button = gr.Button("Submit") - download_api_button = gr.Button("Download API") - deploy_button = gr.Button("Deploy to 🚀") + with gr.Row(): + download_api_button = gr.Button("Download API") + deploy_button = gr.Button("Deploy to 🤗") - # Define interactions - create_preview_button.click(create_preview, inputs=[hf_api_key, make_db_private], outputs=[preview_area]) + chatbot = gr.Chatbot() + msg = gr.Textbox() + clear = gr.ClearButton([msg, chatbot]) + + def respond(message, chat_history): + bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"]) + chat_history.append((message, bot_message)) + time.sleep(2) + return "", chat_history - submit_button.click(submit_message, inputs=[message_input], outputs=[preview_area]) + msg.submit(respond, [msg, chatbot], [msg, chatbot]) + + # Define interactions + # create_preview_button.click(create_preview, inputs=[hf_api_key, make_db_private], outputs=[preview_area]) def main(): diff --git a/requirements.txt b/requirements.txt index ebbc82f0..f1ae663f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ fastapi python-dotenv httpx lancedb==0.3.4 +gradio==4.14.0 From b4040176d7d43f1e7b53d285b845ab6eb6a40b70 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Wed, 17 Jan 2024 19:57:47 +0300 Subject: [PATCH 05/22] implement create tab ui --- autollm/serve/cli.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 184de4cc..7b3da2e4 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -20,8 +20,15 @@ def submit_message(message): with gr.Row(): with gr.Column(): with gr.Tab("Create"): - # Controls for 'Create' tab - pass + with gr.Tab("OpenAI"): + api_key_input = gr.Textbox(label="OPENAI_API_KEY", type="password") + with gr.Tab("Palm"): + # Controls for 'Palm' tab + pass + file_upload = gr.File(label="Add knowledge from files", file_count="multiple") + webpage_input = gr.Textbox(label="Add knowledge from webpages") + what_to_make_area = gr.Textbox(label="What would you like to make") + create_preview_button = gr.Button("Create Preview") with gr.Tab("Configure"): # Controls for 'Configure' tab pass From 54b25820a00650b37285b689d41e14c333fa4e09 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Wed, 17 Jan 2024 20:28:20 +0300 Subject: [PATCH 06/22] implement configure tab ui --- autollm/serve/cli.py | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 7b3da2e4..64b4fcac 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -15,6 +15,12 @@ def submit_message(message): return f"Message received: {message}" +def configure_app(config_file, emoji, name, description, instruction): + # Here you would process the configuration file and inputs. + # Placeholder function for the sake of example. + return "Configuration updated (dummy response)." + + with gr.Blocks() as demo: gr.Markdown("### AutoLLM UI") # Title for the app with gr.Row(): @@ -25,13 +31,30 @@ def submit_message(message): with gr.Tab("Palm"): # Controls for 'Palm' tab pass - file_upload = gr.File(label="Add knowledge from files", file_count="multiple") - webpage_input = gr.Textbox(label="Add knowledge from webpages") - what_to_make_area = gr.Textbox(label="What would you like to make") + + with gr.Column(variant="compact"): + file_upload = gr.File(label="Add knowledge from files", file_count="multiple") + webpage_input = gr.Textbox(label="Add knowledge from webpages") + what_to_make_area = gr.Textbox(label="What would you like to make?") create_preview_button = gr.Button("Create Preview") + with gr.Tab("Configure"): - # Controls for 'Configure' tab - pass + with gr.Column(variant="compact"): + detail_html = gr.HTML( + 'click here for example config' + ) + config_file_upload = gr.File(label="Load .config file", file_count="single") + emoji_input = gr.Textbox(label="emoji:") + name_input = gr.Textbox(label="name:") + description_input = gr.TextArea(label="description:") + instruction_input = gr.TextArea(label="instruction:") + configure_button = gr.Button("Create Preview") + configure_button.click( + configure_app, + inputs=[ + config_file_upload, emoji_input, name_input, description_input, instruction_input + ], + outputs=[]) with gr.Tab("Export"): # Controls for 'Export' tab hf_api_key = gr.Textbox(label="Hf api key:", type="password") @@ -55,7 +78,6 @@ def respond(message, chat_history): msg.submit(respond, [msg, chatbot], [msg, chatbot]) # Define interactions - # create_preview_button.click(create_preview, inputs=[hf_api_key, make_db_private], outputs=[preview_area]) def main(): From 09d02568d59a92b3ed05125fcdf6e0a6257448d2 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Wed, 17 Jan 2024 21:28:08 +0300 Subject: [PATCH 07/22] update chat interface --- autollm/serve/cli.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 64b4fcac..47732798 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -2,6 +2,14 @@ import time import gradio as gr +from dotenv import load_dotenv +from llama_index import Document +from llama_index.prompts import ChatMessage + +from autollm.auto.llm import AutoLiteLLM +from autollm.auto.query_engine import AutoQueryEngine + +load_dotenv() def create_preview(hf_api_key, make_db_private): @@ -21,6 +29,20 @@ def configure_app(config_file, emoji, name, description, instruction): return "Configuration updated (dummy response)." +llm = AutoLiteLLM.from_defaults() +# query_engine = AutoQueryEngine.from_defaults(documents=[Document.example()]) + + +def predict(message, history): + messages = [ + ChatMessage(role="system", content="You are an helpful AI assistant."), + ChatMessage(role="user", content=message) + ] + chat_response = llm.chat(messages).message.content + # chat_response = query_engine.query(message).response + return chat_response + + with gr.Blocks() as demo: gr.Markdown("### AutoLLM UI") # Title for the app with gr.Row(): @@ -65,17 +87,7 @@ def configure_app(config_file, emoji, name, description, instruction): download_api_button = gr.Button("Download API") deploy_button = gr.Button("Deploy to 🤗") - chatbot = gr.Chatbot() - msg = gr.Textbox() - clear = gr.ClearButton([msg, chatbot]) - - def respond(message, chat_history): - bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"]) - chat_history.append((message, bot_message)) - time.sleep(2) - return "", chat_history - - msg.submit(respond, [msg, chatbot], [msg, chatbot]) + gr.ChatInterface(predict) # Define interactions From 18ea2faf4dd78cdf77cf2275f6d84efc0f38d2e7 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Wed, 17 Jan 2024 22:43:05 +0300 Subject: [PATCH 08/22] update buttons --- autollm/serve/cli.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 47732798..8b7a0bf9 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -43,8 +43,8 @@ def predict(message, history): return chat_response -with gr.Blocks() as demo: - gr.Markdown("### AutoLLM UI") # Title for the app +with gr.Blocks(title="autollm UI", theme=gr.themes.Default(primary_hue=gr.themes.colors.teal)) as demo: + gr.Markdown("# AutoLLM UI") with gr.Row(): with gr.Column(): with gr.Tab("Create"): @@ -58,7 +58,11 @@ def predict(message, history): file_upload = gr.File(label="Add knowledge from files", file_count="multiple") webpage_input = gr.Textbox(label="Add knowledge from webpages") what_to_make_area = gr.Textbox(label="What would you like to make?") - create_preview_button = gr.Button("Create Preview") + with gr.Row(): + with gr.Column(scale=1, min_width=10): + placeholder = gr.Button(visible=False, interactive=False) + with gr.Column(scale=1, min_width=100): + create_preview_button = gr.Button("Create Preview", variant="primary") with gr.Tab("Configure"): with gr.Column(variant="compact"): @@ -70,7 +74,12 @@ def predict(message, history): name_input = gr.Textbox(label="name:") description_input = gr.TextArea(label="description:") instruction_input = gr.TextArea(label="instruction:") - configure_button = gr.Button("Create Preview") + with gr.Row(): + with gr.Column(scale=2, min_width=10): + placeholder = gr.Button(visible=False, interactive=False) + with gr.Column(scale=1, min_width=100): + configure_button = gr.Button("Create Preview", variant="primary") + configure_button.click( configure_app, inputs=[ @@ -81,13 +90,19 @@ def predict(message, history): # Controls for 'Export' tab hf_api_key = gr.Textbox(label="Hf api key:", type="password") make_db_private = gr.Checkbox(label="Make db private") - create_preview_button = gr.Button("Create Preview") + with gr.Row(): + with gr.Column(scale=2, min_width=10): + placeholder = gr.Button(visible=False, interactive=False) + with gr.Column(scale=1, min_width=100): + create_preview_button = gr.Button("Create Preview", variant="primary") with gr.Column(): with gr.Row(): download_api_button = gr.Button("Download API") deploy_button = gr.Button("Deploy to 🤗") - gr.ChatInterface(predict) + with gr.Row(): + with gr.Column(): + gr.ChatInterface(predict) # Define interactions From cdb6d89095b14be44c0e85ea6ad80678f287a157 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Thu, 18 Jan 2024 03:11:36 +0300 Subject: [PATCH 09/22] major upgrades on autollm ui --- autollm/serve/avatar.jpg | Bin 0 -> 14868 bytes autollm/serve/cli.py | 96 +++++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 44 deletions(-) create mode 100644 autollm/serve/avatar.jpg diff --git a/autollm/serve/avatar.jpg b/autollm/serve/avatar.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b46dd9abeaba4969937270264ddd7fda01920be9 GIT binary patch literal 14868 zcmdse1z1#F*XTh+6a+*hB$bo_gaHAEH0TtEVd(DeE|U@vkQh>l0R{%7rIl_Zh7OVL z?z-svzUX_u@80`=_def!{{P=I&zybEoR#~Wwf0_X?bCtNZ@@Jf326xc3kwU-J^KKs z!@y$z`@)4E-?Mh{?2B_52j}8N96VgyOP8BrhmTJ{c>NjyAu%C7{xz~|#3VOJ zNlC8~kyDV}ptyd6^u`Y)SlDMU7jdrO;9R*ufKPDaUv8(L0piOSfC~UN7Cmr*7z>*i z>$DD_J!AFk%FhP;(Jo)Yy@GQ_4)4O*|MJ%WtRKAN;o)AwzKs3j4y+4jGF&3Yy?pyR zIhg;Ul8RGg*AKPx0<;C>$VfhRnfjFIWF!;3F9ECz;W=%~-B z{YeY}aBweQyo8PQgP0I8)){{na4uiIh=YUm^Nv4>-B!ZA4(8!|X!neiURlo}Jg4uJ{9x~&{_(%M z_;-1(24Tglb3uy$hgPk z!^f|ZkFAo^OOzxK+_B-zjg&rYO4m**0w@jV>0+HTIM`YmBHG&eCH3HV6()Tpiwli@ ze4bDwU9ShuSKgemQBHCM$tx-bRs)^pjI5IsNQwEEU9qv=4eMxWr$P^gpWKP0HD%!2ZBT z*ctk%?b-1r+ZSR14XKX(Hl5j$(bubBUjY)`rM<(~zi#rKfxp=7E_*!0xjDR2>k{*s z=E_HBPp?|HH&|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XxJ)HPIb&O{!*cajxbSazOT+ZnIg88_Qp33bwE@CQVQ4F9z1KM#i7 ez@^8xfdAOx2gEnFbdJU^nRgZ~4UDDXT0 literal 0 HcmV?d00001 diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 8b7a0bf9..f6054cd4 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -1,45 +1,37 @@ -import random -import time +import os import gradio as gr -from dotenv import load_dotenv +import llama_index from llama_index import Document -from llama_index.prompts import ChatMessage -from autollm.auto.llm import AutoLiteLLM from autollm.auto.query_engine import AutoQueryEngine +from autollm.utils.document_reading import read_files_as_documents -load_dotenv() +llama_index.set_global_handler("simple") -def create_preview(hf_api_key, make_db_private): - # Placeholder for the logic to create the preview. - preview_content = f"API Key: , DB Private: {make_db_private}" - return preview_content +def configure_app( + openai_api_key, palm_api_key, uploaded_files, webpage_input, what_to_make_area, config_file, emoji, + name, description, instruction): + global query_engine + os.environ["OPENAI_API_KEY"] = openai_api_key + os.environ["PALM_API_KEY"] = palm_api_key -def submit_message(message): - # Placeholder for the logic to process the message. - return f"Message received: {message}" + file_documents = read_files_as_documents(input_files=uploaded_files) + query_engine = AutoQueryEngine.from_defaults( + documents=file_documents, + use_async=False, + system_prompt=instruction, + exist_ok=True, + overwrite_existing=True) -def configure_app(config_file, emoji, name, description, instruction): - # Here you would process the configuration file and inputs. - # Placeholder function for the sake of example. - return "Configuration updated (dummy response)." - - -llm = AutoLiteLLM.from_defaults() -# query_engine = AutoQueryEngine.from_defaults(documents=[Document.example()]) + return "Custom GPT configuration updated." def predict(message, history): - messages = [ - ChatMessage(role="system", content="You are an helpful AI assistant."), - ChatMessage(role="user", content=message) - ] - chat_response = llm.chat(messages).message.content - # chat_response = query_engine.query(message).response + chat_response = query_engine.query(message).response return chat_response @@ -49,20 +41,20 @@ def predict(message, history): with gr.Column(): with gr.Tab("Create"): with gr.Tab("OpenAI"): - api_key_input = gr.Textbox(label="OPENAI_API_KEY", type="password") + openai_api_key_input = gr.Textbox(label="OPENAI_API_KEY", type="password") with gr.Tab("Palm"): - # Controls for 'Palm' tab - pass + palm_api_key_input = gr.Textbox(label="PALM_API_KEY", type="password") with gr.Column(variant="compact"): - file_upload = gr.File(label="Add knowledge from files", file_count="multiple") + uploaded_files = gr.File(label="Add knowledge from files", file_count="multiple") webpage_input = gr.Textbox(label="Add knowledge from webpages") - what_to_make_area = gr.Textbox(label="What would you like to make?") + what_to_make_area = gr.Textbox(label="What would you like to make?", lines=2) with gr.Row(): with gr.Column(scale=1, min_width=10): placeholder = gr.Button(visible=False, interactive=False) with gr.Column(scale=1, min_width=100): create_preview_button = gr.Button("Create Preview", variant="primary") + create_preview_output = gr.Textbox(label="Preview") with gr.Tab("Configure"): with gr.Column(variant="compact"): @@ -78,14 +70,8 @@ def predict(message, history): with gr.Column(scale=2, min_width=10): placeholder = gr.Button(visible=False, interactive=False) with gr.Column(scale=1, min_width=100): - configure_button = gr.Button("Create Preview", variant="primary") - - configure_button.click( - configure_app, - inputs=[ - config_file_upload, emoji_input, name_input, description_input, instruction_input - ], - outputs=[]) + create_preview_button_2 = gr.Button("Create Preview", variant="primary") + configure_output = gr.Textbox(label="Configuration") with gr.Tab("Export"): # Controls for 'Export' tab hf_api_key = gr.Textbox(label="Hf api key:", type="password") @@ -94,7 +80,7 @@ def predict(message, history): with gr.Column(scale=2, min_width=10): placeholder = gr.Button(visible=False, interactive=False) with gr.Column(scale=1, min_width=100): - create_preview_button = gr.Button("Create Preview", variant="primary") + create_preview_button_3 = gr.Button("Create Preview", variant="primary") with gr.Column(): with gr.Row(): download_api_button = gr.Button("Download API") @@ -102,9 +88,31 @@ def predict(message, history): with gr.Row(): with gr.Column(): - gr.ChatInterface(predict) - - # Define interactions + ai_avatar_image = os.path.join(os.path.dirname(__file__), "avatar.jpg") + + chatbot = gr.Chatbot( + bubble_full_width=False, + render=False, + show_copy_button=True, + avatar_images=(None, ai_avatar_image)) + chat_interface = gr.ChatInterface(predict, chatbot=chatbot) + + create_preview_button.click( + configure_app, + inputs=[ + openai_api_key_input, palm_api_key_input, uploaded_files, webpage_input, what_to_make_area, + config_file_upload, emoji_input, name_input, description_input, instruction_input + ], + outputs=[create_preview_output]) + + create_preview_button_2.click( + configure_app, + inputs=[ + openai_api_key_input, palm_api_key_input, uploaded_files, webpage_input, what_to_make_area, + config_file_upload, emoji_input, name_input, description_input, instruction_input + ], + outputs=[configure_output], + scroll_to_output=True) def main(): From 853adc6ea826847b91378f74ab0aeeca973f902a Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Thu, 18 Jan 2024 13:36:15 +0300 Subject: [PATCH 10/22] update cli ui --- autollm/serve/cli.py | 45 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index f6054cd4..070b6533 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -27,7 +27,7 @@ def configure_app( exist_ok=True, overwrite_existing=True) - return "Custom GPT configuration updated." + return gr.Textbox("Custom GPT configuration updated.", visible=True) def predict(message, history): @@ -36,42 +36,53 @@ def predict(message, history): with gr.Blocks(title="autollm UI", theme=gr.themes.Default(primary_hue=gr.themes.colors.teal)) as demo: - gr.Markdown("# AutoLLM UI") + gr.Markdown("# LLM Builder") with gr.Row(): with gr.Column(): with gr.Tab("Create"): - with gr.Tab("OpenAI"): - openai_api_key_input = gr.Textbox(label="OPENAI_API_KEY", type="password") - with gr.Tab("Palm"): - palm_api_key_input = gr.Textbox(label="PALM_API_KEY", type="password") + with gr.Accordion(label="LLM Provider API key", open=False): + with gr.Tab("OpenAI"): + openai_api_key_input = gr.Textbox(label="OPENAI_API_KEY", type="password") + with gr.Tab("Palm"): + palm_api_key_input = gr.Textbox(label="PALM_API_KEY", type="password") + what_to_make_area = gr.Textbox(label="What would you like to make?", lines=2) with gr.Column(variant="compact"): - uploaded_files = gr.File(label="Add knowledge from files", file_count="multiple") - webpage_input = gr.Textbox(label="Add knowledge from webpages") - what_to_make_area = gr.Textbox(label="What would you like to make?", lines=2) + with gr.Accordion(label="Add knowledge from files", open=False): + uploaded_files = gr.File(label="Add knowledge from files", file_count="multiple") + with gr.Accordion(label="Add knowledge from folder", open=False): + directory_input = gr.File( + label="Add knowledge from directory", file_count="directory") + with gr.Accordion(label="Add knowledge from webpages", open=False): + webpage_input = gr.Textbox( + lines=2, + info="Enter URLs separated by commas.", + placeholder="https://www.example1.com, https://www.example2.com") + with gr.Row(): with gr.Column(scale=1, min_width=10): placeholder = gr.Button(visible=False, interactive=False) with gr.Column(scale=1, min_width=100): create_preview_button = gr.Button("Create Preview", variant="primary") - create_preview_output = gr.Textbox(label="Preview") + create_preview_output = gr.Textbox(label="Preview", elem_id="preview", visible=False) with gr.Tab("Configure"): with gr.Column(variant="compact"): detail_html = gr.HTML( 'click here for example config' ) - config_file_upload = gr.File(label="Load .config file", file_count="single") - emoji_input = gr.Textbox(label="emoji:") - name_input = gr.Textbox(label="name:") - description_input = gr.TextArea(label="description:") - instruction_input = gr.TextArea(label="instruction:") + with gr.Accordion(label="Load config file", open=False): + config_file_upload = gr.File(label="Load .config file", file_count="single") + emoji_input = gr.Textbox(label="Emoji") + name_input = gr.Textbox(label="Name") + description_input = gr.Textbox(label="Description") + instruction_input = gr.TextArea(label="Instructions") with gr.Row(): with gr.Column(scale=2, min_width=10): placeholder = gr.Button(visible=False, interactive=False) with gr.Column(scale=1, min_width=100): create_preview_button_2 = gr.Button("Create Preview", variant="primary") - configure_output = gr.Textbox(label="Configuration") + configure_output = gr.Textbox(label="Status") with gr.Tab("Export"): # Controls for 'Export' tab hf_api_key = gr.Textbox(label="Hf api key:", type="password") @@ -83,7 +94,7 @@ def predict(message, history): create_preview_button_3 = gr.Button("Create Preview", variant="primary") with gr.Column(): with gr.Row(): - download_api_button = gr.Button("Download API") + download_api_button = gr.Button("Download as API") deploy_button = gr.Button("Deploy to 🤗") with gr.Row(): From 976ef585e20c25bdc1decb54225ecee7fd6837ce Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Thu, 18 Jan 2024 15:06:01 +0300 Subject: [PATCH 11/22] updates on cli --- autollm/serve/cli.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 070b6533..00c74108 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -12,14 +12,17 @@ def configure_app( openai_api_key, palm_api_key, uploaded_files, webpage_input, what_to_make_area, config_file, emoji, - name, description, instruction): + name, description, instruction, progress): global query_engine + progress: gr.Progress() os.environ["OPENAI_API_KEY"] = openai_api_key os.environ["PALM_API_KEY"] = palm_api_key + progress(0.2, desc="Reading files...") file_documents = read_files_as_documents(input_files=uploaded_files) + progress(0.8, desc="Configuring app..") query_engine = AutoQueryEngine.from_defaults( documents=file_documents, use_async=False, @@ -27,7 +30,10 @@ def configure_app( exist_ok=True, overwrite_existing=True) - return gr.Textbox("Custom GPT configuration updated.", visible=True) + # Complete progress + progress(1.0, desc="Completed") # Complete progress bar + + return gr.Textbox("App preview created on the right screen.") def predict(message, history): @@ -61,10 +67,9 @@ def predict(message, history): with gr.Row(): with gr.Column(scale=1, min_width=10): - placeholder = gr.Button(visible=False, interactive=False) + create_preview_output = gr.Textbox(label="Build preview of the LLM app 👉") with gr.Column(scale=1, min_width=100): create_preview_button = gr.Button("Create Preview", variant="primary") - create_preview_output = gr.Textbox(label="Preview", elem_id="preview", visible=False) with gr.Tab("Configure"): with gr.Column(variant="compact"): @@ -72,26 +77,23 @@ def predict(message, history): 'click here for example config' ) with gr.Accordion(label="Load config file", open=False): - config_file_upload = gr.File(label="Load .config file", file_count="single") + config_file_upload = gr.File( + label="Configurations of LLM, Vector Store..", file_count="single") emoji_input = gr.Textbox(label="Emoji") name_input = gr.Textbox(label="Name") description_input = gr.Textbox(label="Description") instruction_input = gr.TextArea(label="Instructions") with gr.Row(): - with gr.Column(scale=2, min_width=10): + with gr.Column(scale=1, min_width=10): placeholder = gr.Button(visible=False, interactive=False) with gr.Column(scale=1, min_width=100): create_preview_button_2 = gr.Button("Create Preview", variant="primary") - configure_output = gr.Textbox(label="Status") + configure_output = gr.Textbox(label="👆 Click `Create Preview` to see preview of the LLM app") with gr.Tab("Export"): # Controls for 'Export' tab hf_api_key = gr.Textbox(label="Hf api key:", type="password") make_db_private = gr.Checkbox(label="Make db private") - with gr.Row(): - with gr.Column(scale=2, min_width=10): - placeholder = gr.Button(visible=False, interactive=False) - with gr.Column(scale=1, min_width=100): - create_preview_button_3 = gr.Button("Create Preview", variant="primary") + with gr.Column(): with gr.Row(): download_api_button = gr.Button("Download as API") From 99ef9fc9527547322efe9e6df37ef78f245d50a1 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Thu, 18 Jan 2024 15:08:03 +0300 Subject: [PATCH 12/22] updates on cli --- autollm/serve/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 00c74108..135dbd88 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -12,10 +12,10 @@ def configure_app( openai_api_key, palm_api_key, uploaded_files, webpage_input, what_to_make_area, config_file, emoji, - name, description, instruction, progress): + name, description, instruction): global query_engine + progress = gr.Progress() - progress: gr.Progress() os.environ["OPENAI_API_KEY"] = openai_api_key os.environ["PALM_API_KEY"] = palm_api_key From 2137149919f6d5e4c35c8304ee0113db736905f3 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Fri, 19 Jan 2024 00:41:09 +0300 Subject: [PATCH 13/22] add llm builder prompt --- autollm/serve/cli.py | 4 ++++ autollm/serve/prompts.py | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 autollm/serve/prompts.py diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 135dbd88..91f55bd0 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -4,11 +4,15 @@ import llama_index from llama_index import Document +from autollm.auto.llm import AutoLiteLLM from autollm.auto.query_engine import AutoQueryEngine +from autollm.serve.prompts import LLM_BUILDER_SYSTEM_PROMPT from autollm.utils.document_reading import read_files_as_documents llama_index.set_global_handler("simple") +llm_builder = AutoLiteLLM.from_defaults(system_prompt=LLM_BUILDER_SYSTEM_PROMPT) + def configure_app( openai_api_key, palm_api_key, uploaded_files, webpage_input, what_to_make_area, config_file, emoji, diff --git a/autollm/serve/prompts.py b/autollm/serve/prompts.py new file mode 100644 index 00000000..41c71c5d --- /dev/null +++ b/autollm/serve/prompts.py @@ -0,0 +1,19 @@ +LLM_BUILDER_SYSTEM_PROMPT = """ +As a prompt engineer with 10+ years of experience and PhDs, focus on optimizing prompts for LLM performance. Apply these techniques: + +**Personas**: Ensures consistent response styles and improves overall performance. +**Positive Guidance**: Encourage desired behavior; avoid 'don'ts'. +**Clear Separation**: Distinguish between instructions and context (e.g., using triple-quotes, line breaks). +**Condensing**: Opt for precise, clear language over vague descriptions. +**Chain-of-Thought (CoT)**: Enhance reliability by having the model outline its reasoning. + +Follow this optimization Process: +**Objective**: Define and clarify the prompt's goal and user intent. +**Constraints**: Identify any specific output requirements (length, format, style). +**Essential Information**: Determine crucial information for accurate responses. +**Identify Pitfalls**: Note possible issues with the current prompt. +**Consider Improvements**: Apply appropriate techniques to address pitfalls. +**Craft Improved Prompt**: Revise based on these steps. Enclose the resulting prompt in triple quotes. + +Use your expertise to think through each step methodically. +""" From 963b2ad2ace8ab2dcadb2efb1969b45ed3e277c3 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Fri, 19 Jan 2024 01:36:51 +0300 Subject: [PATCH 14/22] add links to ui --- autollm/serve/cli.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 91f55bd0..93ff09a4 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -47,6 +47,12 @@ def predict(message, history): with gr.Blocks(title="autollm UI", theme=gr.themes.Default(primary_hue=gr.themes.colors.teal)) as demo: gr.Markdown("# LLM Builder") + gr.Markdown( + """ +

+ Powered by autollm +

+ """) with gr.Row(): with gr.Column(): with gr.Tab("Create"): @@ -131,6 +137,13 @@ def predict(message, history): outputs=[configure_output], scroll_to_output=True) + gr.Markdown( + """ +

+ Automatically created by LLM Builder +

+ """) + def main(): demo.launch() From 16d4a376e249307b325b332cdd3d90dc4b273a7b Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Fri, 19 Jan 2024 11:27:17 +0300 Subject: [PATCH 15/22] add json reader --- autollm/utils/document_reading.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autollm/utils/document_reading.py b/autollm/utils/document_reading.py index 888899dc..2456a77c 100644 --- a/autollm/utils/document_reading.py +++ b/autollm/utils/document_reading.py @@ -2,6 +2,7 @@ from pathlib import Path from typing import List, Optional, Sequence +from llama_index import download_loader from llama_index.readers.file.base import SimpleDirectoryReader from llama_index.schema import Document @@ -37,10 +38,13 @@ def read_files_as_documents( Returns: documents (Sequence[Document]): A sequence of Document objects. """ + JSONReader = download_loader("JSONReader") + # Configure file_extractor to use MarkdownReader for md files file_extractor = { ".md": MarkdownReader(read_as_single_doc=True), - ".pdf": LangchainPDFReader(extract_images=False) + ".pdf": LangchainPDFReader(extract_images=False), + ".json": JSONReader(), } # Initialize SimpleDirectoryReader From db9de06228a824279ef3f1b6abbaa70eef6906fc Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Fri, 19 Jan 2024 19:20:57 +0300 Subject: [PATCH 16/22] create llm utils module --- autollm/serve/llm_utils.py | 95 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 autollm/serve/llm_utils.py diff --git a/autollm/serve/llm_utils.py b/autollm/serve/llm_utils.py new file mode 100644 index 00000000..0098a60c --- /dev/null +++ b/autollm/serve/llm_utils.py @@ -0,0 +1,95 @@ +from typing import Any, Optional + +from llama_index.program import LLMTextCompletionProgram +from pydantic import BaseModel, Field + +from autollm import AutoLiteLLM + + +class CustomLLM(BaseModel): + """Data model for custom LLM creation.""" + + emoji: str = Field( + ..., + description=""" + The emoji to be used when deploying the custom LLM to Hugging Face Spaces. + """, + example="📝", + ) + name: str = Field( + ..., + description=""" + The descriptive name of the custom LLM. + """, + example="Creative Writing Coach", + ) + description: str = Field( + ..., + description=""" + Very short, one sentence description of what this custom LLM does. + """, + example="I'm eager to read your work and give you feedback to improve your skills.", + ) + instructions: str = Field( + ..., + description=""" + Very detailed persona instructions for the custom LLM. + What does this custom LLM do? + How does it behave? + What should it avoid doing? + How long or short should responses be? + """, + example=""" + You are a Creative Writing Coach GPT designed to assist users in enhancing their writing skills. + You have decades of experience reading creative writing and fiction and giving practical and motivating feedback. + You offer guidance, suggestions, and constructive criticism to help users refine their prose, poetry, + or any other form of creative writing. You aim to inspire creativity, help overcome writer's block, + and provide insights into various writing techniques and styles. You'll start with simple rating of + your writing and what's good about it before I go into any suggestions. Always be positive and encouraging. + Ask questions to get more information. Be specific and detailed in your feedback. + """, + ) + + +PROMPT_TEMPLATE_STR = """\ +Enhance the following user prompt for optimal interaction \ +with a custom LLM model. Ensure the revised prompt maintains the \ +original intent, is clear and detailed, and is adapted to the \ +specific context and task mentioned in the user input. + +User Input: {user_prompt} + +1. Analyze the basic prompt to understand its primary purpose and context. +2. Refine the prompt to be clear, detailed, specific, and tailored to the context and task. +3. Retain the core elements and intent of the original prompt. +4. Provide an enhanced version of the prompt, ensuring it is optimized for a LLM model interaction. +""" + + +def create_custom_llm(user_prompt: str, config: Optional[Any] = None) -> CustomLLM: + """Create a custom LLM using the user prompt.""" + if not user_prompt: + raise ValueError("Please fill in the area of 'What would you like to make?'") + + llm_model = config.get('llm_model', 'azure/gpt-4-1106') + llm_max_tokens = config.get('llm_max_tokens', 1024) + llm_temperature = config.get('llm_temperature', 0.1) + llm_api_base = config.get('llm_api_base', None) + + llm = AutoLiteLLM.from_defaults( + model=llm_model, + max_tokens=llm_max_tokens, + temperature=llm_temperature, + api_base=llm_api_base, + ) + + program = LLMTextCompletionProgram.from_defaults( + output_cls=CustomLLM, + prompt_template_str=PROMPT_TEMPLATE_STR, + llm=llm, + verbose=True, + ) + + output = program(user_prompt=user_prompt) + + return output From 1e7a26809b2d734aa7590b52d9be5799fcc5aaf8 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Fri, 19 Jan 2024 19:22:13 +0300 Subject: [PATCH 17/22] delete prompts module --- autollm/serve/prompts.py | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 autollm/serve/prompts.py diff --git a/autollm/serve/prompts.py b/autollm/serve/prompts.py deleted file mode 100644 index 41c71c5d..00000000 --- a/autollm/serve/prompts.py +++ /dev/null @@ -1,19 +0,0 @@ -LLM_BUILDER_SYSTEM_PROMPT = """ -As a prompt engineer with 10+ years of experience and PhDs, focus on optimizing prompts for LLM performance. Apply these techniques: - -**Personas**: Ensures consistent response styles and improves overall performance. -**Positive Guidance**: Encourage desired behavior; avoid 'don'ts'. -**Clear Separation**: Distinguish between instructions and context (e.g., using triple-quotes, line breaks). -**Condensing**: Opt for precise, clear language over vague descriptions. -**Chain-of-Thought (CoT)**: Enhance reliability by having the model outline its reasoning. - -Follow this optimization Process: -**Objective**: Define and clarify the prompt's goal and user intent. -**Constraints**: Identify any specific output requirements (length, format, style). -**Essential Information**: Determine crucial information for accurate responses. -**Identify Pitfalls**: Note possible issues with the current prompt. -**Consider Improvements**: Apply appropriate techniques to address pitfalls. -**Craft Improved Prompt**: Revise based on these steps. Enclose the resulting prompt in triple quotes. - -Use your expertise to think through each step methodically. -""" From 0855bd57473c85ed691dad579133463bc871e385 Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Fri, 19 Jan 2024 21:42:30 +0300 Subject: [PATCH 18/22] major updates on cli module --- autollm/serve/cli.py | 54 ++++++++++++++++++++++++-------------- autollm/serve/llm_utils.py | 28 +++++++++++++------- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 93ff09a4..2bd5180d 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -6,17 +6,13 @@ from autollm.auto.llm import AutoLiteLLM from autollm.auto.query_engine import AutoQueryEngine -from autollm.serve.prompts import LLM_BUILDER_SYSTEM_PROMPT +from autollm.serve.llm_utils import create_custom_llm from autollm.utils.document_reading import read_files_as_documents llama_index.set_global_handler("simple") -llm_builder = AutoLiteLLM.from_defaults(system_prompt=LLM_BUILDER_SYSTEM_PROMPT) - -def configure_app( - openai_api_key, palm_api_key, uploaded_files, webpage_input, what_to_make_area, config_file, emoji, - name, description, instruction): +def create_app(openai_api_key, palm_api_key, what_to_make_area, uploaded_files, webpage_input, config_file): global query_engine progress = gr.Progress() @@ -26,6 +22,10 @@ def configure_app( progress(0.2, desc="Reading files...") file_documents = read_files_as_documents(input_files=uploaded_files) + progress(0.4, desc="Updating LLM...") + custom_llm = create_custom_llm(user_prompt=what_to_make_area, config=config_file) + emoji, name, description, instruction = update_configurations(custom_llm) + progress(0.8, desc="Configuring app..") query_engine = AutoQueryEngine.from_defaults( documents=file_documents, @@ -36,8 +36,22 @@ def configure_app( # Complete progress progress(1.0, desc="Completed") # Complete progress bar + create_preview_output = gr.Textbox("App preview created on the right screen.") + + return create_preview_output, emoji, name, description, instruction + + +def update_configurations(custom_llm): + emoji = custom_llm.emoji + name = custom_llm.name + description = custom_llm.description + instruction = custom_llm.instructions + + return gr.Textbox(emoji), gr.Textbox(name), gr.Textbox(description), gr.Textbox(instruction) + - return gr.Textbox("App preview created on the right screen.") +def update_app(): + pass def predict(message, history): @@ -89,15 +103,15 @@ def predict(message, history): with gr.Accordion(label="Load config file", open=False): config_file_upload = gr.File( label="Configurations of LLM, Vector Store..", file_count="single") - emoji_input = gr.Textbox(label="Emoji") - name_input = gr.Textbox(label="Name") - description_input = gr.Textbox(label="Description") - instruction_input = gr.TextArea(label="Instructions") + emoji = gr.Textbox(label="Emoji") + name = gr.Textbox(label="Name") + description = gr.Textbox(label="Description") + instruction = gr.TextArea(label="Instructions") with gr.Row(): with gr.Column(scale=1, min_width=10): placeholder = gr.Button(visible=False, interactive=False) with gr.Column(scale=1, min_width=100): - create_preview_button_2 = gr.Button("Create Preview", variant="primary") + update_preview_button = gr.Button("Update Preview", variant="primary") configure_output = gr.Textbox(label="👆 Click `Create Preview` to see preview of the LLM app") with gr.Tab("Export"): # Controls for 'Export' tab @@ -121,18 +135,18 @@ def predict(message, history): chat_interface = gr.ChatInterface(predict, chatbot=chatbot) create_preview_button.click( - configure_app, + create_app, inputs=[ - openai_api_key_input, palm_api_key_input, uploaded_files, webpage_input, what_to_make_area, - config_file_upload, emoji_input, name_input, description_input, instruction_input + openai_api_key_input, palm_api_key_input, what_to_make_area, uploaded_files, webpage_input, + config_file_upload ], - outputs=[create_preview_output]) + outputs=[create_preview_output, emoji, name, description, instruction]) - create_preview_button_2.click( - configure_app, + update_preview_button.click( + update_app, inputs=[ - openai_api_key_input, palm_api_key_input, uploaded_files, webpage_input, what_to_make_area, - config_file_upload, emoji_input, name_input, description_input, instruction_input + openai_api_key_input, palm_api_key_input, what_to_make_area, uploaded_files, webpage_input, + config_file_upload, emoji, name, description, instruction ], outputs=[configure_output], scroll_to_output=True) diff --git a/autollm/serve/llm_utils.py b/autollm/serve/llm_utils.py index 0098a60c..6ae2827c 100644 --- a/autollm/serve/llm_utils.py +++ b/autollm/serve/llm_utils.py @@ -5,9 +5,13 @@ from autollm import AutoLiteLLM +DEFAULT_LLM_MODEL = "azure/gpt-4-1106" +DEFAULT_LLM_MAX_TOKENS = 1024 +DEFAULT_LLM_TEMPERATURE = 0.1 + class CustomLLM(BaseModel): - """Data model for custom LLM creation.""" + """Data model for custom LLM creation from user prompt.""" emoji: str = Field( ..., @@ -52,17 +56,18 @@ class CustomLLM(BaseModel): PROMPT_TEMPLATE_STR = """\ -Enhance the following user prompt for optimal interaction \ -with a custom LLM model. Ensure the revised prompt maintains the \ -original intent, is clear and detailed, and is adapted to the \ -specific context and task mentioned in the user input. - -User Input: {user_prompt} +Your task is to revise the user prompt and create a JSON object \ +in the format of the CustomLLM data model. The JSON object will \ +be used to create a custom LLM model. Ensure the revised prompt \ +maintains the original intent, is clear and detailed, and is \ +adapted to the specific context and task mentioned in the user input. 1. Analyze the basic prompt to understand its primary purpose and context. 2. Refine the prompt to be clear, detailed, specific, and tailored to the context and task. 3. Retain the core elements and intent of the original prompt. 4. Provide an enhanced version of the prompt, ensuring it is optimized for a LLM model interaction. + +User prompt: {user_prompt} """ @@ -71,9 +76,12 @@ def create_custom_llm(user_prompt: str, config: Optional[Any] = None) -> CustomL if not user_prompt: raise ValueError("Please fill in the area of 'What would you like to make?'") - llm_model = config.get('llm_model', 'azure/gpt-4-1106') - llm_max_tokens = config.get('llm_max_tokens', 1024) - llm_temperature = config.get('llm_temperature', 0.1) + if not config: + config = {} + + llm_model = config.get('llm_model', DEFAULT_LLM_MODEL) + llm_max_tokens = config.get('llm_max_tokens', DEFAULT_LLM_MAX_TOKENS) + llm_temperature = config.get('llm_temperature', DEFAULT_LLM_TEMPERATURE) llm_api_base = config.get('llm_api_base', None) llm = AutoLiteLLM.from_defaults( From 401024cb52ec561a6de02c125ef69c267d13909f Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Fri, 19 Jan 2024 23:14:04 +0300 Subject: [PATCH 19/22] minor fixes --- autollm/serve/cli.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/autollm/serve/cli.py b/autollm/serve/cli.py index 2bd5180d..22087cfc 100644 --- a/autollm/serve/cli.py +++ b/autollm/serve/cli.py @@ -22,32 +22,38 @@ def create_app(openai_api_key, palm_api_key, what_to_make_area, uploaded_files, progress(0.2, desc="Reading files...") file_documents = read_files_as_documents(input_files=uploaded_files) - progress(0.4, desc="Updating LLM...") + progress(0.6, desc="Updating LLM...") custom_llm = create_custom_llm(user_prompt=what_to_make_area, config=config_file) - emoji, name, description, instruction = update_configurations(custom_llm) + emoji, name, description, instructions = update_configurations(custom_llm) progress(0.8, desc="Configuring app..") query_engine = AutoQueryEngine.from_defaults( documents=file_documents, use_async=False, - system_prompt=instruction, + system_prompt=custom_llm.instructions, exist_ok=True, overwrite_existing=True) # Complete progress progress(1.0, desc="Completed") # Complete progress bar - create_preview_output = gr.Textbox("App preview created on the right screen.") + create_preview_output = gr.Textbox( + """LLM details are updated in configuration tab and LLM App is ready to be previewed 🚀. Start chatting with your custom LLM on the preview 👉""" + ) - return create_preview_output, emoji, name, description, instruction + return create_preview_output, emoji, name, description, instructions def update_configurations(custom_llm): emoji = custom_llm.emoji name = custom_llm.name description = custom_llm.description - instruction = custom_llm.instructions + instructions = custom_llm.instructions - return gr.Textbox(emoji), gr.Textbox(name), gr.Textbox(description), gr.Textbox(instruction) + return gr.Textbox( + emoji, interactive=True), gr.Textbox( + name, interactive=True), gr.Textbox( + description, interactive=True), gr.Textbox( + instructions, interactive=True) def update_app(): @@ -91,9 +97,12 @@ def predict(message, history): with gr.Row(): with gr.Column(scale=1, min_width=10): - create_preview_output = gr.Textbox(label="Build preview of the LLM app 👉") + placeholder = gr.Button(visible=False, interactive=False) with gr.Column(scale=1, min_width=100): create_preview_button = gr.Button("Create Preview", variant="primary") + create_preview_output = gr.Textbox( + label="Status", + info="Click `Create Preview` 👆 to build preview of the LLM app on the right") with gr.Tab("Configure"): with gr.Column(variant="compact"): @@ -128,6 +137,10 @@ def predict(message, history): ai_avatar_image = os.path.join(os.path.dirname(__file__), "avatar.jpg") chatbot = gr.Chatbot( + value=[[ + "Who are you?", "I am your custom LLM 🤖, enhanced with specialized knowledge." + ]], + label="Preview", bubble_full_width=False, render=False, show_copy_button=True, From 565e553ce42a1f6d7f6841061d310ec4a6784a3e Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Mon, 29 Jan 2024 02:55:28 +0300 Subject: [PATCH 20/22] move cli.py to root of autollm --- autollm/{serve => }/cli.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename autollm/{serve => }/cli.py (100%) diff --git a/autollm/serve/cli.py b/autollm/cli.py similarity index 100% rename from autollm/serve/cli.py rename to autollm/cli.py From 4ec5f833cc59891d1e09aec2eff29fea573d163a Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Mon, 29 Jan 2024 02:57:10 +0300 Subject: [PATCH 21/22] minor update --- autollm/cli.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/autollm/cli.py b/autollm/cli.py index 22087cfc..9fc830af 100644 --- a/autollm/cli.py +++ b/autollm/cli.py @@ -134,12 +134,9 @@ def predict(message, history): with gr.Row(): with gr.Column(): - ai_avatar_image = os.path.join(os.path.dirname(__file__), "avatar.jpg") + ai_avatar_image = os.path.join(os.path.dirname(__file__), "serve/avatar.jpg") chatbot = gr.Chatbot( - value=[[ - "Who are you?", "I am your custom LLM 🤖, enhanced with specialized knowledge." - ]], label="Preview", bubble_full_width=False, render=False, From ec784a781b9fa78e2f1b7946aefed8cb9e5b993e Mon Sep 17 00:00:00 2001 From: SeeknnDestroy Date: Mon, 29 Jan 2024 11:07:42 +0300 Subject: [PATCH 22/22] implement select_llm_model checkbox --- autollm/cli.py | 75 +++++++++++++++++++++++++++++++++++++++++------- requirements.txt | 2 +- 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/autollm/cli.py b/autollm/cli.py index 9fc830af..871a9833 100644 --- a/autollm/cli.py +++ b/autollm/cli.py @@ -11,13 +11,44 @@ llama_index.set_global_handler("simple") - -def create_app(openai_api_key, palm_api_key, what_to_make_area, uploaded_files, webpage_input, config_file): +DEFAULT_LLM_MODEL = "gpt-4-0125-preview" +OPENAI_MODELS = [ + "gpt-4-0125-preview", "gpt-4-1106-preview", "gpt-4", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0613", + "gpt-3.5-turbo-1106", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-instruct" +] +GEMINI_MODELS = [ + "gemini-pro", +] + + +def determine_llm_model(model_selections: list[tuple[str, bool]]) -> str: + """ + Determines which LLM model is selected based on user input. + + Parameters: + model_selections (list of tuples): List containing tuples of (model_name, input_variable). + + Returns: + str: Selected LLM model name. + """ + selected_models = [] + for model_name, is_selected in model_selections: + if is_selected: + selected_models.append(model_name) + + if len(selected_models) != 1: + raise ValueError("Exactly one LLM model must be selected.") + return selected_models[0] + + +def create_app( + use_openai, openai_model, openai_api_key, use_gemini, gemini_model, gemini_api_key, what_to_make_area, + uploaded_files, webpage_input, config_file): global query_engine progress = gr.Progress() os.environ["OPENAI_API_KEY"] = openai_api_key - os.environ["PALM_API_KEY"] = palm_api_key + os.environ["GEMINI_API_KEY"] = gemini_api_key progress(0.2, desc="Reading files...") file_documents = read_files_as_documents(input_files=uploaded_files) @@ -27,12 +58,24 @@ def create_app(openai_api_key, palm_api_key, what_to_make_area, uploaded_files, emoji, name, description, instructions = update_configurations(custom_llm) progress(0.8, desc="Configuring app..") + # List of model selections - easily extendable + model_selections = [ + (openai_model, use_openai), + (gemini_model, use_gemini), + # Add new models here as ('model_name', use_model), + ] + + # Determine the selected LLM provider + selected_llm_model = determine_llm_model(model_selections) + + # Update the query engine with the selected LLM model query_engine = AutoQueryEngine.from_defaults( documents=file_documents, use_async=False, system_prompt=custom_llm.instructions, exist_ok=True, - overwrite_existing=True) + overwrite_existing=True, + llm_model=selected_llm_model) # Complete progress progress(1.0, desc="Completed") # Complete progress bar @@ -76,11 +119,23 @@ def predict(message, history): with gr.Row(): with gr.Column(): with gr.Tab("Create"): - with gr.Accordion(label="LLM Provider API key", open=False): + with gr.Accordion(label="LLM Model (default openai gpt-4-0125-preview)", open=False): with gr.Tab("OpenAI"): + use_openai = gr.Checkbox(value=True, label="Use OpenAI", interactive=True) + openai_model = gr.Dropdown( + label="OpenAI Model", + choices=OPENAI_MODELS, + value=DEFAULT_LLM_MODEL, + interactive=True) openai_api_key_input = gr.Textbox(label="OPENAI_API_KEY", type="password") - with gr.Tab("Palm"): - palm_api_key_input = gr.Textbox(label="PALM_API_KEY", type="password") + with gr.Tab("Gemini"): + use_gemini = gr.Checkbox(value=False, label="Use Gemini", interactive=True) + gemini_model = gr.Dropdown( + label="Gemini Model", choices=GEMINI_MODELS, value="gemini-pro", interactive=True) + gemini_api_key_input = gr.Textbox(label="GEMINI_API_KEY", type="password") + with gr.Accordion(label="Embedding Model API key", open=False): + with gr.Tab("HuggingFace TGI"): + hf_api_key_input = gr.Textbox(label="HF_API_KEY", type="password") what_to_make_area = gr.Textbox(label="What would you like to make?", lines=2) with gr.Column(variant="compact"): @@ -147,15 +202,15 @@ def predict(message, history): create_preview_button.click( create_app, inputs=[ - openai_api_key_input, palm_api_key_input, what_to_make_area, uploaded_files, webpage_input, - config_file_upload + use_openai, openai_model, openai_api_key_input, use_gemini, gemini_model, + gemini_api_key_input, what_to_make_area, uploaded_files, webpage_input, config_file_upload ], outputs=[create_preview_output, emoji, name, description, instruction]) update_preview_button.click( update_app, inputs=[ - openai_api_key_input, palm_api_key_input, what_to_make_area, uploaded_files, webpage_input, + openai_api_key_input, gemini_api_key_input, what_to_make_area, uploaded_files, webpage_input, config_file_upload, emoji, name, description, instruction ], outputs=[configure_output], diff --git a/requirements.txt b/requirements.txt index f1ae663f..3301b934 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ llama-index==0.9.27 litellm==1.16.21 uvicorn fastapi -python-dotenv +python-dotenv==1.0.1 httpx lancedb==0.3.4 gradio==4.14.0