|
| 1 | +description: Test chunk text summarization in different languages |
| 2 | + |
| 3 | +providers: |
| 4 | + - openai:chat:gpt-5-mini |
| 5 | + - openai:chat:claude-3-5-haiku-latest |
| 6 | + - openai:chat:gemini-flash-latest |
| 7 | + - openai:chat:deepseek-chat |
| 8 | + |
| 9 | +prompts: |
| 10 | + - file://promptfoo/abstract-chunk/prompt.ts |
| 11 | + |
| 12 | +tests: |
| 13 | + # English technical content |
| 14 | + - vars: |
| 15 | + text: "React is a JavaScript library for building user interfaces. It was developed by Facebook and is now maintained by Facebook and the community. React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable and easier to debug." |
| 16 | + assert: |
| 17 | + - type: llm-rubric |
| 18 | + provider: openai:gpt-5-mini |
| 19 | + value: "The summary should be 1-2 sentences in English, capturing the main topic about React being a JavaScript library for UIs" |
| 20 | + - type: contains-any |
| 21 | + value: ["React", "JavaScript", "library", "UI", "user interface"] |
| 22 | + - type: javascript |
| 23 | + value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2" # At most 2 sentences |
| 24 | + |
| 25 | + # Chinese content |
| 26 | + - vars: |
| 27 | + text: "深度学习是机器学习的一个分支,它使用多层神经网络来学习数据的表示。近年来,深度学习在图像识别、自然语言处理、语音识别等领域取得了突破性进展。卷积神经网络(CNN)在计算机视觉任务中表现优异,而循环神经网络(RNN)和Transformer架构在序列建模任务中非常有效。" |
| 28 | + assert: |
| 29 | + - type: llm-rubric |
| 30 | + provider: openai:gpt-5-mini |
| 31 | + value: "The summary should be 1-2 sentences in Chinese, summarizing deep learning and its applications" |
| 32 | + - type: contains-any |
| 33 | + value: ["深度学习", "神经网络", "机器学习"] |
| 34 | + - type: not-contains |
| 35 | + value: "摘要" # Should not contain meta labels |
| 36 | + - type: javascript |
| 37 | + value: "output.split(/[。!?]/).filter(s => s.trim()).length <= 2" # At most 2 sentences |
| 38 | + |
| 39 | + # Japanese content |
| 40 | + - vars: |
| 41 | + text: "人工知能(AI)は、コンピュータシステムが人間の知能を模倣する技術です。AIは、学習、推論、問題解決などの認知機能を実行できます。現代のAIシステムは、大量のデータから学習し、パターンを認識して予測を行います。" |
| 42 | + assert: |
| 43 | + - type: llm-rubric |
| 44 | + provider: openai:gpt-5-mini |
| 45 | + value: "The summary should be 1-2 sentences in Japanese about artificial intelligence" |
| 46 | + - type: contains-any |
| 47 | + value: ["人工知能", "AI", "コンピュータ"] |
| 48 | + - type: javascript |
| 49 | + value: "output.split(/[。!?]/).filter(s => s.trim()).length <= 2" |
| 50 | + |
| 51 | + # Spanish content |
| 52 | + - vars: |
| 53 | + text: "El cambio climático es uno de los mayores desafíos que enfrenta la humanidad en el siglo XXI. Las temperaturas globales están aumentando debido a las emisiones de gases de efecto invernadero producidas por actividades humanas como la quema de combustibles fósiles, la deforestación y la agricultura industrial. Los efectos incluyen el derretimiento de los glaciares, el aumento del nivel del mar y eventos climáticos extremos más frecuentes." |
| 54 | + assert: |
| 55 | + - type: llm-rubric |
| 56 | + provider: openai:gpt-5-mini |
| 57 | + value: "The summary should be 1-2 sentences in Spanish about climate change" |
| 58 | + - type: contains-any |
| 59 | + value: ["cambio climático", "temperatura", "clima"] |
| 60 | + - type: javascript |
| 61 | + value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2" |
| 62 | + |
| 63 | + # Short technical content (English) |
| 64 | + - vars: |
| 65 | + text: "TypeScript is a strongly typed programming language that builds on JavaScript. It adds static type definitions to JavaScript, making code more robust and maintainable." |
| 66 | + assert: |
| 67 | + - type: llm-rubric |
| 68 | + provider: openai:gpt-5-mini |
| 69 | + value: "The summary should be 1-2 sentences in English about TypeScript" |
| 70 | + - type: contains-any |
| 71 | + value: ["TypeScript", "JavaScript", "type"] |
| 72 | + - type: javascript |
| 73 | + value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2" |
| 74 | + |
| 75 | + # Mixed technical terms in Chinese |
| 76 | + - vars: |
| 77 | + text: "Docker 是一个开源的容器化平台,它允许开发者将应用程序及其依赖项打包到一个可移植的容器中。通过使用 Docker,可以确保应用在任何环境中都能一致地运行。Docker 容器比传统虚拟机更轻量级,启动速度更快,资源占用更少。" |
| 78 | + assert: |
| 79 | + - type: llm-rubric |
| 80 | + provider: openai:gpt-5-mini |
| 81 | + value: "The summary should be 1-2 sentences in Chinese, keeping 'Docker' in English" |
| 82 | + - type: contains |
| 83 | + value: "Docker" # Technical term should be preserved |
| 84 | + - type: contains-any |
| 85 | + value: ["容器", "平台", "应用"] |
| 86 | + - type: javascript |
| 87 | + value: "output.split(/[。!?]/).filter(s => s.trim()).length <= 2" |
| 88 | + |
| 89 | + # German content |
| 90 | + - vars: |
| 91 | + text: "Die Quantenphysik ist ein fundamentaler Zweig der Physik, der sich mit dem Verhalten von Materie und Energie auf atomarer und subatomarer Ebene befasst. Im Gegensatz zur klassischen Physik beschreibt die Quantenphysik Phänomene, bei denen Teilchen sowohl Wellen- als auch Teilcheneigenschaften aufweisen können." |
| 92 | + assert: |
| 93 | + - type: llm-rubric |
| 94 | + provider: openai:gpt-5-mini |
| 95 | + value: "The summary should be 1-2 sentences in German about quantum physics" |
| 96 | + - type: contains-any |
| 97 | + value: ["Quantenphysik", "Physik", "Materie"] |
| 98 | + - type: javascript |
| 99 | + value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2" |
| 100 | + |
| 101 | + # Code snippet in content (English) |
| 102 | + - vars: |
| 103 | + text: "The useState hook in React allows you to add state to functional components. For example: const [count, setCount] = useState(0). This creates a state variable 'count' with initial value 0 and a setter function 'setCount' to update it." |
| 104 | + assert: |
| 105 | + - type: llm-rubric |
| 106 | + provider: openai:gpt-5-mini |
| 107 | + value: "The summary should be 1-2 sentences in English about useState hook, may preserve code syntax" |
| 108 | + - type: contains-any |
| 109 | + value: ["useState", "React", "state", "hook"] |
| 110 | + - type: javascript |
| 111 | + value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2" |
0 commit comments