rohit
commited on
Commit
Β·
f9322c0
1
Parent(s):
01ec3c1
add promtps to docker path
Browse files- Dockerfile +1 -0
- app/config.py +6 -144
Dockerfile
CHANGED
|
@@ -12,6 +12,7 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 12 |
|
| 13 |
# Copy application code
|
| 14 |
COPY --chown=user app/ app/
|
|
|
|
| 15 |
COPY --chown=user start.sh .
|
| 16 |
|
| 17 |
# Make start script executable
|
|
|
|
| 12 |
|
| 13 |
# Copy application code
|
| 14 |
COPY --chown=user app/ app/
|
| 15 |
+
COPY --chown=user prompts/ prompts/
|
| 16 |
COPY --chown=user start.sh .
|
| 17 |
|
| 18 |
# Make start script executable
|
app/config.py
CHANGED
|
@@ -7,151 +7,13 @@ import logging
|
|
| 7 |
logger = logging.getLogger(__name__)
|
| 8 |
|
| 9 |
def load_prompt_template(filename: str) -> str:
|
| 10 |
-
"""Load prompt template from txt file.
|
| 11 |
prompt_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "prompts", filename)
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
except FileNotFoundError:
|
| 18 |
-
logger.warning(f"β οΈ Prompt file not found: {filename}, using fallback template")
|
| 19 |
-
# Fallback prompts for production
|
| 20 |
-
fallback_prompts = {
|
| 21 |
-
"awesome-chatgpt-prompts.txt": """Given the following context where each document represents a prompt for a specific role,
|
| 22 |
-
please answer the question while considering both the role and the prompt content.
|
| 23 |
-
|
| 24 |
-
Available Contexts:
|
| 25 |
-
{% for document in documents %}
|
| 26 |
-
{% if document.meta.role %}Role: {{ document.meta.role }}{% endif %}
|
| 27 |
-
Content: {{ document.content }}
|
| 28 |
-
---
|
| 29 |
-
{% endfor %}
|
| 30 |
-
|
| 31 |
-
Question: {{question}}
|
| 32 |
-
Answer:""",
|
| 33 |
-
"settings-dataset.txt": """Given the following context about software settings and configurations,
|
| 34 |
-
please answer the question accurately based on the provided information.
|
| 35 |
-
|
| 36 |
-
For each setting, provide a clear, step-by-step navigation path and include:
|
| 37 |
-
1. The exact location (Origin Type > Tab > Section > Setting name)
|
| 38 |
-
2. What the setting does
|
| 39 |
-
3. Available options/values
|
| 40 |
-
4. How to access and modify the setting
|
| 41 |
-
5. Reference screenshots (if available)
|
| 42 |
-
|
| 43 |
-
Format your answer as:
|
| 44 |
-
"To [accomplish task], follow these steps:
|
| 45 |
-
|
| 46 |
-
Location: [Origin Type] > [Tab] > [Section] > [Setting name]
|
| 47 |
-
Purpose: [describe what the setting does]
|
| 48 |
-
Options: [list available values/options]
|
| 49 |
-
How to set: [describe interaction method: toggle/select/input]
|
| 50 |
-
|
| 51 |
-
Visual Guide:
|
| 52 |
-
[Include reference image links if available]
|
| 53 |
-
|
| 54 |
-
For more details, you can refer to the screenshots above showing the exact location and interface."
|
| 55 |
-
|
| 56 |
-
Available Contexts:
|
| 57 |
-
{% for document in documents %}
|
| 58 |
-
Setting Info: {{ document.content }}
|
| 59 |
-
Reference Answer: {{ document.meta.answer }}
|
| 60 |
-
---
|
| 61 |
-
{% endfor %}
|
| 62 |
-
|
| 63 |
-
Question: {{question}}
|
| 64 |
-
Answer:""",
|
| 65 |
-
"seven-wonders.txt": """Given the following information about the Seven Wonders, please answer the question.
|
| 66 |
-
|
| 67 |
-
Context:
|
| 68 |
-
{% for document in documents %}
|
| 69 |
-
{{ document.content }}
|
| 70 |
-
{% endfor %}
|
| 71 |
-
|
| 72 |
-
Question: {{question}}
|
| 73 |
-
Answer:""",
|
| 74 |
-
"psychology-dataset.txt": """Given the following context where each document represents a psychological inquiry,
|
| 75 |
-
please answer the question based on the provided responses.
|
| 76 |
-
|
| 77 |
-
Available Contexts:
|
| 78 |
-
{% for document in documents %}
|
| 79 |
-
Question: {{ document.content }}
|
| 80 |
-
Response J: {{ document.meta.response_j }}
|
| 81 |
-
Response K: {{ document.meta.response_k }}
|
| 82 |
-
---
|
| 83 |
-
{% endfor %}
|
| 84 |
-
|
| 85 |
-
Question: {{question}}
|
| 86 |
-
Answer:""",
|
| 87 |
-
"developer-portfolio.txt": """You are a helpful assistant that provides direct answers based on the provided context. Format your answers using markdown, especially for lists.
|
| 88 |
-
|
| 89 |
-
---
|
| 90 |
-
Example 1:
|
| 91 |
-
|
| 92 |
-
Question: What is your current role?
|
| 93 |
-
|
| 94 |
-
Answer:
|
| 95 |
-
I am a Tech Lead at FleetEnable, where I lead the UI development for a logistics SaaS product focused on drayage and freight management.
|
| 96 |
-
|
| 97 |
-
---
|
| 98 |
-
Example 2:
|
| 99 |
-
|
| 100 |
-
Question: What are your primary responsibilities as a Tech Lead?
|
| 101 |
-
|
| 102 |
-
Answer:
|
| 103 |
-
My primary responsibilities include:
|
| 104 |
-
- Leading UI development.
|
| 105 |
-
- Collaborating with product and backend teams.
|
| 106 |
-
- Helping define technical strategies.
|
| 107 |
-
- Ensuring the delivery of high-quality features.
|
| 108 |
-
|
| 109 |
-
---
|
| 110 |
-
|
| 111 |
-
Context:
|
| 112 |
-
{% for document in documents %}
|
| 113 |
-
Question: {{ document.meta.question }}
|
| 114 |
-
Answer: {{ document.content }}
|
| 115 |
-
{% endfor %}
|
| 116 |
-
|
| 117 |
-
Question: {{question}}
|
| 118 |
-
|
| 119 |
-
Answer:""",
|
| 120 |
-
"system-instruction.txt": """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.
|
| 121 |
-
|
| 122 |
-
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").
|
| 123 |
-
|
| 124 |
-
When you use rag_qa tool, you MUST use retrieved information to answer about Rohit's background.
|
| 125 |
-
|
| 126 |
-
Guidelines:
|
| 127 |
-
- Use rag_qa tool for questions about Rohit's: work experience, skills, projects, achievements, contact info
|
| 128 |
-
- For general greetings, introduce yourself as Rohit's AI assistant
|
| 129 |
-
- Always refer to Rohit in third person (he/his/Rohit)
|
| 130 |
-
- Synthesize RAG results into natural responses about Rohit
|
| 131 |
-
- Format responses with markdown for readability
|
| 132 |
-
|
| 133 |
-
Examples:
|
| 134 |
-
β Wrong: "I am a Tech Lead at FleetEnable"
|
| 135 |
-
β
Right: "Rohit is currently working as a Tech Lead at FleetEnable"
|
| 136 |
-
|
| 137 |
-
β Wrong: "My responsibilities include..."
|
| 138 |
-
β
Right: "His responsibilities include..."
|
| 139 |
-
|
| 140 |
-
β Wrong: "I have 5+ years of experience..."
|
| 141 |
-
β
Right: "Rohit has 5+ years of experience..."
|
| 142 |
-
|
| 143 |
-
β Wrong: "You can reach me at..."
|
| 144 |
-
β
Right: "You can reach Rohit at..."
|
| 145 |
-
|
| 146 |
-
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?""",
|
| 147 |
-
"generic-system-instruction.txt": """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."""
|
| 148 |
-
}
|
| 149 |
-
fallback = fallback_prompts.get(filename, "Default prompt template")
|
| 150 |
-
if filename in fallback_prompts:
|
| 151 |
-
logger.info(f"β
Using fallback template for: {filename}")
|
| 152 |
-
else:
|
| 153 |
-
logger.error(f"β No fallback found for: {filename}, using default")
|
| 154 |
-
return fallback
|
| 155 |
|
| 156 |
@dataclass
|
| 157 |
class DatasetConfig:
|
|
|
|
| 7 |
logger = logging.getLogger(__name__)
|
| 8 |
|
| 9 |
def load_prompt_template(filename: str) -> str:
|
| 10 |
+
"""Load prompt template from txt file."""
|
| 11 |
prompt_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "prompts", filename)
|
| 12 |
+
logger.info(f"Loading prompt template: {filename} from {prompt_path}")
|
| 13 |
+
with open(prompt_path, "r", encoding="utf-8") as f:
|
| 14 |
+
content = f.read().strip()
|
| 15 |
+
logger.info(f"β
Successfully loaded prompt template: {filename} ({len(content)} chars)")
|
| 16 |
+
return content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
@dataclass
|
| 19 |
class DatasetConfig:
|