Connection
Base URL, credentials and a reachable server.
Choose between JSON and plain text using already parsed Accept ranges.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
def choose_media(ranges):
offered = ["application/json", "text/plain"]
if not ranges:
return offered[0]
choices = []
for i, media in enumerate(offered):
family = media.split("/")[0] + "/*"
matches = [(2 if p == media else 1 if p == family else 0, q)
for p, q in ranges if p in (media, family, "*/*")]
quality = max(matches, default=(-1, 0))[1]
if quality > 0:
choices.append((quality, -i, media))
return max(choices)[2] if choices else None