Skip to content

Commit 4528c55

Browse files
author
Dylan Huang
committed
revert
1 parent 04a2a2f commit 4528c55

8 files changed

Lines changed: 121 additions & 699 deletions

File tree

eval_protocol/adapters/fireworks_tracing.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,12 @@ def search_logs(self, tags: List[str], limit: int = 100, hours_back: int = 24) -
273273
if not tags:
274274
raise ValueError("At least one tag is required to fetch logs")
275275

276-
headers = {"Authorization": f"Bearer {os.environ.get('FIREWORKS_API_KEY')}"}
276+
from ..common_utils import get_user_agent
277+
278+
headers = {
279+
"Authorization": f"Bearer {os.environ.get('FIREWORKS_API_KEY')}",
280+
"User-Agent": get_user_agent(),
281+
}
277282
params: Dict[str, Any] = {"tags": tags, "limit": limit, "hours_back": hours_back, "program": "eval_protocol"}
278283

279284
# Try /logs first, fall back to /v1/logs if not found
@@ -398,7 +403,12 @@ def get_evaluation_rows(
398403
else:
399404
url = f"{self.base_url}/v1/traces/pointwise"
400405

401-
headers = {"Authorization": f"Bearer {os.environ.get('FIREWORKS_API_KEY')}"}
406+
from ..common_utils import get_user_agent
407+
408+
headers = {
409+
"Authorization": f"Bearer {os.environ.get('FIREWORKS_API_KEY')}",
410+
"User-Agent": get_user_agent(),
411+
}
402412

403413
result = None
404414
try:

eval_protocol/auth.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from pathlib import Path
55
from typing import Dict, Optional # Added Dict
66

7+
import requests
8+
79
logger = logging.getLogger(__name__)
810

911
# Default locations (used for tests and as fallback). Actual resolution is dynamic via _get_auth_ini_file().
@@ -240,11 +242,16 @@ def verify_api_key_and_get_account_id(
240242
if not resolved_key:
241243
return None
242244
resolved_base = api_base or get_fireworks_api_base()
243-
244-
from .fireworks_api_client import FireworksAPIClient
245-
client = FireworksAPIClient(api_key=resolved_key, api_base=resolved_base)
246-
resp = client.get("verifyApiKey", timeout=10)
247-
245+
246+
from .common_utils import get_user_agent
247+
248+
url = f"{resolved_base.rstrip('/')}/verifyApiKey"
249+
headers = {
250+
"Authorization": f"Bearer {resolved_key}",
251+
"User-Agent": get_user_agent(),
252+
}
253+
resp = requests.get(url, headers=headers, timeout=10)
254+
248255
if resp.status_code != 200:
249256
logger.debug("verifyApiKey returned status %s", resp.status_code)
250257
return None

eval_protocol/evaluation.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
get_fireworks_api_key,
2121
verify_api_key_and_get_account_id,
2222
)
23-
from eval_protocol.fireworks_api_client import FireworksAPIClient
23+
from eval_protocol.common_utils import get_user_agent
2424
from eval_protocol.typed_interface import EvaluationMode
2525

2626
from eval_protocol.get_pep440_version import get_pep440_version
@@ -402,15 +402,20 @@ def preview(self, sample_file, max_samples=5):
402402
if "dev.api.fireworks.ai" in api_base and account_id == "fireworks":
403403
account_id = "pyroworks-dev"
404404

405-
client = FireworksAPIClient(api_key=auth_token, api_base=api_base)
406-
path = f"v1/accounts/{account_id}/evaluators:previewEvaluator"
407-
408-
logger.info(f"Previewing evaluator using API endpoint: {api_base}/{path} with account: {account_id}")
405+
url = f"{api_base}/v1/accounts/{account_id}/evaluators:previewEvaluator"
406+
headers = {
407+
"Authorization": f"Bearer {auth_token}",
408+
"Content-Type": "application/json",
409+
"User-Agent": get_user_agent(),
410+
}
411+
logger.info(f"Previewing evaluator using API endpoint: {url} with account: {account_id}")
412+
logger.debug(f"Preview API Request URL: {url}")
413+
logger.debug(f"Preview API Request Headers: {json.dumps(headers, indent=2)}")
409414
logger.debug(f"Preview API Request Payload: {json.dumps(payload, indent=2)}")
410415

411416
global used_preview_api
412417
try:
413-
response = client.post(path, json=payload)
418+
response = requests.post(url, json=payload, headers=headers)
414419
response.raise_for_status()
415420
result = response.json()
416421
used_preview_api = True
@@ -741,25 +746,29 @@ def create(self, evaluator_id, display_name=None, description=None, force=False)
741746
if "dev.api.fireworks.ai" in self.api_base and account_id == "fireworks":
742747
account_id = "pyroworks-dev"
743748

744-
client = FireworksAPIClient(api_key=auth_token, api_base=self.api_base)
745-
path = f"v1/{parent}/evaluatorsV2"
749+
base_url = f"{self.api_base}/v1/{parent}/evaluatorsV2"
750+
headers = {
751+
"Authorization": f"Bearer {auth_token}",
752+
"Content-Type": "application/json",
753+
"User-Agent": get_user_agent(),
754+
}
746755

747756
self._ensure_requirements_present(os.getcwd())
748757

749758
logger.info(f"Creating evaluator '{evaluator_id}' for account '{account_id}'...")
750759

751760
try:
752761
if force:
753-
check_path = f"v1/{parent}/evaluators/{evaluator_id}"
762+
check_url = f"{self.api_base}/v1/{parent}/evaluators/{evaluator_id}"
754763
try:
755-
logger.info(f"Checking if evaluator exists: {self.api_base}/{check_path}")
756-
check_response = client.get(check_path)
764+
logger.info(f"Checking if evaluator exists: {check_url}")
765+
check_response = requests.get(check_url, headers=headers)
757766

758767
if check_response.status_code == 200:
759768
logger.info(f"Evaluator '{evaluator_id}' already exists, deleting and recreating...")
760-
delete_path = f"v1/{parent}/evaluators/{evaluator_id}"
769+
delete_url = f"{self.api_base}/v1/{parent}/evaluators/{evaluator_id}"
761770
try:
762-
delete_response = client.delete(delete_path)
771+
delete_response = requests.delete(delete_url, headers=headers)
763772
if delete_response.status_code < 400:
764773
logger.info(f"Successfully deleted evaluator '{evaluator_id}'")
765774
else:
@@ -768,14 +777,14 @@ def create(self, evaluator_id, display_name=None, description=None, force=False)
768777
)
769778
except Exception as e_del:
770779
logger.warning(f"Error deleting evaluator: {str(e_del)}")
771-
response = client.post(path, json=payload_data)
780+
response = requests.post(base_url, json=payload_data, headers=headers)
772781
else:
773-
response = client.post(path, json=payload_data)
782+
response = requests.post(base_url, json=payload_data, headers=headers)
774783
except requests.exceptions.RequestException:
775-
response = client.post(path, json=payload_data)
784+
response = requests.post(base_url, json=payload_data, headers=headers)
776785
else:
777-
logger.info(f"Creating evaluator at: {self.api_base}/{path}")
778-
response = client.post(path, json=payload_data)
786+
logger.info(f"Creating evaluator at: {base_url}")
787+
response = requests.post(base_url, json=payload_data, headers=headers)
779788

