from langchain.schema.output_parser import StrOutputParser from chains.utils import getToolPromptTemplate from model import llm4 from langchain.tools import tool step4ToolName = "Problem Reconstruction" step4ToolContext = """\ In the format provided, the final scalable problem definition would be structured as follows: "For [a specific demographic], in the context of [a particular scenario], due to [a certain reason], \ the specific problem they face is what we need to find answers to in this toolkit. \ How we can [in a particular manner], achieve [a desired impact] is what we will continue to research." Here is an example using the format: "For [urban adolescents], in the context of [high unemployment rates], \ due to [a lack of job readiness and skills], \ the specific problem they face—[difficulty in securing first-time employment]—is what \ we need to find answers to in this toolkit. How we can [through vocational training and apprenticeship programs], \ achieve [an increase in youth employment rates] is what we will continue to research."\ """ step4ToolSuggestion = """\ 1. The facilitator needs to provide a new workspace for everyone (a whiteboard or a blank canvas). 2. Each participant, using a sticky note and the format provided on the right, \ should combine the supplementary information and feedback obtained from the \ previous step to reconstruct the description of the problem they have posed. 3. Different participants who identified similar problems in the previous step can either \ reconstruct the issue separately according to their own understanding or work in \ pairs to complete the reconstruction of the same problem. """ prompt = getToolPromptTemplate(step4ToolName, step4ToolContext, step4ToolSuggestion) step4Chain = prompt | llm4 | StrOutputParser() @tool("Problem Reconstruction") def step4Tool(context: str) -> str: """Useful for find some detail advise or example when you process on "Problem Reconstruction" step. Need to input current problem context about Problem Reconstruction.""" return step4Chain.invoke({"current_situation": context})