jjz5463 commited on
Commit
76df96c
·
1 Parent(s): e74e7eb

simplify data population

Browse files
Files changed (1) hide show
  1. task_specific_data_population.py +9 -27
task_specific_data_population.py CHANGED
@@ -7,7 +7,7 @@ import json_repair
7
  class DataPopulation:
8
  def __init__(self, api_key):
9
  # Set the API key during initialization
10
- self.client = OpenAI(api_key=api_key)
11
  self.conversation = [
12
  {
13
  "role": "system",
@@ -27,7 +27,6 @@ class DataPopulation:
27
  }
28
  ]
29
 
30
-
31
  def fetch_huggingface_dataset(self, dataset_name):
32
  """Fetch the dataset from Hugging Face."""
33
  return load_dataset(dataset_name)
@@ -62,41 +61,24 @@ class DataPopulation:
62
  self.conversation.append({
63
  "role": "user",
64
  "content": (
65
- f"Given the task: '{task}' and the following page details:\n{relevant_page_details}\n\n"
66
- "Instructions:\n"
67
- "1. Ensure each page contains the following keys: 'page_name', 'features', and 'user_data' (even if empty).\n"
68
- "2. Update 'user_data' with essential information relevant to the task. Do not modify the 'features' section.\n"
69
- "3. Maintain the exact input structure, making changes only to 'user_data' where required.\n"
70
- "4. Confirm that both 'features' and 'user_data' are dictionaries.\n"
71
- "5. Verify that every page includes exactly the three required keys: 'page_name', 'features', and 'user_data'."
72
- "6. Make sure 'user_data' must exist as a key! "
73
  )
74
  })
75
  response_content = self.gpt4_chat(self.conversation)
76
  return response_content
77
 
78
- def ask_to_update_sitemap(self, sitemap, new_page):
79
- """Update the sitemap with the new page and adjust links."""
80
- self.conversation.append({
81
- "role": "user",
82
- "content": (
83
- f"Given the current sitemap:\n{sitemap}\nand a new page: '{new_page}' (currently only has a 'uid'), update the sitemap by:\n"
84
- "- Adding necessary details to '{new_page}', including 'links_to'.\n"
85
- "- Updating 'links_to' in other relevant pages to include '{new_page}'.\n"
86
- "Ensure the output retains the exact structure of the input."
87
- )
88
- })
89
- response_sitemap = self.gpt4_chat(self.conversation)
90
- return json_repair.loads(response_sitemap)
91
-
92
  def ask_to_update_user_state(self, task, user_state):
93
  """Update the user state based on the task."""
94
  self.conversation.append({
95
  "role": "user",
96
  "content": (
97
- f"Given the task: '{task}' and the current user state:\n{user_state}\n\n"
98
- "Update the user state to reflect any changes necessary for completing the task. "
99
- "Only modify values that are required; maintain the exact structure of the input."
100
  )
101
  })
102
  response_content = self.gpt4_chat(self.conversation)
 
7
  class DataPopulation:
8
  def __init__(self, api_key):
9
  # Set the API key during initialization
10
+ self.client = OpenAI(api_key=openai_api_key)
11
  self.conversation = [
12
  {
13
  "role": "system",
 
27
  }
28
  ]
29
 
 
30
  def fetch_huggingface_dataset(self, dataset_name):
31
  """Fetch the dataset from Hugging Face."""
32
  return load_dataset(dataset_name)
 
61
  self.conversation.append({
62
  "role": "user",
63
  "content": (
64
+ f"Given the task: '{task}' and the following task-relevant page details:\n{relevant_page_details}\n\n"
65
+ f"Update each page's 'user_data' field with essential information for task-completion."
66
+ f"Do not modify the other fields"
67
+ "Output should maintain the exact input structure, making changes only to 'user_data' where required."
68
+ "'user_data' must exists as a key in each page.\n"
 
 
 
69
  )
70
  })
71
  response_content = self.gpt4_chat(self.conversation)
72
  return response_content
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  def ask_to_update_user_state(self, task, user_state):
75
  """Update the user state based on the task."""
76
  self.conversation.append({
77
  "role": "user",
78
  "content": (
79
+ f"Given the task: '{task}', default user state:\n{user_state}, and user_data in chat history.\n\n"
80
+ "Initialize the user state values to reflect any initial status necessary for completing the task. "
81
+ "Output should maintain the exact input structure."
82
  )
83
  })
84
  response_content = self.gpt4_chat(self.conversation)