import requests
import json
BASE_URL = "https://orch.zenbase.ai/api"
API_KEY = "YOUR ZENBASE API KEY"
def api_call(method, endpoint, data=None):
url = f"{BASE_URL}/{endpoint}"
headers = {
"Content-Type": "application/json",
"Authorization": f"Api-Key {API_KEY}"
}
response = requests.request(method, url, headers=headers, data=json.dumps(data) if data else None)
return response
optimizer_data = {
"function": function_id,
"train_set": train_dataset_id,
"validation_set": validation_dataset_id,
"test_set": test_dataset_id,
"parameters": {
"shots": 5,
"samples": 5,
"model_keywords": {
"temperature": 0.5
},
"custom_evaluator": {
"type": "llm_as_judge",
"prompt": "Compare the model's output with the expected output. Determine if they are semantically equivalent, even if worded differently. Respond in JSON with 'reasoning' (list of points) and 'passed' (boolean).",
},
},
"schedule": {
"cron": "*/5 * * * *"
},
"api_key": API_KEY,
"model": "MODEL_NAME",
"optimizer_type": "fewshot",
}
optimizer = api_call("POST", "optimizer-configurations/", optimizer_data)
optimizer_id = optimizer.json()['id']