forked from Archives/langchain
Fixed a link typo /-/route -> /-/routes. and change endpoint format (#6186)
<!-- Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution. Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change. After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost. Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle! --> <!-- Remove if not applicable --> Fixes a link typo from `/-/route` to `/-/routes`. and change endpoint format from `f"{self.anyscale_service_url}/{self.anyscale_service_route}"` to `f"{self.anyscale_service_url}{self.anyscale_service_route}"` Also adding documentation about the format of the endpoint #### Before submitting <!-- If you're adding a new integration, please include: 1. a test for the integration - favor unit tests that does not rely on network access. 2. an example notebook showing its use See contribution guidelines for more information on how to write tests, lint etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md --> #### Who can review? Tag maintainers/contributors who might be interested: <!-- For a quicker response, figure out the right person to tag with @ @hwchase17 - project lead Tracing / Callbacks - @agola11 Async - @agola11 DataLoaders - @eyurtsev Models - @hwchase17 - @agola11 Agents / Tools / Toolkits - @hwchase17 VectorStores / Retrievers / Memory - @dev2049 --> --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
This commit is contained in:
parent
03b16ed2b1
commit
3a58c4c3a0
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
|
"attachments": {},
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "9597802c",
|
"id": "9597802c",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -9,7 +10,9 @@
|
|||||||
"\n",
|
"\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",
|
"[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",
|
"\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",
|
"cell_type": "markdown",
|
||||||
"id": "42f05b34-1a44-4cbd-8342-35c1572b6765",
|
"id": "42f05b34-1a44-4cbd-8342-35c1572b6765",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
@ -59,12 +59,17 @@ class Anyscale(LLM):
|
|||||||
anyscale_service_token = get_from_dict_or_env(
|
anyscale_service_token = get_from_dict_or_env(
|
||||||
values, "anyscale_service_token", "ANYSCALE_SERVICE_TOKEN"
|
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:
|
try:
|
||||||
anyscale_service_endpoint = f"{anyscale_service_url}/-/route"
|
anyscale_service_endpoint = f"{anyscale_service_url}/-/routes"
|
||||||
headers = {"Authorization": f"Bearer {anyscale_service_token}"}
|
headers = {"Authorization": f"Bearer {anyscale_service_token}"}
|
||||||
requests.get(anyscale_service_endpoint, headers=headers)
|
requests.get(anyscale_service_endpoint, headers=headers)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
raise ValueError(e)
|
raise ValueError(e)
|
||||||
|
|
||||||
values["anyscale_service_url"] = anyscale_service_url
|
values["anyscale_service_url"] = anyscale_service_url
|
||||||
values["anyscale_service_route"] = anyscale_service_route
|
values["anyscale_service_route"] = anyscale_service_route
|
||||||
values["anyscale_service_token"] = anyscale_service_token
|
values["anyscale_service_token"] = anyscale_service_token
|
||||||
@ -102,7 +107,7 @@ class Anyscale(LLM):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
anyscale_service_endpoint = (
|
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}"}
|
headers = {"Authorization": f"Bearer {self.anyscale_service_token}"}
|
||||||
body = {"prompt": prompt}
|
body = {"prompt": prompt}
|
||||||
|
Loading…
Reference in New Issue
Block a user