Commit 82b4747b authored by Baber's avatar Baber
Browse files

nit

parent 1efafe22
......@@ -7,6 +7,8 @@ import requests
# from api_model import make_concurrent_requests
from Levenshtein import distance
from lm_eval.models.utils import retry_on_specific_exceptions
API_KEY = os.getenv("OPENAI_API_KEY")
assert API_KEY is not None, (
......@@ -58,8 +60,10 @@ Extracted answer: B
# Function to send a single request to the OpenAI API
@retry_on_specific_exceptions(
on_exceptions=[requests.exceptions.RequestException], max_retries=5
)
def send_request(prompt: str):
try:
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
......@@ -76,10 +80,6 @@ def send_request(prompt: str):
result = response.json()
return result["choices"][0]["message"]["content"]
except Exception as e:
print(f"An error occurred while requesting: {e}")
return None
def create_test_prompt(demo_prompt, query, response):
demo_prompt = demo_prompt.strip()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment