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

standalone-action.yaml 2.7 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  1. #
  2. # This is a standalone github action that runs promptfoo against a change.
  3. # You'll have to edit it to use the appropriate branches and prompts.
  4. #
  5. # For an easier to use packaged action, see:
  6. #
  7. # https://promptfoo.dev/docs/integrations/github-action
  8. # https://github.com/promptfoo/promptfoo-action
  9. #
  10. name: LLM Prompt Evaluation
  11. on:
  12. pull_request:
  13. paths:
  14. - 'prompts/**'
  15. jobs:
  16. evaluate:
  17. runs-on: ubuntu-latest
  18. steps:
  19. - name: Checkout base ref (original)
  20. uses: actions/checkout@v2
  21. with:
  22. ref: ${{ github.base_ref }}
  23. path: base
  24. - name: Checkout head ref (modified)
  25. uses: actions/checkout@v2
  26. with:
  27. ref: ${{ github.head_ref }}
  28. path: head
  29. - name: Cache promptfoo data
  30. id: cache
  31. uses: actions/cache@v2
  32. with:
  33. path: ~/.cache/promptfoo
  34. key: ${{ runner.os }}-promptfoo-${{ hashFiles('**/package-lock.json') }}
  35. restore-keys: |
  36. ${{ runner.os }}-promptfoo-
  37. - name: Checkout head ref (modified)
  38. uses: actions/checkout@v2
  39. with:
  40. ref: ${{ github.head_ref }}
  41. path: head
  42. - name: Cache promptfoo data
  43. id: cache
  44. uses: actions/cache@v2
  45. with:
  46. path: ~/.cache/promptfoo
  47. key: ${{ runner.os }}-promptfoo-${{ hashFiles('**/package-lock.json') }}
  48. restore-keys: |
  49. ${{ runner.os }}-promptfoo-
  50. - name: Set up Node.js
  51. uses: actions/setup-node@v2
  52. with:
  53. node-version: 16
  54. - name: Run promptfoo evaluation
  55. id: eval
  56. env:
  57. OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
  58. PROMPTFOO_CACHE_PATH: ~/.cache/promptfoo
  59. run: |
  60. npx promptfoo eval -c head/prompts/promptfooconfig.yaml --prompts base/prompts/prompt1.json head/prompts/prompt1.json -o output.json --share
  61. echo "OUTPUT_JSON_PATH=$GITHUB_WORKSPACE/output.json" >> $GITHUB_ENV
  62. - name: Comment PR
  63. uses: actions/github-script@v6
  64. with:
  65. github-token: ${{secrets.GITHUB_TOKEN}}
  66. script: |
  67. const fs = require('fs');
  68. const output = JSON.parse(fs.readFileSync(process.env.OUTPUT_JSON_PATH, 'utf8'));
  69. const body = `⚠️ LLM prompt was modified.\n\n| Success | Failure |\n|---------|---------|\n| ${output.results.stats.successes} | ${output.results.stats.failures} |\n\n**» [View eval results](${output.shareableUrl}) «**`;
  70. github.rest.issues.createComment({
  71. issue_number: context.issue.number,
  72. owner: context.repo.owner,
  73. repo: context.repo.repo,
  74. body: body
  75. });
Tip!

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

Comments

Loading...