[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthenticationError #844

Open
AprilJoy opened this issue Jun 23, 2024 · 2 comments
Open

AuthenticationError #844

AprilJoy opened this issue Jun 23, 2024 · 2 comments

Comments

@AprilJoy
Copy link

❗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
Copy link
Contributor

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

@AprilJoy
Copy link
Author

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants