Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Bug: CreateFunctionFromPromptyFile ${file:...} paths are not evaluated relative to the prompty file location #11330

Open
DavidJFowler opened this issue Apr 2, 2025 · 2 comments · May be fixed by #11435
Assignees
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code

Comments

@DavidJFowler
Copy link

Describe the bug
PromptyKernelExtensions.CreateFunctionFromPromptyFile calls PromptyKernelExtensions..CreateFunctionFromPrompty which calls KernelFunctionPrompty.ToPromptTemplateConfig which then calls Prompty.Load.
The path to the prompty file is not passed in the call to Prompty.Load, this means that paths in any ${file:..} references in the prompty file are evaluated relative to the application's working directory rather than to the directory containing the prompty file. This behaviour is different from that when running using the VS Code extension.

To Reproduce

  • Create a prompty file containing a ${file:...} reference, e.g.
model:
  api: chat
  configuration:
    type: azure_openai_beta
  parameters:
    response_format: ${file:MySchema.json}
  • Save the file in a sub-directory of the application's working directory, e.g. /prompts
  • Place the referenced file, e.g. MySchema.json in the sub-directory
  • Create a function using .CreateFunctionFromPromptyFile:
    IFileProvider fileProvider = new PhysicalFileProvider(Path.Join(Directory.GetCurrentDirectory(), "prompts"));
    var function = kernel.CreateFunctionFromPromptyFile("my_template.prompty", fileProvider);
  • See that the schema file is not loaded.

Expected behavior
${file:...} paths are evaluated relative to the prompty file location.

@DavidJFowler DavidJFowler added the bug Something isn't working label Apr 2, 2025
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Apr 2, 2025
@github-actions github-actions bot changed the title Bug: CreateFunctionFromPromptyFile ${file:...} paths are not evaluated relative to the prompty file location .Net: Bug: CreateFunctionFromPromptyFile ${file:...} paths are not evaluated relative to the prompty file location Apr 2, 2025
@markwallace-microsoft markwallace-microsoft self-assigned this Apr 3, 2025
@markwallace-microsoft
Copy link
Member

@DavidJFowler thanks for reporting this issue. Would you like to create a PR to fix this?

@DavidJFowler
Copy link
Author

@DavidJFowler thanks for reporting this issue. Would you like to create a PR to fix this?

Thanks @markwallace-microsoft I'll have a look into it.

@DavidJFowler DavidJFowler linked a pull request Apr 8, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code
Projects
Status: Bug
Development

Successfully merging a pull request may close this issue.

2 participants