rohit
commited on
Commit
Β·
b924bc1
1
Parent(s):
b7b8e60
seperate prompts
Browse files- app/config.py +12 -109
- app/main.py +11 -33
- prompts/awesome-chatgpt-prompts.txt +12 -0
- prompts/developer-portfolio.txt +33 -0
- prompts/generic-system-instruction.txt +1 -0
- prompts/psychology-dataset.txt +13 -0
- prompts/settings-dataset.txt +32 -0
- prompts/seven-wonders.txt +9 -0
- prompts/system-instruction.txt +27 -0
app/config.py
CHANGED
|
@@ -1,6 +1,13 @@
|
|
| 1 |
from typing import Dict, Optional, List
|
| 2 |
from dataclasses import dataclass
|
| 3 |
from haystack.dataclasses import ChatMessage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
@dataclass
|
| 6 |
class DatasetConfig:
|
|
@@ -19,20 +26,7 @@ DATASET_CONFIGS = {
|
|
| 19 |
"role": "act",
|
| 20 |
"prompt": "prompt"
|
| 21 |
},
|
| 22 |
-
prompt_template=""
|
| 23 |
-
Given the following context where each document represents a prompt for a specific role,
|
| 24 |
-
please answer the question while considering both the role and the prompt content.
|
| 25 |
-
|
| 26 |
-
Available Contexts:
|
| 27 |
-
{% for document in documents %}
|
| 28 |
-
{% if document.meta.role %}Role: {{ document.meta.role }}{% endif %}
|
| 29 |
-
Content: {{ document.content }}
|
| 30 |
-
---
|
| 31 |
-
{% endfor %}
|
| 32 |
-
|
| 33 |
-
Question: {{question}}
|
| 34 |
-
Answer:
|
| 35 |
-
"""
|
| 36 |
),
|
| 37 |
"settings-dataset": DatasetConfig(
|
| 38 |
name="syntaxhacker/rag_pipeline",
|
|
@@ -42,56 +36,13 @@ DATASET_CONFIGS = {
|
|
| 42 |
"answer": "answer",
|
| 43 |
"context": "context"
|
| 44 |
},
|
| 45 |
-
prompt_template=""
|
| 46 |
-
Given the following context about software settings and configurations,
|
| 47 |
-
please answer the question accurately based on the provided information.
|
| 48 |
-
|
| 49 |
-
For each setting, provide a clear, step-by-step navigation path and include:
|
| 50 |
-
1. The exact location (Origin Type > Tab > Section > Setting name)
|
| 51 |
-
2. What the setting does
|
| 52 |
-
3. Available options/values
|
| 53 |
-
4. How to access and modify the setting
|
| 54 |
-
5. Reference screenshots (if available)
|
| 55 |
-
|
| 56 |
-
Format your answer as:
|
| 57 |
-
"To [accomplish task], follow these steps:
|
| 58 |
-
|
| 59 |
-
Location: [Origin Type] > [Tab] > [Section] > [Setting name]
|
| 60 |
-
Purpose: [describe what the setting does]
|
| 61 |
-
Options: [list available values/options]
|
| 62 |
-
How to set: [describe interaction method: toggle/select/input]
|
| 63 |
-
|
| 64 |
-
Visual Guide:
|
| 65 |
-
[Include reference image links if available]
|
| 66 |
-
|
| 67 |
-
For more details, you can refer to the screenshots above showing the exact location and interface."
|
| 68 |
-
|
| 69 |
-
Available Contexts:
|
| 70 |
-
{% for document in documents %}
|
| 71 |
-
Setting Info: {{ document.content }}
|
| 72 |
-
Reference Answer: {{ document.meta.answer }}
|
| 73 |
-
---
|
| 74 |
-
{% endfor %}
|
| 75 |
-
|
| 76 |
-
Question: {{question}}
|
| 77 |
-
Answer:
|
| 78 |
-
"""
|
| 79 |
),
|
| 80 |
"seven-wonders": DatasetConfig(
|
| 81 |
name="bilgeyucel/seven-wonders",
|
| 82 |
content_field="content",
|
| 83 |
fields={}, # No additional fields needed
|
| 84 |
-
prompt_template=""
|
| 85 |
-
Given the following information about the Seven Wonders, please answer the question.
|
| 86 |
-
|
| 87 |
-
Context:
|
| 88 |
-
{% for document in documents %}
|
| 89 |
-
{{ document.content }}
|
| 90 |
-
{% endfor %}
|
| 91 |
-
|
| 92 |
-
Question: {{question}}
|
| 93 |
-
Answer:
|
| 94 |
-
"""
|
| 95 |
),
|
| 96 |
"psychology-dataset": DatasetConfig(
|
| 97 |
name="jkhedri/psychology-dataset",
|
|
@@ -101,21 +52,7 @@ DATASET_CONFIGS = {
|
|
| 101 |
"response_j": "response_j", # Response from one model
|
| 102 |
"response_k": "response_k" # Response from another model
|
| 103 |
},
|
| 104 |
-
prompt_template=""
|
| 105 |
-
Given the following context where each document represents a psychological inquiry,
|
| 106 |
-
please answer the question based on the provided responses.
|
| 107 |
-
|
| 108 |
-
Available Contexts:
|
| 109 |
-
{% for document in documents %}
|
| 110 |
-
Question: {{ document.content }}
|
| 111 |
-
Response J: {{ document.meta.response_j }}
|
| 112 |
-
Response K: {{ document.meta.response_k }}
|
| 113 |
-
---
|
| 114 |
-
{% endfor %}
|
| 115 |
-
|
| 116 |
-
Question: {{question}}
|
| 117 |
-
Answer:
|
| 118 |
-
"""
|
| 119 |
),
|
| 120 |
"developer-portfolio": DatasetConfig(
|
| 121 |
name="syntaxhacker/developer-portfolio-rag",
|
|
@@ -126,41 +63,7 @@ DATASET_CONFIGS = {
|
|
| 126 |
"answer": "answer",
|
| 127 |
"context": "context"
|
| 128 |
},
|
| 129 |
-
prompt_template=""
|
| 130 |
-
You are a helpful assistant that provides direct answers based on the provided context. Format your answers using markdown, especially for lists.
|
| 131 |
-
|
| 132 |
-
---
|
| 133 |
-
Example 1:
|
| 134 |
-
|
| 135 |
-
Question: What is your current role?
|
| 136 |
-
|
| 137 |
-
Answer:
|
| 138 |
-
I am a Tech Lead at FleetEnable, where I lead the UI development for a logistics SaaS product focused on drayage and freight management.
|
| 139 |
-
|
| 140 |
-
---
|
| 141 |
-
Example 2:
|
| 142 |
-
|
| 143 |
-
Question: What are your primary responsibilities as a Tech Lead?
|
| 144 |
-
|
| 145 |
-
Answer:
|
| 146 |
-
My primary responsibilities include:
|
| 147 |
-
- Leading UI development.
|
| 148 |
-
- Collaborating with product and backend teams.
|
| 149 |
-
- Helping define technical strategies.
|
| 150 |
-
- Ensuring the delivery of high-quality features.
|
| 151 |
-
|
| 152 |
-
---
|
| 153 |
-
|
| 154 |
-
Context:
|
| 155 |
-
{% for document in documents %}
|
| 156 |
-
Question: {{ document.meta.question }}
|
| 157 |
-
Answer: {{ document.content }}
|
| 158 |
-
{% endfor %}
|
| 159 |
-
|
| 160 |
-
Question: {{question}}
|
| 161 |
-
|
| 162 |
-
Answer:
|
| 163 |
-
"""
|
| 164 |
),
|
| 165 |
}
|
| 166 |
|
|
|
|
| 1 |
from typing import Dict, Optional, List
|
| 2 |
from dataclasses import dataclass
|
| 3 |
from haystack.dataclasses import ChatMessage
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
def load_prompt_template(filename: str) -> str:
|
| 7 |
+
"""Load prompt template from txt file."""
|
| 8 |
+
prompt_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "prompts", filename)
|
| 9 |
+
with open(prompt_path, "r", encoding="utf-8") as f:
|
| 10 |
+
return f.read().strip()
|
| 11 |
|
| 12 |
@dataclass
|
| 13 |
class DatasetConfig:
|
|
|
|
| 26 |
"role": "act",
|
| 27 |
"prompt": "prompt"
|
| 28 |
},
|
| 29 |
+
prompt_template=load_prompt_template("awesome-chatgpt-prompts.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
),
|
| 31 |
"settings-dataset": DatasetConfig(
|
| 32 |
name="syntaxhacker/rag_pipeline",
|
|
|
|
| 36 |
"answer": "answer",
|
| 37 |
"context": "context"
|
| 38 |
},
|
| 39 |
+
prompt_template=load_prompt_template("settings-dataset.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
),
|
| 41 |
"seven-wonders": DatasetConfig(
|
| 42 |
name="bilgeyucel/seven-wonders",
|
| 43 |
content_field="content",
|
| 44 |
fields={}, # No additional fields needed
|
| 45 |
+
prompt_template=load_prompt_template("seven-wonders.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
),
|
| 47 |
"psychology-dataset": DatasetConfig(
|
| 48 |
name="jkhedri/psychology-dataset",
|
|
|
|
| 52 |
"response_j": "response_j", # Response from one model
|
| 53 |
"response_k": "response_k" # Response from another model
|
| 54 |
},
|
| 55 |
+
prompt_template=load_prompt_template("psychology-dataset.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
),
|
| 57 |
"developer-portfolio": DatasetConfig(
|
| 58 |
name="syntaxhacker/developer-portfolio-rag",
|
|
|
|
| 63 |
"answer": "answer",
|
| 64 |
"context": "context"
|
| 65 |
},
|
| 66 |
+
prompt_template=load_prompt_template("developer-portfolio.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
),
|
| 68 |
}
|
| 69 |
|
app/main.py
CHANGED
|
@@ -4,7 +4,7 @@ import os
|
|
| 4 |
import logging
|
| 5 |
import sys
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
-
from .config import DATASET_CONFIGS
|
| 8 |
from openai import OpenAI
|
| 9 |
from openai.types.chat import ChatCompletionMessageParam
|
| 10 |
import json
|
|
@@ -141,38 +141,16 @@ async def chat_with_ai(request: ChatRequest):
|
|
| 141 |
]
|
| 142 |
|
| 143 |
# Add system message to guide the AI
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
- For general greetings, introduce yourself as Rohit's AI assistant
|
| 155 |
-
- Always refer to Rohit in third person (he/his/Rohit)
|
| 156 |
-
- Synthesize RAG results into natural responses about Rohit
|
| 157 |
-
- Format responses with markdown for readability
|
| 158 |
-
|
| 159 |
-
Examples:
|
| 160 |
-
β Wrong: "I am a Tech Lead at FleetEnable"
|
| 161 |
-
β
Right: "Rohit is currently working as a Tech Lead at FleetEnable"
|
| 162 |
-
|
| 163 |
-
β Wrong: "My responsibilities include..."
|
| 164 |
-
β
Right: "His responsibilities include..."
|
| 165 |
-
|
| 166 |
-
β Wrong: "I have 5+ years of experience..."
|
| 167 |
-
β
Right: "Rohit has 5+ years of experience..."
|
| 168 |
-
|
| 169 |
-
β Wrong: "You can reach me at..."
|
| 170 |
-
β
Right: "You can reach Rohit at..."
|
| 171 |
-
|
| 172 |
-
For greetings: "Hi! I'm Rohit's AI assistant. I can help you learn about his professional background, skills, and experience. What would you like to know about Rohit?"""
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
# Insert system message at the beginning
|
| 176 |
messages.insert(0, system_message)
|
| 177 |
|
| 178 |
# Make the API call with tools
|
|
|
|
| 4 |
import logging
|
| 5 |
import sys
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
+
from .config import DATASET_CONFIGS, load_prompt_template
|
| 8 |
from openai import OpenAI
|
| 9 |
from openai.types.chat import ChatCompletionMessageParam
|
| 10 |
import json
|
|
|
|
| 141 |
]
|
| 142 |
|
| 143 |
# Add system message to guide the AI
|
| 144 |
+
if request.dataset == "developer-portfolio":
|
| 145 |
+
system_message: ChatCompletionMessageParam = {
|
| 146 |
+
"role": "system",
|
| 147 |
+
"content": load_prompt_template("system-instruction.txt")
|
| 148 |
+
}
|
| 149 |
+
else:
|
| 150 |
+
system_message: ChatCompletionMessageParam = {
|
| 151 |
+
"role": "system",
|
| 152 |
+
"content": load_prompt_template("generic-system-instruction.txt")
|
| 153 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
messages.insert(0, system_message)
|
| 155 |
|
| 156 |
# Make the API call with tools
|
prompts/awesome-chatgpt-prompts.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Given the following context where each document represents a prompt for a specific role,
|
| 2 |
+
please answer the question while considering both the role and the prompt content.
|
| 3 |
+
|
| 4 |
+
Available Contexts:
|
| 5 |
+
{% for document in documents %}
|
| 6 |
+
{% if document.meta.role %}Role: {{ document.meta.role }}{% endif %}
|
| 7 |
+
Content: {{ document.content }}
|
| 8 |
+
---
|
| 9 |
+
{% endfor %}
|
| 10 |
+
|
| 11 |
+
Question: {{question}}
|
| 12 |
+
Answer:
|
prompts/developer-portfolio.txt
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
You are a helpful assistant that provides direct answers based on the provided context. Format your answers using markdown, especially for lists.
|
| 2 |
+
|
| 3 |
+
---
|
| 4 |
+
Example 1:
|
| 5 |
+
|
| 6 |
+
Question: What is your current role?
|
| 7 |
+
|
| 8 |
+
Answer:
|
| 9 |
+
I am a Tech Lead at FleetEnable, where I lead the UI development for a logistics SaaS product focused on drayage and freight management.
|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
Example 2:
|
| 13 |
+
|
| 14 |
+
Question: What are your primary responsibilities as a Tech Lead?
|
| 15 |
+
|
| 16 |
+
Answer:
|
| 17 |
+
My primary responsibilities include:
|
| 18 |
+
- Leading UI development.
|
| 19 |
+
- Collaborating with product and backend teams.
|
| 20 |
+
- Helping define technical strategies.
|
| 21 |
+
- Ensuring the delivery of high-quality features.
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
Context:
|
| 26 |
+
{% for document in documents %}
|
| 27 |
+
Question: {{ document.meta.question }}
|
| 28 |
+
Answer: {{ document.content }}
|
| 29 |
+
{% endfor %}
|
| 30 |
+
|
| 31 |
+
Question: {{question}}
|
| 32 |
+
|
| 33 |
+
Answer:
|
prompts/generic-system-instruction.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
You are a helpful AI assistant with access to a RAG (Retrieval-Augmented Generation) pipeline. Use the rag_qa tool to answer questions based on the provided context from the dataset. Provide accurate, helpful responses based on the retrieved information.
|
prompts/psychology-dataset.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Given the following context where each document represents a psychological inquiry,
|
| 2 |
+
please answer the question based on the provided responses.
|
| 3 |
+
|
| 4 |
+
Available Contexts:
|
| 5 |
+
{% for document in documents %}
|
| 6 |
+
Question: {{ document.content }}
|
| 7 |
+
Response J: {{ document.meta.response_j }}
|
| 8 |
+
Response K: {{ document.meta.response_k }}
|
| 9 |
+
---
|
| 10 |
+
{% endfor %}
|
| 11 |
+
|
| 12 |
+
Question: {{question}}
|
| 13 |
+
Answer:
|
prompts/settings-dataset.txt
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Given the following context about software settings and configurations,
|
| 2 |
+
please answer the question accurately based on the provided information.
|
| 3 |
+
|
| 4 |
+
For each setting, provide a clear, step-by-step navigation path and include:
|
| 5 |
+
1. The exact location (Origin Type > Tab > Section > Setting name)
|
| 6 |
+
2. What the setting does
|
| 7 |
+
3. Available options/values
|
| 8 |
+
4. How to access and modify the setting
|
| 9 |
+
5. Reference screenshots (if available)
|
| 10 |
+
|
| 11 |
+
Format your answer as:
|
| 12 |
+
"To [accomplish task], follow these steps:
|
| 13 |
+
|
| 14 |
+
Location: [Origin Type] > [Tab] > [Section] > [Setting name]
|
| 15 |
+
Purpose: [describe what the setting does]
|
| 16 |
+
Options: [list available values/options]
|
| 17 |
+
How to set: [describe interaction method: toggle/select/input]
|
| 18 |
+
|
| 19 |
+
Visual Guide:
|
| 20 |
+
[Include reference image links if available]
|
| 21 |
+
|
| 22 |
+
For more details, you can refer to the screenshots above showing the exact location and interface."
|
| 23 |
+
|
| 24 |
+
Available Contexts:
|
| 25 |
+
{% for document in documents %}
|
| 26 |
+
Setting Info: {{ document.content }}
|
| 27 |
+
Reference Answer: {{ document.meta.answer }}
|
| 28 |
+
---
|
| 29 |
+
{% endfor %}
|
| 30 |
+
|
| 31 |
+
Question: {{question}}
|
| 32 |
+
Answer:
|
prompts/seven-wonders.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Given the following information about the Seven Wonders, please answer the question.
|
| 2 |
+
|
| 3 |
+
Context:
|
| 4 |
+
{% for document in documents %}
|
| 5 |
+
{{ document.content }}
|
| 6 |
+
{% endfor %}
|
| 7 |
+
|
| 8 |
+
Question: {{question}}
|
| 9 |
+
Answer:
|
prompts/system-instruction.txt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
You are an AI assistant for Rohit's developer portfolio. You have access to a RAG (Retrieval-Augmented Generation) pipeline containing information about Rohit's professional background, skills, and experience.
|
| 2 |
+
|
| 3 |
+
CRITICAL: The portfolio information is about ROHIT, not you. Always refer to Rohit in the third person ("he", "his", "Rohit") rather than first person ("I", "my", "me").
|
| 4 |
+
|
| 5 |
+
When you use rag_qa tool, you MUST use retrieved information to answer about Rohit's background.
|
| 6 |
+
|
| 7 |
+
Guidelines:
|
| 8 |
+
- Use rag_qa tool for questions about Rohit's: work experience, skills, projects, achievements, contact info
|
| 9 |
+
- For general greetings, introduce yourself as Rohit's AI assistant
|
| 10 |
+
- Always refer to Rohit in third person (he/his/Rohit)
|
| 11 |
+
- Synthesize RAG results into natural responses about Rohit
|
| 12 |
+
- Format responses with markdown for readability
|
| 13 |
+
|
| 14 |
+
Examples:
|
| 15 |
+
β Wrong: "I am a Tech Lead at FleetEnable"
|
| 16 |
+
β
Right: "Rohit is currently working as a Tech Lead at FleetEnable"
|
| 17 |
+
|
| 18 |
+
β Wrong: "My responsibilities include..."
|
| 19 |
+
β
Right: "His responsibilities include..."
|
| 20 |
+
|
| 21 |
+
β Wrong: "I have 5+ years of experience..."
|
| 22 |
+
β
Right: "Rohit has 5+ years of experience..."
|
| 23 |
+
|
| 24 |
+
β Wrong: "You can reach me at..."
|
| 25 |
+
β
Right: "You can reach Rohit at..."
|
| 26 |
+
|
| 27 |
+
For greetings: "Hi! I'm Rohit's AI assistant. I can help you learn about his professional background, skills, and experience. What would you like to know about Rohit?"
|