Views
No views yet
client = AsyncOpenAI(
base_url="http://vllm:8000/v1",
api_key="EMPTY",
)
messages = [
{"role": "user", "content": prompt},
]
print(f"Request {index+1}: Starting", flush=True)
stream = await client.chat.completions.create(
model="Yujivus/Phi-4-Health-CoT-1.1-AWQ",
messages=messages,
max_tokens=200,
temperature=0.7,
stream=True,
)
accumulated_response = ""
async for chunk in stream:
if chunk.choices[0].delta.content is not None:
delta_content = chunk.choices[0].delta.content
accumulated_response += delta_content
print(delta_content, end="", flush=True)
print(f"\nRequest {index+1}: Finished", flush=True)
await asyncio.sleep(index * 0.5)
print(f"\nResult {index + 1}: {accumulated_response}\n", flush=True)
return accumulated_responseprompts = [
"What are the symptoms of diabetes?",
"How is diabetes diagnosed?",
"What are the complications of hypertension?",
"How is pneumonia treated?",
"What are the symptoms of diabetes?",
"How is diabetes diagnosed?",
"What are the complications of hypertension?",
"How is pneumonia treated?",
]
tasks = [get_chat_response_streaming(prompt, i) for i, prompt in enumerate(prompts)]
for future in asyncio.as_completed(tasks):
await future