acecalisto3 commited on
Commit
daf537b
·
verified ·
1 Parent(s): 0bde0fb

Update prompts.py

Browse files
Files changed (1) hide show
  1. prompts.py +46 -12
prompts.py CHANGED
@@ -1,9 +1,19 @@
 
 
 
 
 
 
 
 
 
 
1
 
2
  # Define the search engine URL
3
- SEARCH_ENGINE_URL = "https://www.google.com/search?q="
4
 
5
  # Define the search engine URL for web pages
6
- URL_FOR_WEBPAGE = "https://www.google.com/search?q="
7
 
8
  # Define the safe search list
9
  SAFE_SEARCH = ["https://www.google.com/search?q=illegal+activities", "https://www.google.com/search?q=unsafe+content"]
@@ -32,10 +42,13 @@ Context: {context}""",
32
  )
33
 
34
  # Define the LLM
35
- llm = OpenAI(temperature=0.7)
 
 
 
36
 
37
  # Define the embeddings
38
- embeddings = OpenAIEmbeddings()
39
 
40
  # Define the memory
41
  memory = ConversationBufferMemory(memory_key="chat_history")
@@ -118,19 +131,34 @@ def test_code(code_file: str) -> str:
118
  return f"An error occurred while testing code: {e}"
119
 
120
  # Define the function to handle the integrate code action
121
- def integrate_code() -> str:
122
  """Integrates the code into the app."""
123
- return "Code integrated successfully."
 
 
 
 
 
124
 
125
  # Define the function to handle the test app action
126
- def test_app() -> str:
127
  """Tests the functionality of the app."""
128
- return "App tested successfully."
 
 
 
 
 
129
 
130
  # Define the function to handle the generate report action
131
- def generate_report() -> str:
132
  """Generates a report on the integrated code and its functionality."""
133
- return "Report generated successfully."
 
 
 
 
 
134
 
135
  # Define the Gradio interface
136
  iface = gr.Interface(
@@ -139,9 +167,13 @@ iface = gr.Interface(
139
  outputs=gr.Textbox(label="Action Output"),
140
  title="AI Wizard: Your All-Knowing Code Assistant",
141
  description="""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.
 
142
  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.
 
143
  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.
 
144
  I can also provide a detailed report on the integrated code and its functionality using my GENERATE-REPORT tool.
 
145
  To begin, I will use my REFINE-CODE tool to modify and improve the code for the enhanced execution and handling logics, as needed.
146
  Thought: Now that I have the final code, I will use the INTEGRATE-CODE tool to incorporate it into the app.
147
  Action: INTEGRATE-CODE
@@ -277,5 +309,7 @@ Purpose:
277
  ["action: TEST-APP", "App tested successfully."],
278
  ["action: GENERATE-REPORT", "Report generated successfully."],
279
  ],
280
- """
281
- )
 
 
 
1
+ import time
2
+ import gradio as gr
3
+ from langchain.prompts import PromptTemplate
4
+ from langchain.chains import RetrievalQA
5
+ from langchain.embeddings import HuggingFaceEmbeddings
6
+ from langchain.vectorstores import FAISS
7
+ from langchain.memory import ConversationBufferMemory
8
+ from langchain.llms import HuggingFaceHub
9
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
10
+ import torch
11
 
12
  # Define the search engine URL
13
+ SEARCH_ENGINE_URL = "https://www.alltheinternet.com/?q="
14
 
15
  # Define the search engine URL for web pages
16
+ URL_FOR_WEBPAGE = "https://www.alltheinternet.com/?q="
17
 
18
  # Define the safe search list
19
  SAFE_SEARCH = ["https://www.google.com/search?q=illegal+activities", "https://www.google.com/search?q=unsafe+content"]
 
42
  )
43
 
44
  # Define the LLM
45
+ model_name = "google/flan-t5-xl" # Replace with your preferred model
46
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
47
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
48
+ llm = HuggingFaceHub(repo_id=model_name, model_kwargs={"device": "cuda" if torch.cuda.is_available() else "cpu"})
49
 
50
  # Define the embeddings
51
+ embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
52
 
53
  # Define the memory
54
  memory = ConversationBufferMemory(memory_key="chat_history")
 
131
  return f"An error occurred while testing code: {e}"
132
 
133
  # Define the function to handle the integrate code action
134
+ def integrate_code(code_snippet: str) -> str:
135
  """Integrates the code into the app."""
136
+ try:
137
+ # Execute the code snippet
138
+ exec(code_snippet)
139
+ return "Code integrated successfully."
140
+ except Exception as e:
141
+ return f"An error occurred while integrating code: {e}"
142
 
143
  # Define the function to handle the test app action
144
+ def test_app(code_snippet: str) -> str:
145
  """Tests the functionality of the app."""
146
+ try:
147
+ # Execute the code snippet
148
+ exec(code_snippet)
149
+ return "App tested successfully."
150
+ except Exception as e:
151
+ return f"An error occurred while testing the app: {e}"
152
 
153
  # Define the function to handle the generate report action
154
+ def generate_report(code_snippet: str) -> str:
155
  """Generates a report on the integrated code and its functionality."""
156
+ try:
157
+ # Execute the code snippet
158
+ exec(code_snippet)
159
+ return "Report generated successfully."
160
+ except Exception as e:
161
+ return f"An error occurred while generating a report: {e}"
162
 
163
  # Define the Gradio interface
164
  iface = gr.Interface(
 
167
  outputs=gr.Textbox(label="Action Output"),
168
  title="AI Wizard: Your All-Knowing Code Assistant",
169
  description="""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.
170
+
171
  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.
172
+
173
  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.
174
+
175
  I can also provide a detailed report on the integrated code and its functionality using my GENERATE-REPORT tool.
176
+
177
  To begin, I will use my REFINE-CODE tool to modify and improve the code for the enhanced execution and handling logics, as needed.
178
  Thought: Now that I have the final code, I will use the INTEGRATE-CODE tool to incorporate it into the app.
179
  Action: INTEGRATE-CODE
 
309
  ["action: TEST-APP", "App tested successfully."],
310
  ["action: GENERATE-REPORT", "Report generated successfully."],
311
  ],
312
+ )
313
+
314
+ if __name__ == "__main__":
315
+ iface.launch(share=True)