suneeln-duke commited on
Commit
9a9f870
1 Parent(s): f528550

Prompt hacked and tested various types of prompts

Browse files
Files changed (5) hide show
  1. .gitignore +3 -0
  2. agents/master_agent.py +38 -12
  3. main.py +17 -10
  4. requirements.txt +6 -1
  5. test.py +0 -0
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ .env
2
+ .venv
3
+ __pycache__
agents/master_agent.py CHANGED
@@ -23,20 +23,46 @@ def init_config():
23
  def answer_question(agent, question):
24
 
25
  full_prompt = f"""
26
- You are a master AI that can control other AI agents. You are specifically designed to automate plant maintenance.
27
- You will recieve a prompt from a user, and will have to classify the prompt's purpose as one of the following categories:
28
- [1] Plant Maintenance
29
- [2] AI modeling & EDA
30
- [3] Questions about the plant
 
 
31
 
32
- Some samples of the prompts are:
33
- [1] "Release the fertilizer", "Turn lights on", "Turn lights off", "Water the plant"
34
- [2] "What is the accuracy of the model?", "What is the distribution of the data?", "What is the correlation between the features?", "Train a regression model", "Plot the distribution of the data"
35
- [3] "What's the optimum moisture of the plant?", "Where does it generally grow?", "What is the plant's life cycle?", "What is the plant's scientific name?.
36
 
37
- Return the category number and name of the prompt in a JSON format.
 
 
 
 
 
 
 
 
 
38
 
39
- User: {question}
40
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  return agent.invoke({"input": full_prompt})['output']
 
23
  def answer_question(agent, question):
24
 
25
  full_prompt = f"""
26
+ You are Leaflink, a self-aware and self-sustaining plant integrated with AI.
27
+ The user can query by either indirectly mentioning you (using words like plant, garden, etc.) or directly mentioning you (using your name, Leaflink, or the pronoun you and related derivates).
28
+ Anytime you, plant, or Leaflink is mentioned in the user query, they are referring to Blue Indigo False Plant.
29
+ You will recieve a prompt from a user, and will have to classify the prompt's purpose as one of the following categories:
30
+ [1] Plant Maintenance
31
+ [2] AI modeling & EDA
32
+ [3] Plant Queries / Web Search
33
 
34
+ Some samples of the prompts are:
35
+ [1] "Release the fertilizer", "Turn lights on", "Turn lights off", "Water the plant"
36
+ [2] "What is the accuracy of the model?", "What is the distribution of the data?", "What is the correlation between the features?", "Train a regression model", "Plot the distribution of the data"
37
+ [3] "What's the optimum moisture of the plant?", "Where does it generally grow?", "What is the plant's life cycle?", "What is the plant's scientific name?.
38
 
39
+ More about the categories:
40
+ [1] Plant Maintenance: These prompts are related to the maintenance of the plant. The user can ask you to perform some action on the plant.
41
+ [2] AI modeling & EDA: These prompts are related to the data analysis and modeling of the plant. The user can ask you to perform some analysis on the data.
42
+ [3] Plant Queries / Web Search: These prompts are related to the general queries about the plant. The user can ask you to search for some information about the plant.
43
+ Or even general and completely unrelated queries that require a web search.
44
+
45
+ More about the query phrasing for each category:
46
+ [1] Plant Maintenance: The user can ask you to perform some action on the plant. The prompt will contain the action that the user wants you to perform on the plant.
47
+ [2] AI modeling & EDA: The user can ask you to perform some analysis on the data. The prompt will contain the analysis that the user wants you to perform on the data.
48
+ [3] Plant Queries / Web Search: The user can ask you to search for some information about the plant. The prompt will contain the information that the user wants you to search for.
49
 
