Files
langchain/docs/versioned_docs/version-0.2.x/integrations/chat/llama_api.ipynb
Jacob Lee aff771923a Jacob/new docs (#20570)
Use docusaurus versioning with a callout, merged master as well

@hwchase17 @baskaryan

---------

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Rahul Tripathi <rauhl.psit.ec@gmail.com>
Co-authored-by: Leonid Ganeline <leo.gan.57@gmail.com>
Co-authored-by: Leonid Kuligin <lkuligin@yandex.ru>
Co-authored-by: Averi Kitsch <akitsch@google.com>
Co-authored-by: Erick Friis <erick@langchain.dev>
Co-authored-by: Nuno Campos <nuno@langchain.dev>
Co-authored-by: Nuno Campos <nuno@boringbits.io>
Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Co-authored-by: Martín Gotelli Ferenaz <martingotelliferenaz@gmail.com>
Co-authored-by: Fayfox <admin@fayfox.com>
Co-authored-by: Eugene Yurtsev <eugene@langchain.dev>
Co-authored-by: Dawson Bauer <105886620+djbauer2@users.noreply.github.com>
Co-authored-by: Ravindu Somawansa <ravindu.somawansa@gmail.com>
Co-authored-by: Dhruv Chawla <43818888+Dominastorm@users.noreply.github.com>
Co-authored-by: ccurme <chester.curme@gmail.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
Co-authored-by: WeichenXu <weichen.xu@databricks.com>
Co-authored-by: Benito Geordie <89472452+benitoThree@users.noreply.github.com>
Co-authored-by: kartikTAI <129414343+kartikTAI@users.noreply.github.com>
Co-authored-by: Kartik Sarangmath <kartik@thirdai.com>
Co-authored-by: Sevin F. Varoglu <sfvaroglu@octoml.ai>
Co-authored-by: MacanPN <martin.triska@gmail.com>
Co-authored-by: Prashanth Rao <35005448+prrao87@users.noreply.github.com>
Co-authored-by: Hyeongchan Kim <kozistr@gmail.com>
Co-authored-by: sdan <git@sdan.io>
Co-authored-by: Guangdong Liu <liugddx@gmail.com>
Co-authored-by: Rahul Triptahi <rahul.psit.ec@gmail.com>
Co-authored-by: Rahul Tripathi <rauhl.psit.ec@gmail.com>
Co-authored-by: pjb157 <84070455+pjb157@users.noreply.github.com>
Co-authored-by: Eun Hye Kim <ehkim1440@gmail.com>
Co-authored-by: kaijietti <43436010+kaijietti@users.noreply.github.com>
Co-authored-by: Pengcheng Liu <pcliu.fd@gmail.com>
Co-authored-by: Tomer Cagan <tomer@tomercagan.com>
Co-authored-by: Christophe Bornet <cbornet@hotmail.com>
2024-04-18 11:10:55 -07:00

151 lines
3.4 KiB
Plaintext

{
"cells": [
{
"cell_type": "raw",
"id": "71b5cfca",
"metadata": {},
"source": [
"---\n",
"sidebar_label: Llama API\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "90a1faf2",
"metadata": {},
"source": [
"# ChatLlamaAPI\n",
"\n",
"This notebook shows how to use LangChain with [LlamaAPI](https://llama-api.com/) - a hosted version of Llama2 that adds in support for function calling."
]
},
{
"cell_type": "markdown",
"id": "f5b652cf",
"metadata": {},
"source": [
"%pip install --upgrade --quiet llamaapi"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "bfd385fd",
"metadata": {},
"outputs": [],
"source": [
"from llamaapi import LlamaAPI\n",
"\n",
"# Replace 'Your_API_Token' with your actual API token\n",
"llama = LlamaAPI(\"Your_API_Token\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "632eb3e5",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/harrisonchase/.pyenv/versions/3.9.1/envs/langchain/lib/python3.9/site-packages/deeplake/util/check_latest_version.py:32: UserWarning: A newer version of deeplake (3.6.12) is available. It's recommended that you update to the latest version using `pip install -U deeplake`.\n",
" warnings.warn(\n"
]
}
],
"source": [
"from langchain_experimental.llms import ChatLlamaAPI"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "6f850e82",
"metadata": {},
"outputs": [],
"source": [
"model = ChatLlamaAPI(client=llama)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "975c2bf4",
"metadata": {},
"outputs": [],
"source": [
"from langchain.chains import create_tagging_chain\n",
"\n",
"schema = {\n",
" \"properties\": {\n",
" \"sentiment\": {\n",
" \"type\": \"string\",\n",
" \"description\": \"the sentiment encountered in the passage\",\n",
" },\n",
" \"aggressiveness\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"a 0-10 score of how aggressive the passage is\",\n",
" },\n",
" \"language\": {\"type\": \"string\", \"description\": \"the language of the passage\"},\n",
" }\n",
"}\n",
"\n",
"chain = create_tagging_chain(schema, model)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "ef9638c3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'sentiment': 'aggressive', 'aggressiveness': 8, 'language': 'english'}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chain.run(\"give me your money\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "238b4f62",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}