jess commited on
Commit
3757f89
·
1 Parent(s): 05a7853

DONE: WORKING save prompt

Browse files
Project.py CHANGED
@@ -3,7 +3,7 @@ import csv
3
  import re
4
  from typing import Any, Dict
5
  from common_functions_v4 import *
6
- # from prompt_configs import PROMPTS, ModelType
7
  from config_classes import *
8
  from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
9
  import openai
@@ -198,10 +198,13 @@ class Project:
198
  def execute_prompt(self, prompt_name: str, input_variables: Dict[str, Any] = None) -> str:
199
  """Execute a prompt with given input variables synchronously"""
200
  print(f"Attempting to execute prompt: {prompt_name}")
201
- if prompt_name not in PROMPTS:
 
 
202
  raise ValueError(f"Unknown prompt: {prompt_name}")
203
 
204
- config = PROMPTS[prompt_name]
 
205
  input_variables = self._validate_and_fill_inputs(config, input_variables)
206
  prompt = self._build_prompt(config, input_variables)
207
  print(f"Final prompt to be executed: {prompt}")
@@ -220,10 +223,12 @@ class Project:
220
  async def async_execute_prompt(self, prompt_name: str, input_variables: Dict[str, Any] = None) -> str:
221
  """Execute a prompt with given input variables asynchronously"""
222
  print(f"Attempting to execute prompt: {prompt_name}")
223
- if prompt_name not in PROMPTS:
 
224
  raise ValueError(f"Unknown prompt: {prompt_name}")
225
 
226
- config = PROMPTS[prompt_name]
 
227
  input_variables = self._validate_and_fill_inputs(config, input_variables)
228
  prompt = self._build_prompt(config, input_variables)
229
  # print(f"Final prompt to be executed: {prompt}")
@@ -310,13 +315,17 @@ class Project:
310
  def reset_project(self):
311
  """Reset all project attributes"""
312
  self.project_detail = []
313
- for config in PROMPTS.values():
 
 
 
314
  for output in config.outputs:
315
  setattr(self, output, "")
316
 
317
  async def generate_client_initial_question(self):
318
  """Generate follow-up questions after initial client response"""
319
- return PROMPTS["client_initial_question"].prompt
 
320
 
321
  async def generate_client_follow_up(self):
322
  """Generate follow-up questions after initial client response"""
@@ -393,6 +402,11 @@ class Project:
393
  PROMPTS["generate_prd"].prompt,
394
  prd_response)
395
 
 
 
 
 
 
396
  # Parse and format the PRD response
397
  try:
398
  prd_json = self._parse_json_response(prd_response)
 
3
  import re
4
  from typing import Any, Dict
5
  from common_functions_v4 import *
6
+ from prompt_configs import PROMPTS, ModelType
7
  from config_classes import *
8
  from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
9
  import openai
 
198
  def execute_prompt(self, prompt_name: str, input_variables: Dict[str, Any] = None) -> str:
199
  """Execute a prompt with given input variables synchronously"""
200
  print(f"Attempting to execute prompt: {prompt_name}")
201
+
202
+ # if prompt_name not in PROMPTS:
203
+ if prompt_name not in self._db_config:
204
  raise ValueError(f"Unknown prompt: {prompt_name}")
205
 
206
+ # config = PROMPTS[prompt_name]
207
+ config = self._db_config[prompt_name]
208
  input_variables = self._validate_and_fill_inputs(config, input_variables)
209
  prompt = self._build_prompt(config, input_variables)
210
  print(f"Final prompt to be executed: {prompt}")
 
223
  async def async_execute_prompt(self, prompt_name: str, input_variables: Dict[str, Any] = None) -> str:
224
  """Execute a prompt with given input variables asynchronously"""
225
  print(f"Attempting to execute prompt: {prompt_name}")
226
+ # if prompt_name not in PROMPTS:
227
+ if prompt_name not in self._db_config:
228
  raise ValueError(f"Unknown prompt: {prompt_name}")
229
 
230
+ # config = PROMPTS[prompt_name]
231
+ config = self._db_config[prompt_name]
232
  input_variables = self._validate_and_fill_inputs(config, input_variables)
233
  prompt = self._build_prompt(config, input_variables)
234
  # print(f"Final prompt to be executed: {prompt}")
 
315
  def reset_project(self):
316
  """Reset all project attributes"""
317
  self.project_detail = []
318
+ self.load_config_from_db()
319
+
320
+ # for config in PROMPTS.values():
321
+ for config in self._db_config.values():
322
  for output in config.outputs:
323
  setattr(self, output, "")
324
 
325
  async def generate_client_initial_question(self):
326
  """Generate follow-up questions after initial client response"""
327
+ # return PROMPTS["client_initial_question"].prompt
328
+ return self._db_config["client_initial_question"].prompt
329
 
330
  async def generate_client_follow_up(self):
331
  """Generate follow-up questions after initial client response"""
 
402
  PROMPTS["generate_prd"].prompt,
403
  prd_response)
404
 
405
+ # log_prompt(self._db_config["generate_prd"].step,
406
+ # self._db_config["generate_prd"].description,
407
+ # self._db_config["generate_prd"].prompt,
408
+ # prd_response)
409
+
410
  # Parse and format the PRD response
411
  try:
412
  prd_json = self._parse_json_response(prd_response)
app.py CHANGED
@@ -336,13 +336,13 @@ def create_quotation_generator_section():
336
  all_components[prompt_key] = components
337
 
338
  def bulk_save_prompts():
339
- print("Debugging components")
340
  try:
341
  # Create a backup of current PROMPTS
