You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to use the new yaml prompt file feature but realized that it's currently only supported with OpenAI.
I see this is the code that does it:
consttrimmedPrompt=prompt.trim();if(trimmedPrompt.startsWith('- role:')){try{// Try YAMLmessages=yaml.load(prompt)as{role: string;content: string}[];}catch(err){thrownewError(`OpenAI Chat Completion prompt is not a valid YAML string: ${err}\n\n${prompt}`,);}}else{try{// Try JSONmessages=JSON.parse(prompt)as{role: string;content: string}[];}catch(err){if(process.env.PROMPTFOO_REQUIRE_JSON_PROMPTS||trimmedPrompt.startsWith('{')||trimmedPrompt.startsWith('[')){thrownewError(`OpenAI Chat Completion prompt is not a valid JSON string: ${err}\n\n${prompt}`,);}// Fall back to wrapping the prompt in a user messagemessages=[{role: 'user',content: prompt}];}}
Wondering if this code should be moved out to a preprocessing layer before the provider is called, that way it would be called regardless of the provider. Thoughts?
The text was updated successfully, but these errors were encountered:
Hey,
I was trying to use the new
yaml
prompt file feature but realized that it's currently only supported with OpenAI.I see this is the code that does it:
Wondering if this code should be moved out to a preprocessing layer before the provider is called, that way it would be called regardless of the provider. Thoughts?
The text was updated successfully, but these errors were encountered: