Dynamic Types Tests #1310
antoniosarosi
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Overview
Classes and enums marked as
@@dynamic
cannot be tested properly since there is no way to specify dynamic class fields or dynamic enum variants for return types. On the other hand, dynamic parameter types already work but only in the case of classes, dynamic enums are not handled properly.Dynamic Return Types
Enums
Basic example of dynamic enum return type:
There is no syntax for adding new variants to the
Category
enum in the test case, so the rendered prompt will only contain the statically defined variants ofCategory
:Classes
We have the same problem when using dynamic classes as return types instead of enums:
Suppose we want to add a field called
experience
of this type:There is no syntax that allows us to do that in the test, so the rendered prompt will only contain static fields defined in the
Resume
class:Dynamic Parameter Types
Enums
We cannot add dynamic variants to an enum because BAML reports them as errors:
BAML Error:
Classes
Dynamic classes are rendered correctly since all the additional properties we write in the
args
block will get rendered in the prompt:Resulting rendered resume in the prompt:
Proposed Syntax
The proposed syntax for specifying dynamic properties and variants in tests introduces the new
type_builder
anddynamic
blocks.Dynamic Classes
Resulting prompt during test execution:
Dynamic Enums
Resulting prompt during test execution:
Documentation Preview
@@dynamic
AttributeTypeBuilder
ReferenceBeta Was this translation helpful? Give feedback.
All reactions