Repository: explodinggradients/ragas
Issue: "AzureChatOpenAI" object has no field "langchain_llm" error when trying to use Azure OpenAI
Root cause: Documentation Deficiency

Hi, when trying to use Azure OpenAI according to [the guide here](https://docs.ragas.io/en/latest/howtos/customisations/azure-openai.html), I ran into this error:

```
ValueError: "AzureChatOpenAI" object has no field "langchain_llm"
```

My code looks like this according to the guide, please let me know if I'm doing anything wrong:

```python
from ragas.metrics import (
    context_precision,
    answer_relevancy,
    faithfulness,
    context_recall,
)
from ragas.metrics.critique import harmfulness
from datasets import load_dataset
from ragas import evaluate
from langchain.chat_models import AzureChatOpenAI
from langchain.embeddings import OpenAIEmbeddings

import os

os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_BASE"] = "[my base]"
os.environ["OPENAI_API_KEY"] = "[my api key]"

# list of metrics we're going to use
metrics = [
    faithfulness,
    answer_relevancy,
    context_recall,
    context_precision,
    harmfulness,
]

azure_model = AzureChatOpenAI(
    deployment="[my deployment]",
    model="[my-model-name]",
    openai_api_base="[my base]"",
    openai_api_type="azure",
)

answer_relevancy.llm = azure_model

# init and change the embeddings
# only for answer_relevancy
azure_embeddings = OpenAIEmbeddings(
    deployment="[my deployment]",
    model="[my-model-name]",
    openai_api_base="[my base]",
    openai_api_type="azure",
)
answer_relevancy.embeddings = azure_embeddings

for m in metrics:
    m.__setattr__("llm", azure_model)

# data
fiqa_eval = load_dataset("explodinggradients/fiqa", "ragas_eval")

result = evaluate(
    fiqa_eval["baseline"],
    metrics=metrics,
)

df = result.to_pandas()
df.head()
```


Hey thanks for reporting this  - this was because we didn't update the docs correctly. This is the updated doc https://github.com/explodinggradients/ragas/blob/7d96554d6fdbed4fa434ea67d8b15e0484d515a1/docs/howtos/customisations/azure-openai.ipynb could you check with this and confirm if it is working for you ?

@jjmachan Thank you for this. 2 things I noticed:
1. Small typo in this code:
```diff
# wrapper around azure_model 
ragas_azure_model = LangchainLLM(azure_model)
# patch the new RagasLLM instance
- answer_relevancy.llm = ragas_auzre_model
+ answer_relevancy.llm = ragas_azure_model

# init and change the embeddings
# only for answer_relevancy
```
2. According to [Langchain's documentation](https://api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html), we should use `deployment_name` instead
```diff
azure_model = AzureChatOpenAI(
-    deployment="your-deployment-name",
+    deployment_name="your-deployment-name",
    model="your-model-name",
    openai_api_base="https://your-endpoint.openai.azure.com/",
    openai_api_type="azure",
)
```

Those were the only 2 things I had to fix to make it work, thanks again!

thank you so much @nmklong for taking the time to test it and suggest the changes. 
merging the docs in and closing this issue now :)