mirror of
https://github.com/katanemo/plano.git
synced 2026-06-17 15:25:17 +02:00
24 lines
660 B
Python
24 lines
660 B
Python
import os
|
|
|
|
|
|
PROMPT_GATEWAY_ENDPOINT = os.getenv(
|
|
"PROMPT_GATEWAY_ENDPOINT", "http://localhost:10000/v1/chat/completions"
|
|
)
|
|
LLM_GATEWAY_ENDPOINT = os.getenv(
|
|
"LLM_GATEWAY_ENDPOINT", "http://localhost:12000/v1/chat/completions"
|
|
)
|
|
|
|
|
|
def get_data_chunks(stream, n=1):
|
|
chunks = []
|
|
for chunk in stream.iter_lines():
|
|
if chunk:
|
|
chunk = chunk.decode("utf-8")
|
|
chunk_data_id = chunk[0:6]
|
|
assert chunk_data_id == "data: "
|
|
chunk_data = chunk[6:]
|
|
chunk_data = chunk_data.strip()
|
|
chunks.append(chunk_data)
|
|
if len(chunks) >= n:
|
|
break
|
|
return chunks
|