-
Notifications
You must be signed in to change notification settings - Fork 0
/
output_parsers.py
33 lines (21 loc) · 1.02 KB
/
output_parsers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from typing import List, Dict, Any
from langchain_core.output_parsers import PydanticOutputParser
from pydantic import BaseModel, Field
class Summary(BaseModel):
summary: str = Field(description="summary")
facts: List[str] = Field(description="interesting facts about them")
def to_dict(self) -> Dict[str, Any]:
return {"summary": self.summary, "facts": self.facts}
class IceBreaker(BaseModel):
ice_breakers: List[str] = Field(description="ice breaker list")
def to_dict(self) -> Dict[str, Any]:
return {"ice_breakers": self.ice_breakers}
class TopicOfInterest(BaseModel):
topics_of_interest: List[str] = Field(
description="topic that might interest the person"
)
def to_dict(self) -> Dict[str, Any]:
return {"topics_of_interest": self.topics_of_interest}
summary_parser = PydanticOutputParser(pydantic_object=Summary)
ice_breaker_parser = PydanticOutputParser(pydantic_object=IceBreaker)
topics_of_interest_parser = PydanticOutputParser(pydantic_object=TopicOfInterest)