Files
langchain/docs/modules/models/llms/integrations/modal.ipynb
T
leo-gan 5420a0e404 updated langchain/docs/modules/models/llms/integrations/ notebooks (#3041)
- Updated `langchain/docs/modules/models/llms/integrations/` notebooks:
added links to the original sites, the install information, etc.
- Added the `nlpcloud` notebook.
- Removed "Example" from Titles of some notebooks, so all notebook
titles are consistent.
2023-04-17 20:25:32 -07:00

3.5 KiB

Modal

The Modal Python Library provides convenient, on-demand access to serverless cloud compute from Python scripts on your local computer. The Modal itself does not provide any LLMs but only the infrastructure.

This example goes over how to use LangChain to interact with Modal.

Here is another example how to use LangChain to interact with Modal.

In [ ]:
!pip install modal-client
In [2]:
# register and get a new token

!modal token new
[?25lLaunching login page in your browser window...
If this is not showing up, please copy this URL into your web browser manually:
m⠙ Waiting for authentication in the web browser...
]8;id=417802;https://modal.com/token-flow/tf-ptEuGecm7T1T5YQe42kwM1\https://modal.com/token-flow/tf-ptEuGecm7T1T5YQe42kwM1]8;;\

⠙ Waiting for authentication in the web browser...
^C

Aborted.

Follow these instructions to deal with secrets.

In [ ]:
from langchain.llms import Modal
from langchain import PromptTemplate, LLMChain
In [ ]:
template = """Question: {question}

Answer: Let's think step by step."""

prompt = PromptTemplate(template=template, input_variables=["question"])
In [ ]:
llm = Modal(endpoint_url="YOUR_ENDPOINT_URL")
In [ ]:
llm_chain = LLMChain(prompt=prompt, llm=llm)
In [ ]:
question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"

llm_chain.run(question)