Hi everybody... I have 2 questions, I solved them... But I don't like the way, maybe you have other solutions
Imagine I have some Enum:
Does anybody know how to:
- Parse output to Enum?
I did the following: I created the Pydantic class with this field and used PydanticOutputParser:
class MyEnumType(BaseModel):
my_enum: MyEnum
program = LLMTextCompletionProgram.from_defaults(
llm=llm,
output_parser=PydanticOutputParser(output_cls=MyEnumType),
prompt_template_str='......',
)
result = program(prompt=....)
return query_type.my_enum
- How can I pass Enum as a parameter to the agent function?
def my_agent(param: MyEnum):
....
As I understand it passes only basic Python types. So I just manually convert it back:
def my_agent(value: str):
param = MyEnum(value)