Repository: explodinggradients/ragas
Issue: Incorrect Temperature Reset in generate_text Method
Root cause: Algorithmic Error

[x] I have checked the [documentation](https://docs.ragas.io/) and related resources and couldn’t resolve my bug.

**Describe the bug**
In the generate_text method, the original temperature value of self.langchain_llm.temperature is never preserved. Instead of capturing the current temperature before setting a new one, the code sets:

old_temperature = temperature

immediately after updating it. This means that when resetting the temperature later, it’s simply set to the new value rather than restoring the original state.

Ragas version: ‘0.2.14.dev12+g2bc29a2’
Python version: 3.12

**Code to Reproduce**
Calling generate_text with a specified temperature highlights the issue. Below is the relevant snippet:

```python
class LangchainLLMWrapper:
...
def generate_text(
        self,
        prompt: PromptValue,
        n: int = 1,
        temperature: t.Optional[float] = None,
        stop: t.Optional[t.List[str]] = None,
        callbacks: Callbacks = None,
    ) -> LLMResult:
        # figure out the temperature to set
        old_temperature: float | None = None
        if temperature is None:
            temperature = self.get_temperature(n=n)
        if hasattr(self.langchain_llm, "temperature"):
            self.langchain_llm.temperature = temperature  # type: ignore
            old_temperature = temperature

        if is_multiple_completion_supported(self.langchain_llm):
            result = self.langchain_llm.generate_prompt(
                prompts=[prompt],
                n=n,
                stop=stop,
                callbacks=callbacks,
            )
        else:
            result = self.langchain_llm.generate_prompt(
                prompts=[prompt] * n,
                stop=stop,
                callbacks=callbacks,
            )
            # make LLMResult.generation appear as if it was n_completions
            generations = [[g[0] for g in result.generations]]
            result.generations = generations

        # reset the temperature to the original value
        if old_temperature is not None:
            self.langchain_llm.temperature = old_temperature  # type: ignore

        return result
```

**Error trace**
No explicit error message is produced. However, the bug manifests as the temperature not being restored to its original value after text generation, which may affect subsequent operations.

**Expected behavior**
The expected behavior is for the method to restore the original self.langchain_llm.temperature after generating text. This can be achieved by capturing the current temperature before overwriting it, for example:

```python
if hasattr(self.langchain_llm, "temperature"):
    old_temperature = self.langchain_llm.temperature  # Capture the original value
    self.langchain_llm.temperature = temperature       # Set new temperature
```

**Additional context**
This issue may lead to inconsistent behavior in subsequent text generation calls if the temperature setting is not properly restored. Correcting this would ensure that the internal state of the language model remains consistent. Thank you for your attention to this bug.