342
  original_prompts = {key: prompt_config.prompt for key, prompt_config in PROMPTS.items()}
343
 
344
  # Create the output file in prompt_configs_exp.py format
345
- print("Starting debug_components function")
346
  with open("prompt_configs_exp.txt", "w", encoding="utf-8") as f:
347
  # Write everything at once instead of line by line
348
  output_content = "{\n"
@@ -409,16 +409,16 @@ def create_quotation_generator_section():
409
  print("Successfully completed writing to prompt_configs_exp.py")
410
  return "✅ Prompts updated and exported to prompt_configs_exp.py successfully"
411
  except Exception as e:
412
- print(f"ERROR in debug_components: {str(e)}")
413
  return f"❌ Error updating prompts: {str(e)}"
414
 
415
- debug_button = gr.Button("Debug Components")
416
- debug_status = gr.Markdown("Click to save component debug information")
417
 
418
- debug_button.click(
419
  fn=bulk_save_prompts,
420
  inputs=[],
421
- outputs=[debug_status]
422
  )
423
 
424
 
 
336
  all_components[prompt_key] = components
337
 
338
  def bulk_save_prompts():
339
+ print("Bulk saving prompts")
340
  try:
341
  # Create a backup of current PROMPTS
342
  original_prompts = {key: prompt_config.prompt for key, prompt_config in PROMPTS.items()}
343
 
344
  # Create the output file in prompt_configs_exp.py format
345
+ print("Starting bulk save prompts function")
346
  with open("prompt_configs_exp.txt", "w", encoding="utf-8") as f:
347
  # Write everything at once instead of line by line
348
  output_content = "{\n"
 
409
  print("Successfully completed writing to prompt_configs_exp.py")
410
  return "✅ Prompts updated and exported to prompt_configs_exp.py successfully"
411
  except Exception as e:
412
+ print(f"ERROR in bulk_save_prompts: {str(e)}")
413
  return f"❌ Error updating prompts: {str(e)}"
414
 
415
+ bulk_save_button = gr.Button("Bulk Save Prompts to DB")
416
+ bulk_save_status = gr.Markdown("Click to save all prompts")
417
 
418
+ bulk_save_button.click(
419
  fn=bulk_save_prompts,
420
  inputs=[],
421
+ outputs=[bulk_save_status]
422
  )
423
 
424
 
db_config_log_20250326_204808.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205250.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205259.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205400.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205411.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205423.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205703.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205735.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205738.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_205744.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_210148.txt ADDED
The diff for this file is too large to render. See raw diff
 
db_config_log_20250326_210403.txt ADDED
The diff for this file is too large to render. See raw diff
 
prompt_configs.py CHANGED
@@ -41,8 +41,6 @@ PROMPTS = {
41
  "questioning_agent": PromptConfig(
42
  prompt=
43
  """
44
- i changed this for the forth time
45
-
46
  You are an AI that analyzes a software project’s requirements and determines all possible valid and unique configurations based on the provided constraints.
47
 
48
  Input Data:
 
41
  "questioning_agent": PromptConfig(
42
  prompt=
43
  """
 
 
44
  You are an AI that analyzes a software project’s requirements and determines all possible valid and unique configurations based on the provided constraints.
45
 
46
  Input Data:
prompt_configs_exp.txt CHANGED
@@ -1,9 +1,6 @@
1
  {
2
  $$"questioning_agent": PromptConfig(
3
  prompt="""
4
-
5
- i changed this for the forth time
6
-
7
  You are an AI that analyzes a software project’s requirements and determines all possible valid and unique configurations based on the provided constraints.
8
 
9
  Input Data:
@@ -203,7 +200,6 @@
203
  )$$,
204
  $$"client_initial_question": PromptConfig(
205
  prompt="""
206
-
207
  Client Information Gathering Questions
208
 
209
  ### Company Background and Industry
@@ -239,7 +235,6 @@
239
  )$$,
240
  $$"generate_client_follow_up": PromptConfig(
241
  prompt="""
242
-
243
  Based on the initial list of questions and the client's provided answers, generate **insightful and targeted follow-up questions** that will help deepen my understanding of the following critical aspects:
244
 
245
  1. **Client Overview**
@@ -580,7 +575,6 @@
580
  )$$,
581
  $$"generate_prd": PromptConfig(
582
  prompt="""
583
-
584
  Rewrite the following content under the document title "Project Requirements". The goal is to enhance clarity and structure while retaining every specific detail, metric, and constraint exactly as given.
585
 
586
  - Do not introduce any new information, context, or assumptions. Do not omit any details.
 
1
  {
2
  $$"questioning_agent": PromptConfig(
3
  prompt="""
 
 
 
4
  You are an AI that analyzes a software project’s requirements and determines all possible valid and unique configurations based on the provided constraints.
5
 
6
  Input Data:
 
200
  )$$,
201
  $$"client_initial_question": PromptConfig(
202
  prompt="""
 
203
  Client Information Gathering Questions
204
 
205
  ### Company Background and Industry
 
235
  )$$,
236
  $$"generate_client_follow_up": PromptConfig(
237
  prompt="""
 
238
  Based on the initial list of questions and the client's provided answers, generate **insightful and targeted follow-up questions** that will help deepen my understanding of the following critical aspects:
239
 
240
  1. **Client Overview**
 
575
  )$$,
576
  $$"generate_prd": PromptConfig(
577
  prompt="""
 
578
  Rewrite the following content under the document title "Project Requirements". The goal is to enhance clarity and structure while retaining every specific detail, metric, and constraint exactly as given.
579
 
580
  - Do not introduce any new information, context, or assumptions. Do not omit any details.