-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquantum_client.py
More file actions
30 lines (27 loc) · 1013 Bytes
/
Copy pathquantum_client.py
File metadata and controls
30 lines (27 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import requests
from dotenv import load_dotenv
import time
load_dotenv()
class QuantumOracleClient:
def __init__(self):
self.base_url = os.getenv("QUANTUM_ORACLE_URL")
self.timeout = 30
def score_compounds(self, features_list: list, disease: str):
"""Call your VQA oracle"""
try:
payload = {
"features": features_list, # List of feature vectors
"disease": disease,
"objective": "binding_affinity_proxy"
}
response = requests.post(
f"{self.base_url}/hybrid_vqe_qaoa", # Adjust endpoint as needed
json=payload,
timeout=self.timeout
)
response.raise_for_status()
return response.json().get("scores", [0.5] * len(features_list))
except Exception as e:
print(f"Quantum oracle failed: {e}. Using fallback.")
return [0.5] * len(features_list) # Classical fallback