Repository: promptfoo/promptfoo
Issue: Use embedding from AzureOpenAI
Root cause: Configuration Error

I am trying to add a "similar" assert type:

      - type: similar
        value: 'The expected output'
        threshold: 0.8

I have seem in the cocumentation that by default, embeddings are computed via OpenAI's text-embedding-ada-002 model. As you know I am using AzureOpenAI. H**ow can I set up my defaultTest  to use an AzureOpenAI embedding?** 

Below my yaml: is it a wrong setup? i have doubts with the defaultTest configuration, Do I need to pass again the provider?

```
prompts: [prompt1.txt, prompt2.txt]
providers:
  - id: azureopenai:chat:test-gpt4
    config:
      apiHost: testing.openai.azure.com
      apiKey: XXXXXXXXXXXXXXXXXXXXXXXX
      temperature: 0
      max_tokens: 50
evaluateOptions: { cache: false }
defaultTest::
  assert:
    - type: javascript
      value: Math.max(0, Math.min(1, 1 - (output.length - 100) / 900))
  options:
    provider:
       text:
         id: azureopenai:chat:test-gpt4
         config:
           apiHost: testing.openai.azure.com
           apiKey: XXXXXXXXXXXXXXXXXXXXXXXX
    embedding:
        id: azureopenai:text-embedding-ada-002
        config:
          apiHost: testing.openai.azure.com
          apiKey: XXXXXXXXXXXXXXXXXXXXXXXX
tests:
  - vars:
      query: <myquery>?
      context: file://docs/doc.md
    assert:
      - type: contains-all
        value:
          - 'Client 1'
          - 'Client 2'
      - type: contains
        value: $10 and $1
      - type: contains-any
        value:
          - 'Client 1'
          - 'Client 2'
          - 'Client 3'
      - type: equals 
        value: '<<value>>'
      - type: rouge-n
        threshold: 0.9
        value: <<Summary goes here!!>>
      - type: latency
        threshold: 18000
      - type: factuality
        value: <<tetxt goes here>>
      - type: similar
        value: 'The expected output'
        threshold: 0.8

```

I think you may have an indentation error.  The `embedding` property should be under `provider`

Thanks @typpo for the quick response 

With the correct indentation

```
defaultTest:
  options:
    provider:
      text:
        id: azureopenai:chat:test-gpt4
        config:
          apiHost: testing.openai.azure.com
          apiKey: XXXXXXXXXXXXXXXXXXXXXXXX
      embedding:
        - id: azureopenai:text-embedding-ada-002
          config:
            apiHost: testing.openai.azure.com
            apiKey: XXXXXXXXXXXXXXXXXXXXXXXX
  assert: #Let's also add a heuristic that prefers shorter outputs
    - type: javascript
      value: Math.max(0, Math.min(1, 1 - (output.length - 100) / 900))
```

I am getting this error:

```
Error: Invalid provider definition for output type 'embedding': [
  {
    "id": "azureopenai:text-embedding-ada-002",
    "config": {
      "apiHost": "testing.openai.azure.com",
      "apiKey": "XXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
  }
]

Error: Invalid provider definition for output type 'embedding': [
  {
    "id": "azureopenai:text-embedding-ada-002",
    "config": {
      "apiHost": "testing.openai.azure.com",
      "apiKey": "XXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
  }
]
    at getGradingProvider (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\matchers.js:65:19)
    at getGradingProvider (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\matchers.js:58:35)
    at getAndCheckProvider (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\matchers.js:75:31)
    at matchesSimilarity (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\matchers.js:111:32)
    at runAssertion (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\assertions.js:604:56)
    at runAssertions (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\assertions.js:73:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Evaluator.runEval (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\evaluator.js:210:37)
    at async C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\evaluator.js:475:25

```

Assuming you have created an Ada deployment in your Azure OAI dashboard, you'll have to specify the provider like this:

```
azureopenai:embedding:your-deployment-name
```

The `azureopenai:embedding` prefix tells the runner that it's an embedding model.

I have tried and this is the current error: it seem its trying to use OpenAI instead of Azure embedding

```
defaultTest:
  options:
    provider:
      id: azureopenai:chat:test-gpt4
      config:
        apiHost: testing.openai.azure.com
        apiKey: XXXXXXXXXXXXXXXXXX
    embedding:
      - id: azureopenai:embedding:text-embedding-ada-002
        config:
          apiHost: testing.openai.azure.com
          apiKey: XXXXXXXXXXXXXXXXXX

```

```
PS C:\Users\user\code> promptfoo eval
Cache is disabled.
Provider azureopenai:chat:test-gpt4 does not implement callEmbeddingApi for 'similarity check', falling back to default
Incorrect API key provided: sk-uO7XF***************************************LVXy. You can find your API key at https://platform.openai.com/account/api-keys.
```

```
Error: No embedding found in OpenAI embeddings API response

Error: No embedding found in OpenAI embeddings API response
    at OpenAiEmbeddingProvider.callEmbeddingApi (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\providers\openai.js:86:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async matchesSimilarity (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\matchers.js:112:31)
    at async runAssertion (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\assertions.js:604:17)
    at async runAssertions (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\assertions.js:73:24)
    at async Evaluator.runEval (C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\evaluator.js:210:37)
    at async C:\Users\user\AppData\Roaming\npm\node_modules\promptfoo\dist\src\evaluator.js:475:25

```


Your indentation of the `embedding` key got messed up again :)

That's true!! sorry now works :-) thanks a lot!!