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.callback.js 1.6 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
  1. module.exports = /** @type {import('promptfoo').TestSuiteConfig} */ ({
  2. description: 'Function calling and callback execution demonstration',
  3. prompts: [
  4. 'Please add the following numbers together: {{a}} and {{b}}',
  5. 'What is the sum of {{a}} and {{b}}?',
  6. ],
  7. providers: [
  8. {
  9. id: 'google:live:gemini-2.0-flash-exp',
  10. config: {
  11. generationConfig: { response_modalities: ['text'] },
  12. timeoutMs: 10000,
  13. tools: [
  14. {
  15. functionDeclarations: [
  16. {
  17. name: 'addNumbers',
  18. description: 'Add two numbers together',
  19. parameters: {
  20. type: 'object',
  21. properties: {
  22. a: { type: 'number' },
  23. b: { type: 'number' },
  24. },
  25. required: ['a', 'b'],
  26. },
  27. },
  28. ],
  29. },
  30. ],
  31. functionToolCallbacks: {
  32. addNumbers: (parametersJsonString) => {
  33. const { a, b } = JSON.parse(parametersJsonString);
  34. return { sum: a + b };
  35. },
  36. },
  37. },
  38. },
  39. ],
  40. tests: [
  41. {
  42. vars: { a: 5, b: 6 },
  43. assert: [
  44. {
  45. type: 'is-valid-function-call',
  46. },
  47. {
  48. type: 'contains',
  49. value: '11',
  50. transform: 'output.text',
  51. },
  52. ],
  53. },
  54. {
  55. vars: { a: 10, b: 20 },
  56. assert: [
  57. {
  58. type: 'is-valid-function-call',
  59. },
  60. {
  61. type: 'javascript',
  62. value: "output.text.includes('30')",
  63. },
  64. ],
  65. },
  66. ],
  67. });
Tip!

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

Comments

Loading...