780789
response.raise_for_status()
781790
result = response.json()
@@ -800,11 +809,11 @@ def create(self, evaluator_id, display_name=None, description=None, force=False)
800809
tar_size = self._create_tar_gz_with_ignores(tar_path, cwd)
801810

802811
# Call GetEvaluatorUploadEndpoint
803-
upload_endpoint_path = f"v1/{evaluator_name}:getUploadEndpoint"
812+
upload_endpoint_url = f"{self.api_base}/v1/{evaluator_name}:getUploadEndpoint"
804813
upload_payload = {"name": evaluator_name, "filename_to_size": {tar_filename: tar_size}}
805814

806815
logger.info(f"Requesting upload endpoint for {tar_filename}")
807-
upload_response = client.post(upload_endpoint_path, json=upload_payload)
816+
upload_response = requests.post(upload_endpoint_url, json=upload_payload, headers=headers)
808817
upload_response.raise_for_status()
809818

810819
# Check for signed URLs
@@ -884,9 +893,9 @@ def create(self, evaluator_id, display_name=None, description=None, force=False)
884893
raise
885894

886895
# Step 3: Validate upload
887-
validate_path = f"v1/{evaluator_name}:validateUpload"
896+
validate_url = f"{self.api_base}/v1/{evaluator_name}:validateUpload"
888897
validate_payload = {"name": evaluator_name}
889-
validate_response = client.post(validate_path, json=validate_payload)
898+
validate_response = requests.post(validate_url, json=validate_payload, headers=headers)
890899
validate_response.raise_for_status()
891900

892901
validate_data = validate_response.json()

eval_protocol/fireworks_api_client.py

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)