<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic LangChain - A Cool Python Framework for LLM Applications in DevNet General Discussions</title>
    <link>https://community.cisco.com/t5/devnet-general-discussions/langchain-a-cool-python-framework-for-llm-applications/m-p/5000338#M2191</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="langchain.jpeg" style="width: 339px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/207841i71F228B4E8FA5BBD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="langchain.jpeg" alt="langchain.jpeg" /&gt;&lt;/span&gt;The world of technology is constantly evolving, and large language models (LLMs) have emerged as groundbreaking tools that are revolutionizing the way we interact with applications and digital content. These sophisticated language models, such as ChatGPT and Google BARD, have opened up new possibilities for engineers, enabling them to create applications that were once beyond reach.&lt;/P&gt;
&lt;P&gt;If you’re a Python programmer interested in learning about AI and LLMs, &lt;A title="LangChain" href="https://www.langchain.com/" target="_self"&gt;&lt;STRONG&gt;LangChain&lt;/STRONG&gt;&lt;/A&gt; is an exciting new Python framework that you must try. LangChain simplifies the process of developing applications powered by language models, providing flexible abstractions and an AI-first toolkit that unlocks developers to build context-aware, reasoning LLM applications. LangChain’s tools and APIs simplify the process of building LLM-driven applications like chatbots and virtual agents.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To install LangChain run:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;pip install langchain&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To try out this simple example you also need to install dotenv and openai modules:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;pip install openai
pip install python-dotenv&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On MacOS or Linux, you may want to replace pip with pip3. Also, create a virtual environment before installing these modules. You will need to create an OpenAI account‍ If you don't already have an OpenAI account and generate an API key before try out this example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from langchain_openai import ChatOpenAI
from langchain.prompts.chat import ChatPromptTemplate
from dotenv import load_dotenv
import os

load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")
chat_model = ChatOpenAI(openai_api_key=api_key)

template = "You are a helpful assistant that translates {input_language} to {output_language}."
human_template = "{text}"

chat_prompt = ChatPromptTemplate.from_messages([
    ("system", template),
    ("human", human_template),
])

messages = chat_prompt.format_messages(input_language="English", output_language="Spanish", 
                                                                     text="I love Devvie.")
result = chat_model.predict_messages(messages)
print(result.content)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have fun with LangChain!&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jan 2024 21:59:35 GMT</pubDate>
    <dc:creator>davidn#</dc:creator>
    <dc:date>2024-01-18T21:59:35Z</dc:date>
    <item>
      <title>LangChain - A Cool Python Framework for LLM Applications</title>
      <link>https://community.cisco.com/t5/devnet-general-discussions/langchain-a-cool-python-framework-for-llm-applications/m-p/5000338#M2191</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="langchain.jpeg" style="width: 339px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/207841i71F228B4E8FA5BBD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="langchain.jpeg" alt="langchain.jpeg" /&gt;&lt;/span&gt;The world of technology is constantly evolving, and large language models (LLMs) have emerged as groundbreaking tools that are revolutionizing the way we interact with applications and digital content. These sophisticated language models, such as ChatGPT and Google BARD, have opened up new possibilities for engineers, enabling them to create applications that were once beyond reach.&lt;/P&gt;
&lt;P&gt;If you’re a Python programmer interested in learning about AI and LLMs, &lt;A title="LangChain" href="https://www.langchain.com/" target="_self"&gt;&lt;STRONG&gt;LangChain&lt;/STRONG&gt;&lt;/A&gt; is an exciting new Python framework that you must try. LangChain simplifies the process of developing applications powered by language models, providing flexible abstractions and an AI-first toolkit that unlocks developers to build context-aware, reasoning LLM applications. LangChain’s tools and APIs simplify the process of building LLM-driven applications like chatbots and virtual agents.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To install LangChain run:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;pip install langchain&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To try out this simple example you also need to install dotenv and openai modules:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;pip install openai
pip install python-dotenv&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On MacOS or Linux, you may want to replace pip with pip3. Also, create a virtual environment before installing these modules. You will need to create an OpenAI account‍ If you don't already have an OpenAI account and generate an API key before try out this example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from langchain_openai import ChatOpenAI
from langchain.prompts.chat import ChatPromptTemplate
from dotenv import load_dotenv
import os

load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")
chat_model = ChatOpenAI(openai_api_key=api_key)

template = "You are a helpful assistant that translates {input_language} to {output_language}."
human_template = "{text}"

chat_prompt = ChatPromptTemplate.from_messages([
    ("system", template),
    ("human", human_template),
])

messages = chat_prompt.format_messages(input_language="English", output_language="Spanish", 
                                                                     text="I love Devvie.")
result = chat_model.predict_messages(messages)
print(result.content)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have fun with LangChain!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 21:59:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-general-discussions/langchain-a-cool-python-framework-for-llm-applications/m-p/5000338#M2191</guid>
      <dc:creator>davidn#</dc:creator>
      <dc:date>2024-01-18T21:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: LangChain - A Cool Python Framework for LLM Applications</title>
      <link>https://community.cisco.com/t5/devnet-general-discussions/langchain-a-cool-python-framework-for-llm-applications/m-p/5011671#M2203</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/365403"&gt;@davidn#&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All sorted?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 09:09:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-general-discussions/langchain-a-cool-python-framework-for-llm-applications/m-p/5011671#M2203</guid>
      <dc:creator>Ruben Cocheno</dc:creator>
      <dc:date>2024-02-02T09:09:35Z</dc:date>
    </item>
  </channel>
</rss>

