MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / generate

Function generate

examples/server/api_like_OAI.py:176–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

174 return jsonify(resData)
175 else:
176 def generate():
177 data = requests.request("POST", urllib.parse.urljoin(args.llama_api, "/completion"), data=json.dumps(postData), stream=True)
178 time_now = int(time.time())
179 resData = make_resData_stream({}, chat=True, time_now=time_now, start=True)
180 yield 'data: {}\n'.format(json.dumps(resData))
181 for line in data.iter_lines():
182 if line:
183 decoded_line = line.decode('utf-8')
184 resData = make_resData_stream(json.loads(decoded_line[6:]), chat=True, time_now=time_now)
185 yield 'data: {}\n'.format(json.dumps(resData))
186 return Response(generate(), mimetype='text/event-stream')
187
188

Callers 2

chat_completionsFunction · 0.70
completionFunction · 0.70

Calls 4

make_resData_streamFunction · 0.85
timeMethod · 0.80
formatMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected