Spaces:
Runtime error
Runtime error
jess commited on
Commit ·
2a9812a
1
Parent(s): 6801443
add: question agent partially functional
Browse filesFiles changed (3)
264 unmodified lines265266267268269270264 unmodified linesfor output in config.outputs:setattr(self, output, "")async def generate_client_follow_up(self):"""Generate follow-up questions after initial client response"""return await self.async_execute_prompt(264 unmodified lines265266267268269270271272273274264 unmodified linesfor output in config.outputs:setattr(self, output, "")async def generate_client_initial_question(self):"""Generate follow-up questions after initial client response"""return PROMPTS["client_initial_question"].promptasync def generate_client_follow_up(self):"""Generate follow-up questions after initial client response"""return await self.async_execute_prompt(
276 unmodified lines2772782792802812822834 unmodified lines28828929029129229329429529629729829930030130230330430530623 unmodified lines33033133233333433533633733833996 unmodified lines436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465276 unmodified linesr'(?i)[\(\[]?\s*Sample\s*:\s*"[^"]*"\s*[\)\]]?','Answer:',text,flags=re.MULTILINE)return cleaned_text4 unmodified lines# Example usage:# chat_history = [{'role': 'user', ...}, {'role': 'assistant', ...}]# log_chat_history(chat_history)# if len(history) == 1: # After first client information question# next_question = state.quotation_project.generate_client_follow_up()# elif len(history) == 2:# # Get configuration output# next_question = validate_project_choice(answer,state.quotation_project)# # next_question = result# elif len(history) == 3: # After specific questioning, run general questions# next_question = state.quotation_project.generate_general_questions()# else: # Subsequent project requirements questions# # next_question = quotation_project.generate_follow_up()# next_question = state.quotation_project.generate_further_follow_up_questions()#TODO: Ensure it directs towards correct questionasync def async_process_response(answer, history):"""Process user responses and generate appropriate follow-up questions."""23 unmodified linesmetadata={"title": "_Processing_ step-by-step", "id": 0, "status": "pending"})yield response, ""current_thoughts = PROMPTS["client_initial_question"].thoughtsnext_question_task = asyncio.create_task(state.quotation_project.generate_client_follow_up())# Update project detail with new list;if state.quotation_project.session_id:96 unmodified linesdef create_new_session():"""Create a new session in the database and return the session_id"""try:# conn = get_db_connection()# cur = conn.cursor()# # Insert new session with start time# cur.execute("""# INSERT INTO sessions (start_time)# VALUES (CURRENT_TIMESTAMP)# RETURNING session_id# """)# session_id = cur.fetchone()[0]# # Insert session_base_project record for "Page"# cur.execute("""# INSERT INTO session_base_project (session_id, base_project_name)# VALUES (%s, 'Page')# """, (session_id,))# conn.commit()# cur.close()# conn.close()# return session_idreturn 151except Exception as e:print(f"Error creating new session: {str(e)}")return None276 unmodified lines2772782792802812822834 unmodified lines28828929029129229329423 unmodified lines31831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834996 unmodified lines446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475276 unmodified linesr'(?i)[\(\[]?\s*Sample\s*:\s*"[^"]*"\s*[\)\]]?','Answer:',text,flags=re.MULTILINE | re.IGNORECASE)return cleaned_text4 unmodified lines# Example usage:# chat_history = [{'role': 'user', ...}, {'role': 'assistant', ...}]# log_chat_history(chat_history)##TODO: Ensure it directs towards correct questionasync def async_process_response(answer, history):"""Process user responses and generate appropriate follow-up questions."""23 unmodified linesmetadata={"title": "_Processing_ step-by-step", "id": 0, "status": "pending"})yield response, ""function_to_run = state.quotation_project.generate_client_initial_questioncurrent_thoughts = PROMPTS["client_initial_question"].thoughtsproject_detail_len = len(state.quotation_project.project_detail)if project_detail_len == 2:function_to_run = state.quotation_project.generate_client_follow_upcurrent_thoughts = PROMPTS["generate_client_follow_up"].thoughtselif project_detail_len == 3:function_to_run = lambda: run_question_agent(state.quotation_project)current_thoughts = PROMPTS["generate_client_follow_up"].thoughtselif project_detail_len == 4:function_to_run = state.quotation_project.generate_general_questionscurrent_thoughts = PROMPTS["generate_general_questions"].thoughtselif project_detail_len >= 5:function_to_run = state.quotation_project.generate_further_follow_up_questionscurrent_thoughts = PROMPTS["generate_further_follow_up_questions"].thoughtsnext_question_task = asyncio.create_task(function_to_run())# Update project detail with new list;if state.quotation_project.session_id:96 unmodified linesdef create_new_session():"""Create a new session in the database and return the session_id"""try:conn = get_db_connection()cur = conn.cursor()# Insert new session with start timecur.execute("""INSERT INTO sessions (start_time)VALUES (CURRENT_TIMESTAMP)RETURNING session_id""")session_id = cur.fetchone()[0]# Insert session_base_project record for "Page"cur.execute("""INSERT INTO session_base_project (session_id, base_project_name)VALUES (%s, 'Page')""", (session_id,))conn.commit()cur.close()conn.close()return session_id# return 151except Exception as e:print(f"Error creating new session: {str(e)}")return None
141 unmodified lines142143144145146147141 unmodified linesshow_copy_button=True)},),"component_agent": PromptConfig(141 unmodified lines142143144145146147148149150151152153154155156157141 unmodified linesshow_copy_button=True)},thoughts=["Read the project detail and function list.","Identify the project requirements and function list.","Determine the project configuration type.","Output a JSON object with the configuration type and selected functions.","Running the selected functions to generate questions.","Analyzing the project requirements to determine the best question set.","Generating context-aware questions based on the project type.","Formatting the output with sample answers for clarity."],),"component_agent": PromptConfig(
Project.py+4
common_functions_v4.py+50-40
prompt_configs.py+10