abetlen / abetlen/llama-cpp-python
how to make multiple inference requests from a single model object
- Linguagem predominante
- Python
- Estrelas
- 10.6k
- Forks
- 1.4k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
```
def generate_response_stream(_model, _messages, _max_tokens=8192):
_stream = _model.create_chat_completion(
_messages,
stop=["<|eot_id|>", "<|end_of_text|>"],
max_tokens=_max_tokens,
stream=True
)
for chunk in _stream:
if 'role' in chunk["choices"][0]['delta'].keys():
yield chunk["choices"][0]['delta']['role']+':'
elif 'content' in chunk["choices"][0]['delta'].keys():
yield chunk["choices"][0]['delta']['content']
@router.post("/llm_generator")
async def llm_post(guideIn: LLMRequest):
try:
jsonString = {**guideIn.dict()}
messages=jsonString['messages']
async with lock:
return StreamingResponse(model.generate_response_stream(messages),media_type="text/plain")
```
The service crashed after two concurrent requests were made, and there were no error messages.

problem that has been bothering me for a long time.
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.