MCPcopy Index your code
hub / github.com/lm-sys/FastChat / fetch_remote

Function fetch_remote

fastchat/serve/openai_api_server.py:76–97  ·  view source on GitHub ↗
(url, pload=None, name=None)

Source from the content-addressed store, hash-verified

74
75
76async def fetch_remote(url, pload=None, name=None):
77 async with aiohttp.ClientSession(timeout=fetch_timeout) as session:
78 async with session.post(url, json=pload) as response:
79 chunks = []
80 if response.status != 200:
81 ret = {
82 "text": f"{response.reason}",
83 "error_code": ErrorCode.INTERNAL_ERROR,
84 }
85 return json.dumps(ret)
86
87 async for chunk, _ in response.content.iter_chunks():
88 chunks.append(chunk)
89 output = b"".join(chunks)
90
91 if name is not None:
92 res = json.loads(output)
93 if name != "":
94 res = res[name]
95 return res
96
97 return output
98
99
100class AppSettings(BaseSettings):

Callers 8

check_modelFunction · 0.85
check_lengthFunction · 0.85
get_worker_addressFunction · 0.85
get_convFunction · 0.85
show_available_modelsFunction · 0.85
generate_completionFunction · 0.85
get_embeddingFunction · 0.85
count_tokensFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…