Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

promptfooconfig.transform.yaml 1.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  1. # yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
  2. description: 'Example configuration for SageMaker provider with transforms'
  3. prompts:
  4. - 'Generate a short poem about {{subject}}'
  5. - 'Write a brief description of {{subject}}'
  6. - 'Explain the concept of {{subject}} to a 5-year-old'
  7. providers:
  8. # Example 1: Inline transform function for Llama format
  9. - id: sagemaker:llama:your-llama-endpoint
  10. label: 'Llama with Inline Transform'
  11. config:
  12. region: us-west-2
  13. modelType: llama
  14. maxTokens: 256
  15. temperature: 0.7
  16. transform: |
  17. // Format for Llama-2 Chat models
  18. return `<s>[INST] ${prompt} [/INST]`;
  19. # Example 2: File-based transform for complex formatting
  20. - id: sagemaker:jumpstart:your-jumpstart-endpoint
  21. label: 'JumpStart with File Transform'
  22. config:
  23. region: us-west-2
  24. modelType: jumpstart
  25. maxTokens: 256
  26. temperature: 0.7
  27. transform: file://transform.js
  28. responseFormat:
  29. path: 'json.generated_text' # Extract this field from the response
  30. # Example 3: Transform applied to an embedding model
  31. - id: sagemaker:embedding:your-embedding-endpoint
  32. label: 'Embedding with Transform'
  33. config:
  34. region: us-west-2
  35. transform: |
  36. // For embedding models, you might want to add context or formatting
  37. return `Context: This is for semantic analysis. Query: ${prompt}`;
  38. tests:
  39. - vars:
  40. subject: space exploration
  41. - vars:
  42. subject: artificial intelligence
  43. - vars:
  44. subject: climate change
  45. # Example using transformed embedding provider for similarity assertions
  46. defaultTest:
  47. assert:
  48. - type: similar
  49. value: '{{prompt}}'
  50. threshold: 0.7
  51. options:
  52. provider:
  53. embedding:
  54. id: sagemaker:embedding:your-embedding-endpoint
  55. config:
  56. region: us-west-2
  57. transform: |
  58. // Ensure consistent formatting for comparison
  59. return `Topic: ${prompt}`;
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...