Skip to content

Commit

Permalink
fix wrong type annotations and nonexistent types (#560)
Browse files Browse the repository at this point in the history
- The code shown in the document cause warnings in the IDE.  

![](https://github.com/explodinggradients/ragas/assets/62790279/826c10ae-a9d0-410a-b681-f07d44aeda17)

- `ragas.llms.LangchainLLM` is no longer exists but `from ragas.llms
import LangchainLLM` is still left in
[document](https://github.com/explodinggradients/ragas/blob/c9ba2be93cb698ff7e691952b6f77378b853ef58/docs/howtos/customisations/gcp-vertexai.ipynb#L128)

First time here, apology for any mistakes.
  • Loading branch information
stydxm authored Feb 7, 2024
1 parent 5476079 commit e6be5bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
2 changes: 0 additions & 2 deletions docs/concepts/prompt_adaptation.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Create a sample prompt using `Prompt` class.
```{code-block} python
from langchain.chat_models import ChatOpenAI
from ragas.llms import LangchainLLMWrapper
from ragas.llms.prompt import Prompt
noun_extractor = Prompt(
Expand All @@ -55,7 +54,6 @@ examples=[{
)
openai_model = ChatOpenAI(model_name="gpt-4")
openai_model = LangchainLLMWrapper(llm=openai_model)
```

Prompt adaption is done using the `.adapt` method:
Expand Down
12 changes: 3 additions & 9 deletions docs/howtos/customisations/gcp-vertexai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@
"]\n",
"```\n",
"\n",
"By default Ragas uses `ChatOpenAI` for evaluations, lets swap that out with `ChatVertextAI`. We also need to change the embeddings used for evaluations for `OpenAIEmbeddings` to `VertextAIEmbeddings` for metrices that need it, which in our case is `answer_relevancy`.\n",
"\n",
"Now in order to use the new `ChatVertextAI` llm instance with Ragas metrics, you have to create a new instance of `RagasLLM` using the `ragas.llms.LangchainLLM` wrapper. Its a simple wrapper around langchain that make Langchain LLM/Chat instances compatible with how Ragas metrics will use them."
"By default Ragas uses `ChatOpenAI` for evaluations, lets swap that out with `ChatVertextAI`. We also need to change the embeddings used for evaluations for `OpenAIEmbeddings` to `VertextAIEmbeddings` for metrices that need it, which in our case is `answer_relevancy`."
]
},
{
Expand All @@ -125,7 +123,6 @@
"source": [
"import google.auth\n",
"from langchain.chat_models import ChatVertexAI\n",
"from ragas.llms import LangchainLLM\n",
"from langchain.embeddings import VertexAIEmbeddings\n",
"\n",
"\n",
Expand All @@ -136,11 +133,8 @@
"# authenticate to GCP\n",
"creds, _ = google.auth.default(quota_project_id=\"tmp-project-404003\")\n",
"# create Langchain LLM and Embeddings\n",
"chat = ChatVertexAI(credentials=creds)\n",
"vertextai_embeddings = VertexAIEmbeddings(credentials=creds)\n",
"\n",
"# create a wrapper around it\n",
"ragas_vertexai_llm = LangchainLLM(chat)"
"ragas_vertexai_llm = ChatVertexAI(credentials=creds)\n",
"vertextai_embeddings = VertexAIEmbeddings(credentials=creds)"
]
},
{
Expand Down
3 changes: 1 addition & 2 deletions docs/howtos/customisations/llms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"id": "c9ddf74a-9830-4e1a-a4dd-7e5ec17a71e4",
"metadata": {},
"source": [
"Now lets create an Langchain llm instance and wrap it with `LangchainLLMWrapper` class. Because vLLM can run in OpenAI compatibilitiy mode, we can use the `ChatOpenAI` class as it is with small tweaks."
"Now lets create an Langchain llm instance. Because vLLM can run in OpenAI compatibilitiy mode, we can use the `ChatOpenAI` class as it is with small tweaks."
]
},
{
Expand All @@ -199,7 +199,6 @@
"outputs": [],
"source": [
"from langchain_openai.chat_models import ChatOpenAI\n",
"from ragas.llms.base import LangchainLLMWrapper\n",
"\n",
"inference_server_url = \"http://localhost:8080/v1\"\n",
"\n",
Expand Down

0 comments on commit e6be5bb

Please sign in to comment.