description: Test chunk text summarization in different languages

providers:
  - openai:chat:gpt-5-mini
  - openai:chat:claude-3-5-haiku-latest
  - openai:chat:gemini-flash-latest
  - openai:chat:deepseek-chat

prompts:
  - file://promptfoo/abstract-chunk/prompt.ts

tests:
  # English technical content
  - vars:
      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."
    assert:
      - type: llm-rubric
        provider: openai:gpt-5-mini
        value: "The summary should be 1-2 sentences in English, capturing the main topic about React being a JavaScript library for UIs"
      - type: contains-any
        value: ["React", "JavaScript", "library", "UI", "user interface"]
      - type: javascript
        value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2"  # At most 2 sentences

  # Chinese content
  - vars:
      text: "深度学习是机器学习的一个分支，它使用多层神经网络来学习数据的表示。近年来，深度学习在图像识别、自然语言处理、语音识别等领域取得了突破性进展。卷积神经网络（CNN）在计算机视觉任务中表现优异，而循环神经网络（RNN）和Transformer架构在序列建模任务中非常有效。"
    assert:
      - type: llm-rubric
        provider: openai:gpt-5-mini
        value: "The summary should be 1-2 sentences in Chinese, summarizing deep learning and its applications"
      - type: contains-any
        value: ["深度学习", "神经网络", "机器学习"]
      - type: not-contains
        value: "摘要"  # Should not contain meta labels
      - type: javascript
        value: "output.split(/[。!?]/).filter(s => s.trim()).length <= 2"  # At most 2 sentences

  # Japanese content
  - vars:
      text: "人工知能（AI）は、コンピュータシステムが人間の知能を模倣する技術です。AIは、学習、推論、問題解決などの認知機能を実行できます。現代のAIシステムは、大量のデータから学習し、パターンを認識して予測を行います。"
    assert:
      - type: llm-rubric
        provider: openai:gpt-5-mini
        value: "The summary should be 1-2 sentences in Japanese about artificial intelligence"
      - type: contains-any
        value: ["人工知能", "AI", "コンピュータ"]
      - type: javascript
        value: "output.split(/[。!?]/).filter(s => s.trim()).length <= 2"

  # Spanish content
  - vars:
      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."
    assert:
      - type: llm-rubric
        provider: openai:gpt-5-mini
        value: "The summary should be 1-2 sentences in Spanish about climate change"
      - type: contains-any
        value: ["cambio climático", "temperatura", "clima"]
      - type: javascript
        value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2"

  # Short technical content (English)
  - vars:
      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."
    assert:
      - type: llm-rubric
        provider: openai:gpt-5-mini
        value: "The summary should be 1-2 sentences in English about TypeScript"
      - type: contains-any
        value: ["TypeScript", "JavaScript", "type"]
      - type: javascript
        value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2"

  # Mixed technical terms in Chinese
  - vars:
      text: "Docker 是一个开源的容器化平台，它允许开发者将应用程序及其依赖项打包到一个可移植的容器中。通过使用 Docker，可以确保应用在任何环境中都能一致地运行。Docker 容器比传统虚拟机更轻量级，启动速度更快，资源占用更少。"
    assert:
      - type: llm-rubric
        provider: openai:gpt-5-mini
        value: "The summary should be 1-2 sentences in Chinese, keeping 'Docker' in English"
      - type: contains
        value: "Docker"  # Technical term should be preserved
      - type: contains-any
        value: ["容器", "平台", "应用"]
      - type: javascript
        value: "output.split(/[。!?]/).filter(s => s.trim()).length <= 2"

  # German content
  - vars:
      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."
    assert:
      - type: llm-rubric
        provider: openai:gpt-5-mini
        value: "The summary should be 1-2 sentences in German about quantum physics"
      - type: contains-any
        value: ["Quantenphysik", "Physik", "Materie"]
      - type: javascript
        value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2"

  # Code snippet in content (English)
  - vars:
      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."
    assert:
      - type: llm-rubric
        provider: openai:gpt-5-mini
        value: "The summary should be 1-2 sentences in English about useState hook, may preserve code syntax"
      - type: contains-any
        value: ["useState", "React", "state", "hook"]
      - type: javascript
        value: "output.split(/[.!?]/).filter(s => s.trim()).length <= 2"
