Skip to content

Commit

Permalink
docs: update import paths and move to lcel for llama.cpp examples (la…
Browse files Browse the repository at this point in the history
…ngchain-ai#19391)

**Description:** Update import paths and move to lcel for llama.cpp
examples
**Issue:** Update import paths to reflect package refactoring and move
chains to LCEL in examples
**Dependencies:** None

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
  • Loading branch information
3 people authored and chrispy-snps committed Mar 30, 2024
1 parent 1212ab7 commit d202f2c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions docs/docs/integrations/llms/llamacpp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,9 @@
},
"outputs": [],
"source": [
"from langchain.callbacks.manager import CallbackManager\n",
"from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler\n",
"from langchain.chains import LLMChain\n",
"from langchain.prompts import PromptTemplate\n",
"from langchain_community.llms import LlamaCpp"
"from langchain_community.llms import LlamaCpp\n",
"from langchain_core.callbacks import CallbackManager, StreamingStdOutCallbackHandler\n",
"from langchain_core.prompts import PromptTemplate"
]
},
{
Expand Down Expand Up @@ -329,10 +327,10 @@
}
],
"source": [
"prompt = \"\"\"\n",
"question = \"\"\"\n",
"Question: A rap battle between Stephen Colbert and John Oliver\n",
"\"\"\"\n",
"llm.invoke(prompt)"
"llm.invoke(question)"
]
},
{
Expand Down Expand Up @@ -360,7 +358,7 @@
"metadata": {},
"outputs": [],
"source": [
"llm_chain = LLMChain(prompt=prompt, llm=llm)"
"llm_chain = prompt | llm"
]
},
{
Expand Down Expand Up @@ -406,7 +404,7 @@
],
"source": [
"question = \"What NFL team won the Super Bowl in the year Justin Bieber was born?\"\n",
"llm_chain.run(question)"
"llm_chain.invoke({\"question\": question})"
]
},
{
Expand Down Expand Up @@ -488,9 +486,9 @@
}
],
"source": [
"llm_chain = LLMChain(prompt=prompt, llm=llm)\n",
"llm_chain = prompt | llm\n",
"question = \"What NFL team won the Super Bowl in the year Justin Bieber was born?\"\n",
"llm_chain.run(question)"
"llm_chain.invoke({\"question\": question})"
]
},
{
Expand Down Expand Up @@ -710,7 +708,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.9.1"
},
"vscode": {
"interpreter": {
Expand Down

0 comments on commit d202f2c

Please sign in to comment.