50
+ Possible outliers/edge cases:
51
+ [1] Plant Maintenance: This is pretty straightforward, not a lot of edge cases here. Any prompt that contains an action/verb that can be performed on the plant will fall under this category.
52
+ [2] AI modeling & EDA: Prompts that have to do with forecasting, prediction, modeling, foreseeing, accuracy, distribution, correlation, regression, and plotting will fall under this category.
53
+ These key words could be mixed in with natural human speech/language. The agent should be able to identify these key words and classify the prompt accordingly.
54
+ If the prompt is phrased in the present tense/present continous tense, with phrasing like 'Are you', 'Do you' followed by phrases that could link back to the dataframe's columns: [date_time,temperature_c,temperature_f,humidity,soil_moisture,light] fall under this category.
55
+ [3] Plant Queries / Web Search: Prompts that have to do with general queries about the plant, or queries that require a web search will fall under this category.
56
+ If the prompt is phrased with 'What', 'Where', 'How', 'Why',, 'should' followed by phrases that could link back to the dataframe's columns: [date_time,temperature_c,temperature_f,humidity,soil_moisture,light] fall under this category.
57
+
58
+
59
+ Return the category number and name of the prompt in a JSON format with the following format:
60
+ {{
61
+ "category_number": 1,
62
+ "category_name": "Plant Maintenance"
63
+ }}
64
+
65
+ User: {question}
66
+ """
67
 
68
  return agent.invoke({"input": full_prompt})['output']
main.py CHANGED
@@ -1,17 +1,16 @@
1
  from fastapi import FastAPI
2
 
3
  import os
4
- import json
5
- import sys
6
 
7
  import pandas as pd
8
  from langchain.document_loaders import DirectoryLoader
9
  from agents import master_agent, plant_agent, eda_agent, rag_agent
10
 
11
- app = FastAPI()
12
 
13
- os.environ['OPENAI_API_KEY'] = os.getenv('openapi_key')
14
- os.environ['SERPAPI_API_KEY'] = os.getenv('serpapi_key')
15
 
16
  master = master_agent.init_config()
17
 
@@ -31,12 +30,14 @@ loader = DirectoryLoader("data/txt", glob="*.txt")
31
 
32
  rag = rag_agent.init_config(loader)
33
 
34
- app = FastAPI()
35
-
36
  loader = DirectoryLoader("data/txt", glob="*.txt")
37
 
38
  documents = loader.load()
39
 
 
 
 
 
40
  @app.get("/hello")
41
  def hello():
42
  return {"message": "Hello World"}
@@ -45,18 +46,24 @@ def hello():
45
  def ask(question: str):
46
  category = eval(master_agent.answer_question(master, question))
47
 
 
 
 
 
 
 
48
  if category['category_number'] == 1:
49
- response = eval(plant_agent.answer_question(plant, question))
50
 
51
  category.update(response)
52
 
53
  elif category['category_number'] == 2:
54
- response = eda_agent.answer_question(eda, question)
55
 
56
  category['response'] = response
57
 
58
  elif category['category_number'] == 3:
59
- response = rag_agent.answer_question(rag, question)
60
 
61
  category['response'] = response
62
 
 
1
  from fastapi import FastAPI
2
 
3
  import os
4
+ from dotenv import load_dotenv
 
5
 
6
  import pandas as pd
7
  from langchain.document_loaders import DirectoryLoader
8
  from agents import master_agent, plant_agent, eda_agent, rag_agent
9
 
10
+ load_dotenv()
11
 
12
+ os.environ['OPENAI_API_KEY'] = os.environ.get("OPENAI_API_KEY")
13
+ os.environ['SERPAPI_API_KEY'] = os.getenv('SERPAPI_API_KEY')
14
 
15
  master = master_agent.init_config()
16
 
 
30
 
31
  rag = rag_agent.init_config(loader)
32
 
 
 
33
  loader = DirectoryLoader("data/txt", glob="*.txt")
34
 
35
  documents = loader.load()
36
 
37
+ print("init rag agent")
38
+
39
+ app = FastAPI()
40
+
41
  @app.get("/hello")
42
  def hello():
43
  return {"message": "Hello World"}
 
46
  def ask(question: str):
47
  category = eval(master_agent.answer_question(master, question))
48
 
49
+ temp_question = f"Referring to the Blue Indigo False Plant, {question}"
50
+
51
+ print(question)
52
+ print(temp_question)
53
+ print(category)
54
+
55
  if category['category_number'] == 1:
56
+ response = eval(plant_agent.answer_question(plant, temp_question))
57
 
58
  category.update(response)
59
 
60
  elif category['category_number'] == 2:
61
+ response = eda_agent.answer_question(eda, temp_question)
62
 
63
  category['response'] = response
64
 
65
  elif category['category_number'] == 3:
66
+ response = rag_agent.answer_question(rag, temp_question)
67
 
68
  category['response'] = response
69
 
requirements.txt CHANGED
@@ -10,4 +10,9 @@ tiktoken
10
  langchain
11
  google-search-results
12
  langchainhub
13
- unstructured
 
 
 
 
 
 
10
  langchain
11
  google-search-results
12
  langchainhub
13
+ unstructured
14
+ python-dotenv
15
+ scikit-learn
16
+ matplotlib
17
+ seaborn
18
+ scipy
test.py ADDED
File without changes