mirror of
https://github.com/hwchase17/langchain
synced 2024-10-31 15:20:26 +00:00
86 lines
1.7 KiB
Plaintext
86 lines
1.7 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Banana\n",
|
||
|
"This example goes over how to use LangChain to interact with Banana models"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import os\n",
|
||
|
"from langchain.llms import Banana\n",
|
||
|
"from langchain import PromptTemplate, LLMChain\n",
|
||
|
"os.environ[\"BANANA_API_KEY\"] = \"YOUR_API_KEY\""
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"template = \"\"\"Question: {question}\n",
|
||
|
"\n",
|
||
|
"Answer: Let's think step by step.\"\"\"\n",
|
||
|
"\n",
|
||
|
"prompt = PromptTemplate(template=template, input_variables=[\"question\"])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"llm = Banana(model_key=\"YOUR_MODEL_KEY\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"llm_chain = LLMChain(prompt=prompt, llm=llm)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"question = \"What NFL team won the Super Bowl in the year Justin Beiber was born?\"\n",
|
||
|
"\n",
|
||
|
"llm_chain.run(question)"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3.9.12 ('palm')",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"name": "python",
|
||
|
"version": "3.9.12"
|
||
|
},
|
||
|
"orig_nbformat": 4,
|
||
|
"vscode": {
|
||
|
"interpreter": {
|
||
|
"hash": "a0a0263b650d907a3bfe41c0f8d6a63a071b884df3cfdc1579f00cdc1aed6b03"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|