Zum Hauptinhalt springen

Documentation Index

Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt

Use this file to discover all available pages before exploring further.

Promptfoo ist ein Framework für Prompt-Auswertung, Regressionstests und AI-Red-Teaming. Promptfoo enthält einen cometapi-Provider, der CometAPI über OpenAI-kompatible Endpunkte aufruft.

Voraussetzungen

Integration konfigurieren

1

Set your CometAPI API key

Setze COMETAPI_KEY, bevor du Auswertungen ausführst:
read -rsp "CometAPI API key: " COMETAPI_KEY
printf '\n'
export COMETAPI_KEY
2

Choose a provider format

Promptfoo verwendet das folgende Provider-ID-Format für CometAPI:
providers:
  - cometapi:<type>:<model>
Verwende diese Provider-Typen:
TypeUse case
chatChat Completions, Vision- und Multimodal-Prompts
completionText-Completion-Modelle
embeddingText-Embedding-Auswertungen
imageBildgenerierungs-Auswertungen
Du kannst auch cometapi:your-model-id für den standardmäßigen Chat-Modus verwenden.
3

Run a CLI evaluation

Der folgende Befehl führt eine Chat-Auswertung mit einem Prompt aus:
npx promptfoo@latest eval \
  --prompts "Write a concise release note for {{feature}}" \
  --vars feature="a unified API dashboard" \
  -r cometapi:chat:your-model-id
4

Create a Promptfoo config file

Die folgende promptfooconfig.yaml wertet denselben Prompt gegen ein CometAPI-Modell aus:
prompts:
  - "Classify this support request: {{message}}"

providers:
  - id: cometapi:chat:your-model-id
    config:
      temperature: 0.2
      max_tokens: 256

tests:
  - vars:
      message: "The API key works locally but fails in production."
    assert:
      - type: contains-any
        value:
          - authentication
          - configuration
Führe die Konfigurationsdatei mit Promptfoo aus:
npx promptfoo@latest eval -c promptfooconfig.yaml

Provider-Beispiele

Verwende einen Provider-Typ, der zum Modellverhalten passt, das du auswerten möchtest:
providers:
  - cometapi:chat:your-model-id
  - cometapi:completion:your-model-id
  - cometapi:embedding:your-model-id
  - cometapi:image:your-model-id
Für Multimodal-Tests behältst du den Provider-Typ chat bei und übergibst Bildvariablen über Promptfoo-Testvariablen.

Fehlerbehebung

Stelle sicher, dass COMETAPI_KEY in derselben Shell-Sitzung exportiert ist, in der promptfoo eval ausgeführt wird.
Verwende chat für konversationelle und Multimodal-Modelle, embedding für Embedding-Modelle und image für Bildgenerierungs-Modelle.
Ersetze your-model-id durch eine exakte model ID von der CometAPI Models-Seite.

Verwandte Ressourcen