LlamaCpp truncates the response from LLM, and CTransformers gives a token overrun error

### System Info

Ubuntu: 22.04.3 LTS
python: 3.10
pip: 22.0.2
langchain: 0.0.319
vector stores: faiss
llm model: llama-2-13b-chat.Q4_K_M.gguf and mistral-7b-openorca.Q4_K_M.gguf
embeddings model: thenlper/gte-large

### Who can help?

anyone

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [X] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

1. Prompt is created via PromptTemplate.
In Prompt:
```
You are a financial consultant. Try to answer the question based on the information below. 
If you cannot answer the question based on the information, say that you cannot find the answer or are unable to find the answer.
Therefore, try to understand the context of the question and answer only on the basis of the information given. Do not write answers that are irrelevant.
If you do not have enough information to end a sentence with a period, then do not write that sentence.

Context: {context}
Question: {question}

Helpful answer:
```

2. Load vectoron storage using HuggingFaceEmbeddings and FAISS:
```
embeddings = HuggingFaceEmbeddings(model_name="thenlper/gte-large", model_kwargs={'device': 'cpu'})
db = FAISS.load_local(persist_directory, embeddings)
retriever = db.as_retriever(search_kwargs={"k": 2})
```

3. Load the LLM via LlamaCpp or CTransformers
LlamaCpp code:
```
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])

llm = LlamaCpp(
    model_path=model_path,
    n_gpu_layers=-1,
    use_mlock=True,
    n_batch=512,
    n_ctx=2048,
    temperature=0.8,
    f16_kv=True,
    callback_manager=callback_manager,
    verbose=True,
    top_k=1
)
```

CTransformers Code:
```
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])

llm = CTransformers(
    model=model_path,
    model_type="llama",
    config={'max_new_tokens': 2048, 'temperature': 0.8},
    callbacks=callback_manager
)
```

4. Create Retriever using RetrievalQA:
```
qa = RetrievalQA.from_chain_type(
    llm=llm,
    chain_type="stuff",
    retriever=retriever,
    return_source_documents=return_source_documents,
    chain_type_kwargs={"prompt": custom_prompt}
)
```

5. Query the created retriever: qa("your question")

### Expected behavior

I look forward to receiving a completed response from LLM.

However, when using LlamaCpp, the response reaches about 1000 characters and ends. The last sentence from LLM is abruptly cut off.

When CTransformers are used, the response can reach different lengths, after which an error occurs: "Number of tokens (513) exceeded maximum context length (512)" and there are many of these errors. After that I get a response where the beginning is correct and then the same words are repeated. The repetition of words starts from the moment the errors about the number of tokens begin.