confident-ai / deepeval

The LLM Evaluation Framework
https://docs.confident-ai.com/
Apache License 2.0
2.78k stars 200 forks source link

AuthenticationError #844

Open AprilJoy opened 2 months ago

AprilJoy commented 2 months ago

❗BEFORE YOU BEGIN❗ Are you on discord? 🤗 We'd love to have you asking questions on discord instead: https://discord.com/invite/a3K9c8GRGt Yes

Describe the bug I get the error info: AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-*** You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}} I use the base_url setting, but where can I set the base_url? I did not find the method in toturial.

To Reproduce Steps to reproduce the behavior:

  1. My script is: os.environ["OPENAI_API_KEY"] = "xxxxx" from deepeval.metrics import SummarizationMetric metric = SummarizationMetric(threshold=0.5) metric.measure(test_case) print(metric.score) print(metric.reason) print(metric.is_successful())
  2. Run the script
  3. See error

Expected behavior How can I set the OPENAI configure "base_url" in the deepeval SDK?

Screenshots If applicable, add screenshots to help explain your problem.

image
penguine-ip commented 2 months ago

@AprilJoy Try calling the openai API on its own with this api key and see if you get the same error

AprilJoy commented 2 months ago

@penguine-ip

I used this and can get the correct respond.

import os import json from openai import OpenAI messages= [ {"role": "user", "content": "你好,一个高级工程师想学习 Azure,他已经有 10 年的开发经验,可以用哪些资料做参考"} ]

client = OpenAI(

api_key=os.environ.get("OPENAI_API_KEY"),

api_key= api_key, base_url = "https://burn.hair/v1" )

response = client.chat.completions.create(model="gpt-3.5-turbo", messages=messages ) print(response.choices[0].message)

Frankgu3528 commented 2 weeks ago

I encounter this problem too. I can't find a place to set base_url for api_key.