|
|
|
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 |
|
|
|
|
|
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") |
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
|
parser = PydanticOutputParser(pydantic_object=ResponseSchema) |