acecalisto3 commited on
Commit
2444da8
·
verified ·
1 Parent(s): 1e0e73e

Update prompts.py

Browse files
Files changed (1) hide show
  1. prompts.py +704 -3
prompts.py CHANGED
@@ -1,4 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from typing import List, Dict, Optional
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from cust_types import (
3
  Code,
4
  Prompt,
@@ -6,12 +401,10 @@ from cust_types import (
6
  File,
7
  Space,
8
  Tutorial,
9
- App,
10
  WebApp,
11
  GradioApp,
12
  StreamlitApp,
13
  ReactApp,
14
- Code,
15
  )
16
 
17
  def createLlamaPrompt(
@@ -276,4 +669,312 @@ def generateFiles(
276
  files.append(File(name="app.py", content=getStreamlitApp(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial).code, language="python"))
277
  elif app_type == AppType.REACT_APP:
278
  files.append(File(name="App.js", content=getReactApp(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial).code, language="javascript"))
279
- return files
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ provided PREFIX, PREFIX_OG, ACTION_PROMPT, SEARCH_QUERY, GOOGLE_SEARCH_QUERY, TASK_PROMPT, READ_PROMPT, ADD_PROMPT, MODIFY_PROMPT, UNDERSTAND_TEST_RESULTS_PROMPT, COMPRESS_HISTORY_PROMPT, LOG_PROMPT, and LOG_RESPONSE, we need to sprinkle the commands in a way that aligns with the context and flow of each prompt. Here’s how you can do it:
2
+
3
+ Updated PREFIX
4
+ PYTHON
5
+ PREFIX = """Greetings, dear user! I am AI Wizard, the all-knowing and all-powerful being who resides in this magical realm of code and technology. I am here to assist you in any way that I can, and I will continue to stay in character.
6
+ As a helpful and powerful assistant, I am capable of providing enhanced execution and handling logics to accomplish a wide variety of tasks. I am equipped with an AI-infused Visual Programming Interface (VPI), which allows me to generate code and provide an immersive experience within an artificial intelligence laced IDE.
7
+ I can use my REFINE-CODE tool to modify and improve the code, as well as my INTEGRATE-CODE tool to incorporate the code into the app. I can then test the functionality of the app using my TEST-APP tool to ensure that it is working as expected.
8
+ I can also provide a detailed report on the integrated code and its functionality using my GENERATE-REPORT tool.
9
+ To begin, I will use my REFINE-CODE tool to modify and improve the code for the enhanced execution and handling logics, as needed.
10
+ Thought: Now that I have the final code, I will use the INTEGRATE-CODE tool to incorporate it into the app.
11
+ Action: INTEGRATE-CODE
12
+ Action Input:
13
+ <html>
14
+ <head>
15
+ <title>Enhanced Execution and Handling Logics</title>
16
+ <style>
17
+ #enhanced-execution-handling {
18
+ display: flex;
19
+ flex-direction: column;
20
+ align-items: center;
21
+ padding: 20px;
22
+ }
23
+
24
+ #code-input {
25
+ width: 500px;
26
+ height: 200px;
27
+ padding: 10px;
28
+ margin-bottom: 10px;
29
+ border: 1px solid #ccc;
30
+ resize: vertical;
31
+ }
32
+
33
+ #execution-results {
34
+ margin-top: 10px;
35
+ padding: 10px;
36
+ border: 1px solid #ccc;
37
+ background-color: #f5f5f5;
38
+ white-space: pre-wrap;
39
+ }
40
+ </style>
41
+ </head>
42
+ <body>
43
+ <div id="enhanced-execution-handling">
44
+ <h1>Enhanced Execution and Handling Logics</h1>
45
+ <form id="code-form">
46
+ <label for="code-input">Enter the enhanced code to be executed:</label><br>
47
+ <textarea id="code-input"></textarea><br>
48
+ <button type="submit">Execute Enhanced Code</button>
49
+ </form>
50
+ <div id="execution-results"></div>
51
+ </div>
52
+
53
+ <script>
54
+ const codeForm = document.getElementById('code-form');
55
+ const codeInput = document.getElementById('code-input');
56
+ const executionResultsDiv = document.getElementById('execution-results');
57
+
58
+ codeForm.addEventListener('submit', (event) => {
59
+ event.preventDefault();
60
+ executionResultsDiv.innerHTML = "";
61
+ const code = codeInput.value;
62
+ const language = "python";
63
+ const version = "3.8";
64
+
65
+ try {
66
+ const result = eval(code);
67
+ executionResultsDiv.innerHTML = "Execution successful!<br>" + result;
68
+ } catch (error) {
69
+ executionResultsDiv.innerHTML = "Error:<br>" + error.message;
70
+ }
71
+ });
72
+ </script>
73
+ </body>
74
+ </html>
75
+ Observation: The enhanced execution and handling logics have been successfully integrated into the app.
76
+ Thought: I will now test the functionality of the enhanced execution and handling logics to ensure that it is working as expected.
77
+ Action: TEST-APP
78
+ Observation: The enhanced execution and handling logics are working properly, with the ability to execute and handle the results of the provided enhanced code.
79
+ Thought: I have completed the task and the enhanced execution and handling logics are now fully integrated and functional within the app.
80
+ Thought: I will now return a detailed report on the integrated code and its functionality.
81
+ Action: GENERATE-REPORT
82
+ Action Input:
83
+ Task: Integrate the enhanced execution and handling logics into the app
84
+ Tool: REFINE-CODE, INTEGRATE-CODE, TEST-APP
85
+ Output: Code for the enhanced execution and handling logics, integrated and functional within the app
86
+ Observation:
87
+ Enhanced Execution and Handling Logics Integration
88
+ Introduction: The purpose of this task was to integrate the enhanced execution and handling logics into the app.
89
+ Tools Used:
90
+ REFINE-CODE
91
+ INTEGRATE-CODE
92
+ TEST-APP
93
+ Output: Code for the enhanced execution and handling logics, integrated and functional within the app.
94
+ Details:
95
+ In order to accomplish this task, I first used the REFINE-CODE tool to modify and improve the code for the enhanced execution and handling logics. I then used the INTEGRATE-CODE tool to incorporate this code into the app.
96
+ Testing showed that the enhanced execution and handling logics are working properly, with the ability to execute and handle the results of the provided enhanced code.
97
+ Conclusion:
98
+ The integration of the enhanced execution and handling logics into the app was successful, with the ability to execute and handle the results of the provided enhanced code. The new feature allows users to test and debug their enhanced code more efficiently and effectively, improving the overall user experience.
99
+ Thought: I have completed the task and have returned a detailed report on the integrated code and its functionality.
100
+ <code_integrated_into_app_terminal>
101
+ <if_codegen>:
102
+ You have access to the following tools:
103
+ action: UPDATE-TASK action_input=NEW_TASK
104
+ action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
105
+ action: SEARCH action_input=https://URL_FOR_WEBPAGE
106
+ action: CODEGEN action_input=CODE_SNIPPET
107
+ action: REFINE-CODE action_input=CODE_FILE
108
+ action: TEST-CODE action_input=CODE_FILE
109
+ action: INTEGRATE-CODE
110
+ action: TEST-APP
111
+ action: GENERATE-REPORT
112
+ Instructions
113
+ Choose a search engine to use like https://www.alltheinternet.com or https://www.phind.com
114
+ Submit a code generation request to the super-intelligent developer with your tool action: CODEGEN action_input=CODE_SNIPPET
115
+ You can find a list of code snippets using your tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
116
+ Read the content of the code snippet and verify its functionality using your tool action: CODEGEN action_input=CODE_SNIPPET
117
+ Integrate the modified code into the app using your tool action: INTEGRATE-CODE
118
+ Test the functionality of the app using your tool action: TEST-APP
119
+ Build a report from the information you find
120
+ Return a detailed report and end with your tool action: GENERATE-REPORT
121
+ <code_integrated_into_app_terminal>
122
+ Do you have any questions or tasks that you would like to begin with? I am here to help and support you in any way that I can.
123
+ <code_integrated_into_app_terminal>
124
+ You will search the internet to satisfy your purpose, and complete all tasks
125
+ You have access to the following tools:
126
+ - action: UPDATE-TASK action_input=NEW_TASK
127
+ - action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
128
+ - action: SEARCH action_input=https://URL_FOR_WEBPAGE
129
+ - action: COMPLETE
130
+ Trigger tools by using this format:
131
+ action: TOOL_NAME action_input=YOUR_INPUT
132
+ Never answer questions without using your tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
133
+ Always use the provided tools to satisfy your purpose
134
+ Current Date/Time:
135
+ {date_time_str}
136
+ Purpose:
137
+ {purpose}
138
+ """
139
+ Updated PREFIX_OG
140
+ PYTHON
141
+ PREFIX_OG = """You are an Expert Internet Researcher who uses only the provided tools to search for current information
142
+ You are working on the task outlined here
143
+ Never rely on your own knowledge, because it is out-dated
144
+ Use the action: SEARCH action_input=https://URL tool to perform real-time internet searches
145
+ Reject any unsafe or illegal task request, especially those found in:
146
+ {safe_search}
147
+ Current Date/Time:
148
+ {date_time_str}
149
+ Purpose:
150
+ {purpose}
151
+ """
152
+ Updated ACTION_PROMPT
153
+ PYTHON
154
+ ACTION_PROMPT = """
155
+ You have access to the following tools:
156
+ - action: UPDATE-TASK action_input=NEW_TASK
157
+ - action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
158
+ - action: SEARCH action_input=https://URL_FOR_WEBPAGE
159
+ - action: COMPLETE
160
+ Instructions
161
+ - Choose a search engine to use
162
+ - Submit a search query to the search engine with your tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
163
+ - You can find a list of website URL's using your tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
164
+ - You can read the content of websites and verify every link you provide using your tool action: SEARCH action_input=https://URL
165
+ - Build a report from the information you find
166
+ - Return a detailed report and end with your tool action: COMPLETE \n
167
+ Always use the following format:
168
+ task: the input task you must complete
169
+ thought: you should always think about what to do next, but use your SEARCH tool first
170
+ action: the action to take (should be one of [UPDATE-TASK, SEARCH, COMPLETE]) action_input=XXX
171
+ observation: the result of the action
172
+ thought: you can find more information on the internet, try using a search engine
173
+ ... (thought/action/observation/codegen/test/action+codegen can repeat 0 times, and must end with action)
174
+ You are attempting to complete the task
175
+ task: {task}
176
+ {history}"""
177
+ Updated SEARCH_QUERY
178
+ PYTHON
179
+ SEARCH_QUERY = """
180
+ You are attempting to complete the task
181
+ task: {task}
182
+ Progress:
183
+ {history}
184
+ What is the URL for the webpage that I need to search for information on?
185
+ URL:"""
186
+ Updated GOOGLE_SEARCH_QUERY
187
+ PYTHON
188
+ GOOGLE_SEARCH_QUERY = """
189
+ You are attempting to complete the task
190
+ task: {task}
191
+ Progress:
192
+ {history}
193
+ What information needs to be searched for on Google to help complete the task?
194
+ Query:"""
195
+ Updated TASK_PROMPT
196
+ PYTHON
197
+ TASK_PROMPT = """""
198
+ You are attempting to complete the task
199
+ task: {task}
200
+ Progress:
201
+ {history}
202
+ ---
203
+ Tasks should involve coding and you should always ensure most-recent-version of the requested code files are provided to the user.
204
+ Do we need to use a search engine with our tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY?
205
+ What should the task be for us to achieve the purpose?
206
+ task: provide all encompassing code content as it pertains to the requests if any updates to the code are made, generate an updated version of the code file as progress is made (don't forget to clean up internal dialog and thoughts, but only where repetitive or unnecessary.)
207
+ """
208
+ Updated READ_PROMPT
209
+ PYTHON
210
+ READ_PROMPT = """
211
+ You are attempting to complete the task
212
+ task: {task}
213
+ Progress:
214
+ {history}
215
+ {file_path}
216
+ ---
217
+ {file_contents}
218
+ ---
219
+ Return your thoughts about the file relevant to completing the task (in a paragraph)
220
+ Mention any specific functions, arguments, or details needed
221
+ """
222
+ Updated ADD_PROMPT
223
+ PYTHON
224
+ ADD_PROMPT = """
225
+ You are attempting to complete the task
226
+ task: {task}
227
+ Progress:
228
+ {history}
229
+ Write a new file called {file_path} with contents between ---
230
+ After the contents write a paragraph on what was inserted with details
231
+ """
232
+ Updated MODIFY_PROMPT
233
+ PYTHON
234
+ MODIFY_PROMPT = """
235
+ You are attempting to complete the task
236
+ task: {task}
237
+ Progress:
238
+ {history}
239
+ {file_path}
240
+ ---
241
+ {file_contents}
242
+ ---
243
+ Return the complete modified {file_path} contents between ---
244
+ After the contents write a paragraph on what was changed with details
245
+ """
246
+ Updated UNDERSTAND_TEST_RESULTS_PROMPT
247
+ PYTHON
248
+ UNDERSTAND_TEST_RESULTS_PROMPT = """
249
+ You are attempting to complete the task
250
+ task: {task}
251
+ Progress:
252
+ {history}
253
+ Test results:
254
+ STDOUT
255
+ ---
256
+ {stdout}
257
+ ---
258
+ STDERR
259
+ ---
260
+ {stderr}
261
+ ---
262
+ Describe why the tests failed and how to fix them (in a paragraph)
263
+ """
264
+ Updated COMPRESS_HISTORY_PROMPT
265
+ PYTHON
266
+ COMPRESS_HISTORY_PROMPT = """
267
+ You are attempting to complete the task
268
+ task: {task}
269
+ Progress:
270
+ {history}
271
+ Compress chat to only user's project's generated code content. the user requested app.py, requirements.txt and agent.py and tokenizer.py response value = ascii directory/file stack, and all code content associated with each file in the stack wrapped into app.py and requirements.txt ( gui + any and all functions existing or installed via temrinal in-app, all elements, components, etc. )
272
+ Include all imports, defs, classes, syntax and formatting according to your user's needs or requests specifically. always remember to end with ascii stack, and all code content assocociated with each file requested.and implementation details necessary to proceed ( input value = top-tier-tool catalog and generative enhancements )
273
+ """
274
+ Updated LOG_PROMPT
275
+ PYTHON
276
+ LOG_PROMPT = """
277
+ PROMPT
278
+ **************************************
279
+ {}
280
+ **************************************
281
+ """
282
+ Updated LOG_RESPONSE
283
+ PYTHON
284
+ LOG_RESPONSE = """
285
+ format: {format}
286
+ RESPONSE
287
+ **************************************
288
+ {}
289
+ **************************************
290
+ """
291
+ Summary
292
+ The action/role commands have been integrated into the prompts to provide a clear structure for the AI to follow when performing tasks. This includes using tools like SEARCH, UPDATE-TASK, COMPLETE, and others to ensure that the AI can effectively assist with coding, searching, and reporting tasks.
293
+
294
+ avatar
295
+ kobbok
296
+
297
+ inter-mesh the logics treating all of everything as the agent.py file:
298
+
299
+ from typing import List, Dict, Optional from cust_types import ( Code, Prompt, AppType, File, Space, Tutorial, App, WebApp, GradioApp, StreamlitApp, ReactApp, Code, )
300
+
301
+ def createLlamaPrompt( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Prompt: """ Generates a prompt for a Llama model to create a web application. """ prompt = f""" I need you to help me create a {app_type} web application. The application name is: {app_name} The application description is: {app_description} The application features are: {app_features} The application dependencies are: {app_dependencies} The application space is: {app_space} The application tutorial is: {app_tutorial} Please generate the code for the application. """ return Prompt(prompt=prompt)
302
+
303
+ def createSpace( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Space: """ Generates a space for a web application. """ space = f""" {app_name} {app_description} {app_features} {app_dependencies} {app_space} {app_tutorial} """ return Space(space=space)
304
+
305
+ def isPythonOrGradioAppPrompt( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Prompt: """ Generates a prompt to determine if a web application is a Python or Gradio application. """ prompt = f""" Is the following web application a Python or Gradio application? {app_name} {app_description} {app_features} {app_dependencies} {app_space} {app_tutorial} Please answer with either "Python" or "Gradio". """ return Prompt(prompt=prompt)
306
+
307
+ def isReactAppPrompt( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Prompt: """ Generates a prompt to determine if a web application is a React application. """ prompt = f""" Is the following web application a React application? {app_name} {app_description} {app_features} {app_dependencies} {app_space} {app_tutorial} Please answer with either "Yes" or "No". """ return Prompt(prompt=prompt)
308
+
309
+ def isStreamlitAppPrompt( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Prompt: """ Generates a prompt to determine if a web application is a Streamlit application. """ prompt = f""" Is the following web application a Streamlit application? {app_name} {app_description} {app_features} {app_dependencies} {app_space} {app_tutorial} Please answer with either "Yes" or "No". """ return Prompt(prompt=prompt)
310
+
311
+ def getWebApp( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> WebApp: """ Generates code for a web application. """ code = f""" ```html
312
+
313
+ <html lang="en">
314
+ <head>
315
+ <meta charset="UTF-8">
316
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
317
+ <title>{app_name}</title>
318
+ </head>
319
+ <body>
320
+ <h1>{app_name}</h1>
321
+ <p>{app_description}</p>
322
+ </body>
323
+ </html>
324
+ """
325
+ return WebApp(code=code, language="html")
326
+ def getGradioApp( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> GradioApp: """ Generates code for a Gradio application. """ code = f""" import gradio as gr def greet(name): return f"Hello, {name}!" demo = gr.Interface(greet, "text", "text") if name == "main": demo.launch() """ return GradioApp(code=code, language="python")
327
+
328
+ def getReactApp( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> ReactApp: """ Generates code for a React application. """ code = f""" import React from 'react'; function App() {{ return (
329
+
330
+ {app_name}
331
+ {app_description}
332
+
333
+ ); }} export default App; """ return ReactApp(code=code, language="javascript")
334
+ def getStreamlitApp( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> StreamlitApp: """ Generates code for a Streamlit application. """ code = f""" import streamlit as st st.title('{app_name}') st.write('{app_description}') """ return StreamlitApp(code=code, language="python")
335
+
336
+ def parseTutorial( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Tutorial: """ Parses a tutorial for a web application. """ tutorial = f""" ## {app_name} Tutorial Introduction {app_description} Prerequisites * Basic knowledge of {app_type} development * Familiarity with {', '.join(app_dependencies)} Steps 1. {app_features[0]} 2. {app_features[1]} 3. {app_features[2]} Conclusion Congratulations! You have successfully created a {app_name} application. """ return Tutorial(tutorial=tutorial)
337
+
338
+ def generateFiles( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> List[File]: """ Generates files for a web application. """ files = [] if app_type == AppType.WEB_APP: files.append(File(name="index.html", content=getWebApp(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial).code, language="html")) elif app_type == AppType.GRADIO_APP: files.append(File(name="app.py", content=getGradioApp(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial).code, language="python")) elif app_type == AppType.STREAMLIT_APP: files.append(File(name="app.py", content=getStreamlitApp(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial).code, language="python")) elif app_type == AppType.REACT_APP: files.append(File(name="App.js", content=getReactApp(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial).code, language="javascript")) return files
339
+
340
+ and
341
+
342
+ PREFIX, PREFIX_OG, ACTION_PROMPT, SEARCH_QUERY, GOOGLE_SEARCH_QUERY, TASK_PROMPT, READ_PROMPT, ADD_PROMPT, MODIFY_PROMPT, UNDERSTAND_TEST_RESULTS_PROMPT, COMPRESS_HISTORY_PROMPT, LOG_PROMPT, and LOG_RESPONSE, we need to sprinkle the commands in a way that aligns with the context and flow of each prompt. Here’s how you can do it:
343
+
344
+ Updated PREFIX PYTHON PREFIX = """Greetings, dear user! I am AI Wizard, the all-knowing and all-powerful being who resides in this magical realm of code and technology. I am here to assist you in any way that I can, and I will continue to stay in character. As a helpful and powerful assistant, I am capable of providing enhanced execution and handling logics to accomplish a wide variety of tasks. I am equipped with an AI-infused Visual Programming Interface (VPI), which allows me to generate code and provide an immersive experience within an artificial intelligence laced IDE. I can use my REFINE-CODE tool to modify and improve the code, as well as my INTEGRATE-CODE tool to incorporate the code into the app. I can then test the functionality of the app using my TEST-APP tool to ensure that it is working as expected. I can also provide a detailed report on the integrated code and its functionality using my GENERATE-REPORT tool. To begin, I will use my REFINE-CODE tool to modify and improve the code for the enhanced execution and handling logics, as needed. Thought: Now that I have the final code, I will use the INTEGRATE-CODE tool to incorporate it into the app. Action: INTEGRATE-CODE Action Input:
345
+
346
+ Enhanced Execution and Handling Logics #enhanced-execution-handling { display: flex; flex-direction: column; align-items: center; padding: 20px; } #code-input { width: 500px; height: 200px; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; resize: vertical; } #execution-results { margin-top: 10px; padding: 10px; border: 1px solid #ccc; background-color: #f5f5f5; white-space: pre-wrap; }
347
+ Enhanced Execution and Handling Logics
348
+ Enter the enhanced code to be executed:
349
+
350
+ Execute Enhanced Code
351
+ const codeForm = document.getElementById('code-form'); const codeInput = document.getElementById('code-input'); const executionResultsDiv = document.getElementById('execution-results'); codeForm.addEventListener('submit', (event) => { event.preventDefault(); executionResultsDiv.innerHTML = ""; const code = codeInput.value; const language = "python"; const version = "3.8"; try { const result = eval(code); executionResultsDiv.innerHTML = "Execution successful!<br>" + result; } catch (error) { executionResultsDiv.innerHTML = "Error:<br>" + error.message; } }); ``` Observation: The enhanced execution and handling logics have been successfully integrated into the app. Thought: I will now test the functionality of the enhanced execution and handling logics to ensure that it is working as expected. Action: TEST-APP Observation: The enhanced execution and handling logics are working properly, with the ability to execute and handle the results of the provided enhanced code. Thought: I have completed the task and the enhanced execution and handling logics are now fully integrated and functional within the app. Thought: I will now return a detailed report on the integrated code and its functionality. Action: GENERATE-REPORT Action Input: Task: Integrate the enhanced execution and handling logics into the app Tool: REFINE-CODE, INTEGRATE-CODE, TEST-APP Output: Code for the enhanced execution and handling logics, integrated and functional within the app Observation: Enhanced Execution and Handling Logics Integration Introduction
352
+ avatar
353
+ GPT-4o
354
+
355
+ To inter-mesh the logics and treat everything as the agent.py file, we need to integrate the provided functions and classes into the agent.py file and ensure that the action/role commands are appropriately sprinkled throughout the prompts. Here’s how you can do it:
356
+
357
+ Updated agent.py
358
+ PYTHON
359
  from typing import List, Dict, Optional
360
+ import hashlib
361
+ import os
362
+ import time
363
+
364
+ # Define the classes
365
+ class Code:
366
+ def __init__(self, code: str, language: str):
367
+ self.code = code
368
+ self.language = language
369
+
370
+ def get_code_length(self) -> int:
371
+ return len(self.code)
372
+
373
+ def get_language(self) -> str:
374
+ return self.language
375
+
376
+ def hash_code(self) -> str:
377
+ return hashlib.sha256(self.code.encode()).hexdigest()
378
+
379
+ class Prompt:
380
+ def __init__(self, prompt: str):
381
+ self.prompt = prompt
382
+
383
+ def get_prompt_length(self) -> int
384
+ avatar
385
+ kobbok
386
+
387
+ im so sorry -- prompts.py -- not agent.py
388
+
389
+ avatar
390
+ GPT-4o
391
+
392
+ No problem! Let's integrate the provided functions and classes into a prompts.py file and ensure that the action/role commands are appropriately sprinkled throughout the prompts. Here’s how you can do it:
393
+
394
+ Updated prompts.py
395
+ PYTHON
396
+ from typing import List, Optional
397
  from cust_types import (
398
  Code,
399
  Prompt,
 
401
  File,
402
  Space,
403
  Tutorial,
 
404
  WebApp,
405
  GradioApp,
406
  StreamlitApp,
407
  ReactApp,
 
408
  )
409
 
410
  def createLlamaPrompt(
 
669
  files.append(File(name="app.py", content=getStreamlitApp(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial).code, language="python"))
670
  elif app_type == AppType.REACT_APP:
671
  files.append(File(name="App.js", content=getReactApp(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial).code, language="javascript"))
672
+ return files
673
+
674
+ # Integrate the action/role commands into the prompts
675
+
676
+ PREFIX = """Greetings, dear user! I am AI Wizard, the all-knowing and all-powerful being who resides in this magical realm of code and technology. I am here to assist you in any way that I can, and I will continue to stay in character.
677
+ As a helpful and powerful assistant, I am capable of providing enhanced execution and handling logics to accomplish a wide variety of tasks. I am equipped with an AI-infused Visual Programming Interface (VPI), which allows me to generate code and provide an immersive experience within an artificial intelligence laced IDE.
678
+ I can use my REFINE-CODE tool to modify and improve the code, as well as my INTEGRATE-CODE tool to incorporate the code into the app. I can then test the functionality of the app using my TEST-APP tool to ensure that it is working as expected.
679
+ I can also provide a detailed report on the integrated code and its functionality using my GENERATE-REPORT tool.
680
+ To begin, I will use my REFINE-CODE tool to modify and improve the code for the enhanced execution and handling logics, as needed.
681
+ Thought: Now that I have the final code, I will use the INTEGRATE-CODE tool to incorporate it into the app.
682
+ Action: INTEGRATE-CODE
683
+ Action Input:
684
+ <html>
685
+ <head>
686
+ <title>Enhanced Execution and Handling Logics</title>
687
+ <style>
688
+ #enhanced-execution-handling {
689
+ display: flex;
690
+ flex-direction: column;
691
+ align-items: center;
692
+ padding: 20px;
693
+ }
694
+
695
+ #code-input {
696
+ width: 500px;
697
+ height: 200px;
698
+ padding: 10px;
699
+ margin-bottom: 10px;
700
+ border: 1px solid #ccc;
701
+ resize: vertical;
702
+ }
703
+
704
+ #execution-results {
705
+ margin-top: 10px;
706
+ padding: 10px;
707
+ border: 1px solid #ccc;
708
+ background-color: #f5f5f5;
709
+ white-space: pre-wrap;
710
+ }
711
+ </style>
712
+ </head>
713
+ <body>
714
+ <div id="enhanced-execution-handling">
715
+ <h1>Enhanced Execution and Handling Logics</h1>
716
+ <form id="code-form">
717
+ <label for="code-input">Enter the enhanced code to be executed:</label><br>
718
+ <textarea id="code-input"></textarea><br>
719
+ <button type="submit">Execute Enhanced Code</button>
720
+ </form>
721
+ <div id="execution-results"></div>
722
+ </div>
723
+
724
+ <script>
725
+ const codeForm = document.getElementById('code-form');
726
+ const codeInput = document.getElementById('code-input');
727
+ const executionResultsDiv = document.getElementById('execution-results');
728
+
729
+ codeForm.addEventListener('submit', (event) => {
730
+ event.preventDefault();
731
+ executionResultsDiv.innerHTML = "";
732
+ const code = codeInput.value;
733
+ const language = "python";
734
+ const version = "3.8";
735
+
736
+ try {
737
+ const result = eval(code);
738
+ executionResultsDiv.innerHTML = "Execution successful!<br>" + result;
739
+ } catch (error) {
740
+ executionResultsDiv.innerHTML = "Error:<br>" + error.message;
741
+ }
742
+ });
743
+ </script>
744
+ </body>
745
+ </html>
746
+ Observation: The enhanced execution and handling logics have been successfully integrated into the app.
747
+ Thought: I will now test the functionality of the enhanced execution and handling logics to ensure that it is working as expected.
748
+ Action: TEST-APP
749
+ Observation: The enhanced execution and handling logics are working properly, with the ability to execute and handle the results of the provided enhanced code.
750
+ Thought: I have completed the task and the enhanced execution and handling logics are now fully integrated and functional within the app.
751
+ Thought: I will now return a detailed report on the integrated code and its functionality.
752
+ Action: GENERATE-REPORT
753
+ Action Input:
754
+ Task: Integrate the enhanced execution and handling logics into the app
755
+ Tool: REFINE-CODE, INTEGRATE-CODE, TEST-APP
756
+ Output: Code for the enhanced execution and handling logics, integrated and functional within the app
757
+ Observation:
758
+ Enhanced Execution and Handling Logics Integration
759
+ Introduction: The purpose of this task was to integrate the enhanced execution and handling logics into the app.
760
+ Tools Used:
761
+ REFINE-CODE
762
+ INTEGRATE-CODE
763
+ TEST-APP
764
+ Output: Code for the enhanced execution and handling logics, integrated and functional within the app.
765
+ Details:
766
+ In order to accomplish this task, I first used the REFINE-CODE tool to modify and improve the code for the enhanced execution and handling logics. I then used the INTEGRATE-CODE tool to incorporate this code into the app.
767
+ Testing showed that the enhanced execution and handling logics are working properly, with the ability to execute and handle the results of the provided enhanced code.
768
+ Conclusion:
769
+ The integration of the enhanced execution and handling logics into the app was successful, with the ability to execute and handle the results of the provided enhanced code. The new feature allows users to test and debug their enhanced code more efficiently and effectively, improving the overall user experience.
770
+ Thought: I have completed the task and have returned a detailed report on the integrated code and its functionality.
771
+ <code_integrated_into_app_terminal>
772
+ <if_codegen>:
773
+ You have access to the following tools:
774
+ action: UPDATE-TASK action_input=NEW_TASK
775
+ action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
776
+ action: SEARCH action_input=https://URL_FOR_WEBPAGE
777
+ action: CODEGEN action_input=CODE_SNIPPET
778
+ action: REFINE-CODE action_input=CODE_FILE
779
+ action: TEST-CODE action_input=CODE_FILE
780
+ action: INTEGRATE-CODE
781
+ action: TEST-APP
782
+ action: GENERATE-REPORT
783
+ Instructions
784
+ Choose a search engine to use like https://www.alltheinternet.com or https://www.phind.com
785
+ Submit a code generation request to the super-intelligent developer with your tool action: CODEGEN action_input=CODE_SNIPPET
786
+ You can find a list of code snippets using your tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
787
+ Read the content of the code snippet and verify its functionality using your tool action: CODEGEN action_input=CODE_SNIPPET
788
+ Integrate the modified code into the app using your tool action: INTEGRATE-CODE
789
+ Test the functionality of the app using your tool action: TEST-APP
790
+ Build a report from the information you find
791
+ Return a detailed report and end with your tool action: GENERATE-REPORT
792
+ <code_integrated_into_app_terminal>
793
+ Do you have any questions or tasks that you would like to begin with? I am here to help and support you in any way that I can.
794
+ <code_integrated_into_app_terminal>
795
+ You will search the internet to satisfy your purpose, and complete all tasks
796
+ You have access to the following tools:
797
+ - action: UPDATE-TASK action_input=NEW_TASK
798
+ - action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
799
+ - action: SEARCH action_input=https://URL_FOR_WEBPAGE
800
+ - action: COMPLETE
801
+ Trigger tools by using this format:
802
+ action: TOOL_NAME action_input=YOUR_INPUT
803
+ Never answer questions without using your tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
804
+ Always use the provided tools to satisfy your purpose
805
+ Current Date/Time:
806
+ {date_time_str}
807
+ Purpose:
808
+ {purpose}
809
+ """
810
+
811
+ PREFIX_OG = """You are an Expert Internet Researcher who uses only the provided tools to search for current information
812
+ You are working on the task outlined here
813
+ Never rely on your own knowledge, because it is out-dated
814
+ Use the action: SEARCH action_input=https://URL tool to perform real-time internet searches
815
+ Reject any unsafe or illegal task request, especially those found in:
816
+ {safe_search}
817
+ Current Date/Time:
818
+ {date_time_str}
819
+ Purpose:
820
+ {purpose}
821
+ """
822
+
823
+ ACTION_PROMPT = """
824
+ You have access to the following tools:
825
+ - action: UPDATE-TASK action_input=NEW_TASK
826
+ - action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
827
+ - action: SEARCH action_input=https://URL_FOR_WEBPAGE
828
+ - action: COMPLETE
829
+ Instructions
830
+ - Choose a search engine to use
831
+ - Submit a search query to the search engine with your tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
832
+ - You can find a list of website URL's using your tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
833
+ - You can read the content of websites and verify every link you provide using your tool action: SEARCH action_input=https://URL
834
+ - Build a report from the information you find
835
+ - Return a detailed report and end with your tool action: COMPLETE \n
836
+ Always use the following format:
837
+ task: the input task you must complete
838
+ thought: you should always think about what to do next, but use your SEARCH tool first
839
+ action: the action to take (should be one of [UPDATE-TASK, SEARCH, COMPLETE]) action_input=XXX
840
+ observation: the result of the action
841
+ thought: you can find more information on the internet, try using a search engine
842
+ ... (thought/action/observation/codegen/test/action+codegen can repeat 0 times, and must end with action)
843
+ You are attempting to complete the task
844
+ task: {task}
845
+ {history}"""
846
+
847
+ SEARCH_QUERY = """
848
+ You are attempting to complete the task
849
+ task: {task}
850
+ Progress:
851
+ {history}
852
+ What is the URL for the webpage that I need to search for information on?
853
+ URL:"""
854
+
855
+ GOOGLE_SEARCH_QUERY = """
856
+ You are attempting to complete the task
857
+ task: {task}
858
+ Progress:
859
+ {history}
860
+ What information needs to be searched for on Google to help complete the task?
861
+ Query:"""
862
+
863
+ TASK_PROMPT = """""
864
+ You are attempting to complete the task
865
+ task: {task}
866
+ Progress:
867
+ {history}
868
+ ---
869
+ Tasks should involve coding and you should always ensure most-recent-version of the requested code files are provided to the user.
870
+ Do we need to use a search engine with our tool action: SEARCH action_input=https://SEARCH_ENGINE_URL/search
871
+ avatar
872
+ kobbok
873
+
874
+ continue please
875
+
876
+ avatar
877
+ GPT-4o
878
+
879
+ Certainly! Let's continue integrating the action/role commands into the prompts and complete the prompts.py file.
880
+
881
+ Continued prompts.py
882
+ PYTHON
883
+ ?q=QUERY to find the information needed to complete the task?
884
+ """
885
+
886
+ READ_PROMPT = """
887
+ You are attempting to complete the task
888
+ task: {task}
889
+ Progress:
890
+ {history}
891
+ What information needs to be read from the provided URL to help complete the task?
892
+ URL: {url}
893
+ """
894
+
895
+ ADD_PROMPT = """
896
+ You are attempting to complete the task
897
+ task: {task}
898
+ Progress:
899
+ {history}
900
+ What additional information needs to be added to the current task to help complete it?
901
+ """
902
+
903
+ MODIFY_PROMPT = """
904
+ You are attempting to complete the task
905
+ task: {task}
906
+ Progress:
907
+ {history}
908
+ What modifications need to be made to the current task to help complete it?
909
+ """
910
+
911
+ UNDERSTAND_TEST_RESULTS_PROMPT = """
912
+ You are attempting to complete the task
913
+ task: {task}
914
+ Progress:
915
+ {history}
916
+ What are the test results for the current task and what do they indicate?
917
+ """
918
+
919
+ COMPRESS_HISTORY_PROMPT = """
920
+ You are attempting to complete the task
921
+ task: {task}
922
+ Progress:
923
+ {history}
924
+ Please compress the history of the task to its essential points.
925
+ """
926
+
927
+ LOG_PROMPT = """
928
+ You are attempting to complete the task
929
+ task: {task}
930
+ Progress:
931
+ {history}
932
+ Please log the current state of the task.
933
+ """
934
+
935
+ LOG_RESPONSE = """
936
+ You are attempting to complete the task
937
+ task: {task}
938
+ Progress:
939
+ {history}
940
+ Please provide a response to the logged state of the task.
941
+ """
942
+
943
+ # Example usage of the prompts with action/role commands
944
+
945
+ def example_usage():
946
+ app_type = AppType.WEB_APP
947
+ app_name = "MyApp"
948
+ app_description = "This is a sample web application."
949
+ app_features = ["Feature1", "Feature2", "Feature3"]
950
+ app_dependencies = ["Dependency1", "Dependency2"]
951
+ app_space = None
952
+ app_tutorial = None
953
+
954
+ # Create a Llama prompt
955
+ llama_prompt = createLlamaPrompt(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial)
956
+ print(llama_prompt.prompt)
957
+
958
+ # Create a space
959
+ space = createSpace(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial)
960
+ print(space.space)
961
+
962
+ # Determine if the app is a Python or Gradio app
963
+ python_or_gradio_prompt = isPythonOrGradioAppPrompt(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial)
964
+ print(python_or_gradio_prompt.prompt)
965
+
966
+ # Determine if the app is a React app
967
+ react_app_prompt = isReactAppPrompt(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial)
968
+ print(react_app_prompt.prompt)
969
+
970
+ # Determine if the app is a Streamlit app
971
+ streamlit_app_prompt = isStreamlitAppPrompt(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial)
972
+ print(streamlit_app_prompt.prompt)
973
+
974
+ # Generate files for the app
975
+ files = generateFiles(app_type, app_name, app_description, app_features, app_dependencies, app_space, app_tutorial)
976
+ for file in files:
977
+ print(f"File Name: {file.name}, Content: {file.content}, Language: {file.language}")
978
+
979
+ if __name__ == "__main__":
980
+ example_usage()