Skip to content

Conversation

@rysweet
Copy link

@rysweet rysweet commented Mar 13, 2025

adds a [Prompty(File=...)] attribute enabling specifying the prompts file on a class or method

see #205

/// <summary>
/// Prompty Attribute - used to load a prompty file or resource from an attribute
/// </summary>
/// <usage>
/// [Prompty("prompty/basic.prompty"]
/// [Prompty("prompty/embedded-resource-path.prompty", IsResource = true, Configuration = "default", Params = new string[] { "question", "answer" })]
/// public class MyClass
/// {...} 
/// in a class or method then use the attribute to load the prompty
/// ...
/// var prompty = (PromptyAttribute)Attribute.GetCustomAttribute(typeof(MyClass), typeof(PromptyAttribute));
/// var messages = prompty.Messages;
/// ...
/// </usage>

Note: you can only specify params that are strings. that is a limitation of attribs. you can still Prepare(new Dictionary<string, object) manually.

@rysweet rysweet marked this pull request as draft March 13, 2025 16:53
@rysweet rysweet changed the title Rysweet prompty attribute .NET prompty attribute Mar 13, 2025
@rysweet rysweet marked this pull request as ready for review March 13, 2025 21:19
@rysweet
Copy link
Author

rysweet commented Mar 14, 2025

please note:
Co-Autohored by: @IntrepidIcarus (Dustin Duran)

@sethjuarez
Copy link
Member

Are there any issues with file normalization when using a stream? In the python version you can explode out a section of the frontmatter by adding a ${file:my_props.json} to any part of the tree and it will load my_props.json based upon the relative path to the parent prompty file. Does this work the same way?

@rysweet
Copy link
Author

rysweet commented Apr 11, 2025

Are there any issues with file normalization when using a stream? In the python version you can explode out a section of the frontmatter by adding a ${file:my_props.json} to any part of the tree and it will load my_props.json based upon the relative path to the parent prompty file. Does this work the same way?

no idea - my assumption is that this would be down to the Json serializer rather than the file IO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants