Skip to content

The agent engineering platform.

Fixed a link typo /-/route -> /-/routes. and change endpoint format (#6186)

kYLe3a58c4c3a0c6
diff --git a/docs/extras/modules/model_io/models/llms/integrations/anyscale.ipynb b/docs/extras/modules/model_io/models/llms/integrations/anyscale.ipynb
index ec2732cf44..3f9e2cc0b2 100644
--- a/docs/extras/modules/model_io/models/llms/integrations/anyscale.ipynb
+++ b/docs/extras/modules/model_io/models/llms/integrations/anyscale.ipynb
@@ -1,6 +1,7 @@
{
"cells": [
{
+ "attachments": {},
"cell_type": "markdown",
"id": "9597802c",
"metadata": {},
@@ -9,7 +10,9 @@
"\n",
"[Anyscale](https://www.anyscale.com/) is a fully-managed [Ray](https://www.ray.io/) platform, on which you can build, deploy, and manage scalable AI and Python applications\n",
"\n",
- "This example goes over how to use LangChain to interact with `Anyscale` [service](https://docs.anyscale.com/productionize/services-v2/get-started)"
+ "This example goes over how to use LangChain to interact with `Anyscale` [service](https://docs.anyscale.com/productionize/services-v2/get-started). \n",
+ "\n",
+ "It will send the requests to Anyscale Service endpoint, which is concatenate `ANYSCALE_SERVICE_URL` and `ANYSCALE_SERVICE_ROUTE`, with a token defined in `ANYSCALE_SERVICE_TOKEN`"
]
},
{
@@ -96,6 +99,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"id": "42f05b34-1a44-4cbd-8342-35c1572b6765",
"metadata": {},
diff --git a/langchain/llms/anyscale.py b/langchain/llms/anyscale.py
index 8baa9225a4..307efd1e84 100644
--- a/langchain/llms/anyscale.py
+++ b/langchain/llms/anyscale.py
@@ -59,12 +59,17 @@ class Anyscale(LLM):
anyscale_service_token = get_from_dict_or_env(
values, "anyscale_service_token", "ANYSCALE_SERVICE_TOKEN"
)
+ if anyscale_service_url.endswith("/"):
+ anyscale_service_url = anyscale_service_url[:-1]
+ if not anyscale_service_route.startswith("/"):
+ anyscale_service_route = "/" + anyscale_service_route
try:
- anyscale_service_endpoint = f"{anyscale_service_url}/-/route"
+ anyscale_service_endpoint = f"{anyscale_service_url}/-/routes"
headers = {"Authorization": f"Bearer {anyscale_service_token}"}
requests.get(anyscale_service_endpoint, headers=headers)
except requests.exceptions.RequestException as e:
raise ValueError(e)
+
values["anyscale_service_url"] = anyscale_service_url
values["anyscale_service_route"] = anyscale_service_route
values["anyscale_service_token"] = anyscale_service_token
@@ -102,7 +107,7 @@ class Anyscale(LLM):
"""
anyscale_service_endpoint = (
- f"{self.anyscale_service_url}/{self.anyscale_service_route}"
+ f"{self.anyscale_service_url}{self.anyscale_service_route}"
)
headers = {"Authorization": f"Bearer {self.anyscale_service_token}"}
body = {"prompt": prompt}