"[Ray Serve](https://docs.ray.io/en/latest/serve/index.html) is a scalable model serving library for building online inference APIs. Serve is particularly well suited for system composition, enabling you to build a complex inference service consisting of multiple chains and business logic all in Python code. "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Goal of this notebook\n",
"This notebook shows a simple example of how to deploy an OpenAI chain into production. You can extend it to deploy your own self-hosted models where you can easily define amount of hardware resources (GPUs and CPUs) needed to run your model in production efficiently. Read more about available options including autoscaling in the Ray Serve [documentation](https://docs.ray.io/en/latest/serve/getting_started.html).\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup Ray Serve\n",
"Install ray with `pip install ray[serve]`. "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## General Skeleton"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The general skeleton for deploying a service is the following:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 0: Import ray serve and request from starlette\n",
"## Example of deploying and OpenAI chain with custom prompts"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Get an OpenAI API key from [here](https://platform.openai.com/account/api-keys). By running the following code, you will be asked to provide your API key."