from typing import List from langchain_core.output_parsers import JsonOutputParser from langchain_core.pydantic_v1 import BaseModel, Field from langchain.output_parsers import PydanticOutputParser ## DEFINE INPUT FRAMEWORK class InputSchema(BaseModel): """Expect the input from the frontend to be a JSON object with this structure""" question: str = Field(description="The enquiry that is passed from the user") # Define your desired data structure. class FrontEndActions(BaseModel): """Structure to pass actions back to the frontend""" text: str = Field(description="The text to display on the button") type: str = Field(description="This should be a string that identifies the type of action. It can be one of: SuggestGoal, SuggestRiseActivity") class ResponseSchema(BaseModel): """Final response to the question being asked""" message: str = Field(description="final answer to respond to the user") #characters: str = Field(description="number of characters in the answer") #actions: List[FrontEndActions] = Field(description="List of suggested actions that should be passed back to the frontend to display. The use will click these to enact them. ") #tokens: int = Field(description="Count the number of used to produce the response") parser = PydanticOutputParser(pydantic_object=ResponseSchema)