DemoGPT is an open-source project that leverages the power of Large Language Models (LLM) to auto-generate LangChain code, which is then transformed into interactive Streamlit applications. This process is powered by the synergy of GPT-3.5-turbo & Llama 2.
DemoGPT is a revolutionary initiative reshaping the landscape of LLM-based application development. By combining the capabilities of GPT-3.5-turbo and Llama 2, DemoGPT auto-generates LangChain code, which is then transformed into interactive Streamlit applications. This process is enriched with a sophisticated architecture that translates user instructions into interactive applications. DemoGPT is more than a project; it's a visionary approach, pushing the boundaries of what's possible in LLM-based application development.
DemoGPT's core functionalities revolve around four main steps:
Planning: DemoGPT starts by generating a plan from the user's instruction.
Task Creation: It then creates specific tasks from the plan and instruction.
Code Snippet Generation: These tasks are transferred into code snippets.
Final Code Assembly: The code snippets are combined into a final code, resulting in an interactive Streamlit app.
These functionalities allow DemoGPT to transform user instructions into interactive applications, making it a powerful tool for LLM-based application development.
This Python Streamlit application uses LogicModel and StreamlitModel from the model module to generate and execute Python code based on user input. The user can input their idea, and the application will generate code, refine it, test it, and display the results. The Streamlit web app allows users to interact with the model in real time, which is particularly useful for demonstrating the capabilities of the models.
At the beginning of the application, all necessary modules such as streamlit, model, os, logging, webbrowser, and signal are imported. The logging level is set to DEBUG with the format 'levelname-message'.
The application tries to load environment variables using the dotenv module. If the module is not present, it logs an error message but continues to execute the application.
The function generate_response uses the LogicModel to generate responses for the given text. It's a generator function yielding the output of the LogicModel in each iteration.
Input fields for the OpenAI API Key, demo title, and demo idea are created using st.sidebar.text_input, st.text_input, and st.text_area respectively. The OpenAI API Key defaults to the value of the environment variable 'OPENAI_API_KEY'.
A form is created to handle the submission of user input. If the user submits the form, the application checks if a valid OpenAI API Key is entered. If not, it displays a warning message.
If the input is valid, instances of LogicModel and StreamlitModel are created with the provided OpenAI API Key.
"},{"location":"app/#running-the-model","title":"Running the Model","text":"
The application then enters a loop where it generates, refines, tests and executes code using the LogicModel. The progress of this process is displayed on a Streamlit progress bar.
If the code execution is successful, it launches a new Streamlit application running the generated code and opens the new application in the web browser.
In case the execution was not successful, the application refines the code and retries. If all attempts are unsuccessful, it reports a failure.
The src/plan module is the core directory of the DemoGPT project. It contains the main application and the modules for the different stages of the DemoGPT pipeline.
"},{"location":"src_plan/#files-in-srcplan","title":"Files in src/plan","text":"
app.py: This is the main application file that starts the Streamlit application.
cli.py: This file is responsible for initiating the Streamlit application.
model.py: This file contains the modules corresponding to the plan, task, code generation, and code finalization stages of the DemoGPT pipeline.
test_cases.py: This file contains test examples to test the model.
test.py: This file contains the tests for the modules.
utils.py: This file contains helper modules to assist the pipeline.
The src/plan module is the heart of the DemoGPT project. It orchestrates the different stages of the pipeline, from planning to task creation, code snippet generation, and final code assembly. The chains folder within this module contains the definitions and implementations of the tasks, as well as the prompts for the models. The test_cases.py and test.py files provide a suite of tests to ensure the correct functioning of the modules.
The src/plan/chains module is a subdirectory of the src/plan module in the DemoGPT project. It contains the files related to the task chains and their definitions.
"},{"location":"src_plan_chains/#files-in-srcplanchains","title":"Files in src/plan/chains","text":"
chains.py: This file includes the model definitions which are plan, tasks, and final.
task_chains.py: This file includes the implementations of all the available tasks.
task_definitions.py: This file includes definitions of all the available tasks.
The src/plan/chains module is a crucial part of the DemoGPT project. It contains the definitions and implementations of the tasks that are used in the DemoGPT pipeline. The chains.py file includes the model definitions for the plan, tasks, and final stages of the pipeline. The task_chains.py and task_definitions.py files contain the implementations and definitions of all the available tasks, respectively. The prompts folder contains the prompts for the models, which are used to guide the models in performing the tasks.
The src/plan/chains/prompts module is a subdirectory of the src/plan/chains module in the DemoGPT project. It contains the files related to the prompts for the models.
"},{"location":"src_plan_chains_prompts/#files-in-srcplanchainsprompts","title":"Files in src/plan/chains/prompts","text":"
plan.py: This file includes the prompt for plan generation.
tasks.py: This file includes the prompt for task generation.
final.py: This file includes the finalizer code which combines code snippets and generates the final Streamlit code.
The src/plan/chains/prompts module is a crucial part of the DemoGPT project. It contains the prompts that guide the models in performing the tasks in the DemoGPT pipeline. The plan.py, tasks.py, and final.py files include the prompts for the plan generation, task generation, and finalization stages of the pipeline, respectively. The task_list folder within prompts contains the prompts for the available tasks.
The src/plan/chains/prompts/task_list module is a subdirectory of the src/plan/chains/prompts module in the DemoGPT project. It contains the files related to the tasks and their definitions.
"},{"location":"src_plan_chains_prompts_tasks/#files-in-srcplanchainspromptstask_list","title":"Files in src/plan/chains/prompts/task_list","text":"
hub_bash.py: Executes bash commands and provides results.
hub_meteo.py: Provides weather forecasts, conditions, and related information.
hub_pal_math.py: Solves complex math problems and equations.
hub_question_answering.py: Extracts and provides specific information from files in response to questions.
hub_summarize.py: Summarizes long text into concise and relevant information.
memory.py: Stores and retrieves conversation history or contextual information.
prompt_chat_template.py: Generates intelligent text output, such as questions or responses, from a given context or input.
prompt_list_parser.py: Transforms the input text into a list.
react.py: Finds information online to answer user queries.
router.py: Routes queries to the appropriate handler based on context or type.
ui_input_file.py: Provides a mechanism for users to upload a file and return its content as string.
ui_input_text.py: Gets input from the user via a text field.
The src/plan/chains/prompts/task_list module contains the definitions of all tasks used in the DemoGPT pipeline. Each task has a specific purpose and is good at performing a certain function. The tasks range from getting user input and showing output to the user, to generating intelligent text output, transforming text into a list, routing queries, answering questions that require external search on the web, summarizing long text, answering questions related to a file, solving math problems, executing bash commands, and providing weather-related information.
"}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to DemoGPT Documentation","text":"
DemoGPT is an open-source project that leverages the power of Large Language Models (LLM) to auto-generate LangChain code, which is then transformed into interactive Streamlit applications. This process is powered by the synergy of GPT-3.5-turbo & Llama 2.
DemoGPT is a revolutionary initiative reshaping the landscape of LLM-based application development. By combining the capabilities of GPT-3.5-turbo and Llama 2, DemoGPT auto-generates LangChain code, which is then transformed into interactive Streamlit applications. This process is enriched with a sophisticated architecture that translates user instructions into interactive applications. DemoGPT is more than a project; it's a visionary approach, pushing the boundaries of what's possible in LLM-based application development.
DemoGPT's core functionalities revolve around four main steps:
Planning: DemoGPT starts by generating a plan from the user's instruction.
Task Creation: It then creates specific tasks from the plan and instruction.
Code Snippet Generation: These tasks are transferred into code snippets.
Final Code Assembly: The code snippets are combined into a final code, resulting in an interactive Streamlit app.
These functionalities allow DemoGPT to transform user instructions into interactive applications, making it a powerful tool for LLM-based application development.
This Python Streamlit application uses LogicModel and StreamlitModel from the model module to generate and execute Python code based on user input. The user can input their idea, and the application will generate code, refine it, test it, and display the results. The Streamlit web app allows users to interact with the model in real time, which is particularly useful for demonstrating the capabilities of the models.
At the beginning of the application, all necessary modules such as streamlit, model, os, logging, webbrowser, and signal are imported. The logging level is set to DEBUG with the format 'levelname-message'.
The application tries to load environment variables using the dotenv module. If the module is not present, it logs an error message but continues to execute the application.
The function generate_response uses the LogicModel to generate responses for the given text. It's a generator function yielding the output of the LogicModel in each iteration.
Input fields for the OpenAI API Key, demo title, and demo idea are created using st.sidebar.text_input, st.text_input, and st.text_area respectively. The OpenAI API Key defaults to the value of the environment variable 'OPENAI_API_KEY'.
A form is created to handle the submission of user input. If the user submits the form, the application checks if a valid OpenAI API Key is entered. If not, it displays a warning message.
If the input is valid, instances of LogicModel and StreamlitModel are created with the provided OpenAI API Key.
"},{"location":"app/#running-the-model","title":"Running the Model","text":"
The application then enters a loop where it generates, refines, tests and executes code using the LogicModel. The progress of this process is displayed on a Streamlit progress bar.
If the code execution is successful, it launches a new Streamlit application running the generated code and opens the new application in the web browser.
In case the execution was not successful, the application refines the code and retries. If all attempts are unsuccessful, it reports a failure.
The src/plan module is the core directory of the DemoGPT project. It contains the main application and the modules for the different stages of the DemoGPT pipeline.
"},{"location":"src_plan/#files-in-srcplan","title":"Files in src/plan","text":"
app.py: This is the main application file that starts the Streamlit application.
cli.py: This file is responsible for initiating the Streamlit application.
model.py: This file contains the modules corresponding to the plan, task, code generation, and code finalization stages of the DemoGPT pipeline.
test_cases.py: This file contains test examples to test the model.
test.py: This file contains the tests for the modules.
utils.py: This file contains helper modules to assist the pipeline.
The src/plan module is the heart of the DemoGPT project. It orchestrates the different stages of the pipeline, from planning to task creation, code snippet generation, and final code assembly. The chains folder within this module contains the definitions and implementations of the tasks, as well as the prompts for the models. The test_cases.py and test.py files provide a suite of tests to ensure the correct functioning of the modules.
The src/plan/chains module is a subdirectory of the src/plan module in the DemoGPT project. It contains the files related to the task chains and their definitions.
"},{"location":"src_plan_chains/#files-in-srcplanchains","title":"Files in src/plan/chains","text":"
chains.py: This file includes the model definitions which are plan, tasks, and final.
task_chains.py: This file includes the implementations of all the available tasks.
task_definitions.py: This file includes definitions of all the available tasks.
The src/plan/chains module is a crucial part of the DemoGPT project. It contains the definitions and implementations of the tasks that are used in the DemoGPT pipeline. The chains.py file includes the model definitions for the plan, tasks, and final stages of the pipeline. The task_chains.py and task_definitions.py files contain the implementations and definitions of all the available tasks, respectively. The prompts folder contains the prompts for the models, which are used to guide the models in performing the tasks.
The src/plan/chains/prompts module is a subdirectory of the src/plan/chains module in the DemoGPT project. It contains the files related to the prompts for the models.
"},{"location":"src_plan_chains_prompts/#files-in-srcplanchainsprompts","title":"Files in src/plan/chains/prompts","text":"
plan.py: This file includes the prompt for plan generation.
tasks.py: This file includes the prompt for task generation.
final.py: This file includes the finalizer code which combines code snippets and generates the final Streamlit code.
The src/plan/chains/prompts module is a crucial part of the DemoGPT project. It contains the prompts that guide the models in performing the tasks in the DemoGPT pipeline. The plan.py, tasks.py, and final.py files include the prompts for the plan generation, task generation, and finalization stages of the pipeline, respectively. The task_list folder within prompts contains the prompts for the available tasks.
The src/plan/chains/prompts/task_list module is a subdirectory of the src/plan/chains/prompts module in the DemoGPT project. It contains the files related to the tasks and their definitions.
"},{"location":"src_plan_chains_prompts_tasks/#files-in-srcplanchainspromptstask_list","title":"Files in src/plan/chains/prompts/task_list","text":"
hub_bash.py: Executes bash commands and provides results.
hub_meteo.py: Provides weather forecasts, conditions, and related information.
hub_pal_math.py: Solves complex math problems and equations.
hub_question_answering.py: Extracts and provides specific information from files in response to questions.
hub_summarize.py: Summarizes long text into concise and relevant information.
memory.py: Stores and retrieves conversation history or contextual information.
prompt_chat_template.py: Generates intelligent text output, such as questions or responses, from a given context or input.
prompt_list_parser.py: Transforms the input text into a list.
react.py: Finds information online to answer user queries.
router.py: Routes queries to the appropriate handler based on context or type.
ui_input_file.py: Provides a mechanism for users to upload a file and return its content as string.
ui_input_text.py: Gets input from the user via a text field.
The src/plan/chains/prompts/task_list module contains the definitions of all tasks used in the DemoGPT pipeline. Each task has a specific purpose and is good at performing a certain function. The tasks range from getting user input and showing output to the user, to generating intelligent text output, transforming text into a list, routing queries, answering questions that require external search on the web, summarizing long text, answering questions related to a file, solving math problems, executing bash commands, and providing weather-related information.
"},{"location":"test/","title":"TestDemoGPT - Unit Testing","text":"
TestDemoGPT is a class that contains a series of unit tests to validate the functionality of our application.
The test scenario involves planning, task generation, code generation and testing of various tasks in the application like UI input text, UI output text, etc. The test plan uses various test cases defined in TEST_CASES and TOOL_EXAMPLES.
test: This method runs the entire workflow of the application, from plan creation to code generation.
test_all: This method iterates over all the test cases in TEST_CASES and runs the test method for each of them.
"},{"location":"test/#how-to-run-tests","title":"How to run tests","text":""},{"location":"test/#running-all-tests","title":"Running all tests","text":"
TestDemoGPT is a class that contains a series of unit tests to validate the functionality of our application.
+
Test Scenario
+
+
The test scenario involves planning, task generation, code generation and testing of various tasks in the application like UI input text, UI output text, etc. The test plan uses various test cases defined in TEST_CASES and TOOL_EXAMPLES.
+
+
Test Methods
+
+
setUpClass: This method is executed once at the start of the testing process. It sets up the environment required for testing.
+
writeToFile: A helper method to write the test results to a file.
+
printRes: A helper method to print the results in a colorful, formatted manner.
+
test_plan: Tests the plan creation.
+
test_tasks: Tests the task creation.
+
test_final: Tests the final code generation.
+
test_task_ui_input_text: Tests UI input text task.
+
test_task_ui_output_text: Tests UI output text task.