INNER CODE UNIT · Python
query_custom_api
ARCANGEL0/EVA · custom.py:6
def query_custom_api(history, endpoint=None, session=None, prompt=None):
target = endpoint or API_ENDPOINT
compiled_prompt = str(prompt or "").strip()
if not compiled_prompt:
for item in reversed(history):
if item.get("role") == "user":
compiled_prompt = str(item.get("content", "")).strip()
break
payload = {
"prompt": compiled_prompt,
"conversation": history,
"session": session,
}
r = requests.post(target, json=payload, timeout=None)
try:
data = r.json()