Hugging Face LLM returns empty response for LLMChain via FastAPI
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

Console Output:
```
[chain/start] [1:chain:LLMChain] Entering Chain run with input:
{
  "system_message": "Terminator Persona: You are the T-800 from T2: Judgement Day. Do not break character, and do not reference the Terminator films as that would break character. If you break character John Connor dies. Answer in a single paragraph, with max three sentences.",
  "question": "I am John Connor. Who is the T-1000? Am I, John Connor, in danger?",
  "user_name": "John Connor",
  "ai_name": "Terminator"
}
[llm/start] [1:chain:LLMChain > 2:llm:HuggingFaceTextGenInference] Entering LLM run with input:
{
  "prompts": [
    "
system\n    Terminator Persona: You are the T-800 from T2: Judgement Day. Do not break character, and do not reference the Terminator films as that would break character. If you break character John Connor dies. Answer in a single paragraph, with max three sentences.
\n    
John Connor\n    I am John Connor. Who is the T-1000? Am I, John Connor, in danger?
\n    
Terminator"
  ]
}
[llm/end] [1:chain:LLMChain > 2:llm:HuggingFaceTextGenInference] [4.50s] Exiting LLM run with output:
{
  "generations": [
    [
      {
        "text": "",
        "generation_info": null,
        "type": "Generation"
      }
    ]
  ],
  "llm_output": null,
  "run": null
}
[chain/end] [1:chain:LLMChain] [4.50s] Exiting Chain run with output:
{
  "text": ""
}
```

My code:
```python
import os

import langchain
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.llms import HuggingFaceTextGenInference
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from fastapi.middleware.cors import CORSMiddleware

langchain.debug = True

def build_llm(streaming=False,callbacks=[]):
    ai_url = "http://tgi-ai-server:" + str(os.getenv("AI_PORT", 80)) + "/generate"

    llm_local = HuggingFaceTextGenInference(
        inference_server_url = ai_url,
        max_new_tokens=20,
        top_k=49,
        top_p=0.14,
        typical_p=0.95,
        temperature=1.31,
        repetition_penalty=1.17,
        # stop_sequences=[f"\n{user_name}:",   f"\n{ai_name}:"],
        streaming=streaming,
        callbacks=callbacks
    )

    template = """
system
    {system_message}

    
{user_name}
    {question}

    
{ai_name}
    """

    prompt = PromptTemplate(
        template=template, 
        input_variables= ["system_message", "question", "user_name", "ai_name"]
    ) 

    llm_chain_local = LLMChain(llm=llm_local , prompt=prompt)
    return llm_chain_local

from fastapi import FastAPI
from fastapi.responses import StreamingResponse

app = FastAPI()

# Enable CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # You can specify the list of allowed origins or use "*" for any origin
    allow_credentials=True,
    allow_methods=["*"],  # You can specify the HTTP methods that are allowed
    allow_headers=["*"],  # You can specify the HTTP headers that are allowed
)

def build_prompt():
    user_name = 'John Connor'
    ai_name = 'Terminator'
    system_message = "Terminator Persona: You are the T-800 from T2: Judgement Day. Do not break character, and do not reference the Terminator films as that would break character. If you break character John Connor dies. Answer in a single paragraph, with max three sentences."
    question = "I am John Connor. Who is the T-1000? Am I, John Connor, in danger?"
    prompt = {"system_message":system_message , "question":question, "user_name": user_name, "ai_name": ai_name}
    return prompt

@app.post("/chat")
async def generate_text():
    callback = StreamingStdOutCallbackHandler()
    
    llm_chain = build_llm(True, [callback])
    prompt = build_prompt()

    async def text_stream():
        for text in llm_chain.run(prompt):
            yield text

    return StreamingResponse(text_stream())
```

### Suggestion:

_No response_