Create DeepSeek AI Agents on a Laptop for Free (Ollama + LangChain)
100% Free, Private, and Secure
This tutorial shows you how to download and run DeepSeek-R1 on your laptop computer for free and create a basic AI Multi-Agent workflow. (It even runs on my 5 year old M1 Macbook Pro). This setup is 100% free, ensures full privacy since it is stored and run from your own computer, and relies on open source AI tools and models, including DeepSeek R1 Distilled, Ollama, and the LangChain Python library.
This is just a starter template for AI Agents using DeepSeek R1. You can change the goals and inputs of the AI Agents. You can create additional AI Agents with more comprehensive orchestrated workflows. You can even swap out DeepSeek R1 for whatever new local Large Language Model (LLM) gets released.
Full Code Below the Video
# DeepSeek Agents using LangChain
# (Crisis Management Team)
# Source: Deep Charts Youtube Channel
# https://www.youtube.com/@DeepCharts
## Libraries/Functions
from langchain.chains import SequentialChain, LLMChain
from langchain.prompts import PromptTemplate
from langchain_ollama.llms import OllamaLLM
## Initialize Model And Create Prompt Templates
# Initialize the Ollama model
llm = OllamaLLM(model="deepseek-r1:8b")
# Crisis Management Agent Prompt
crisis_prompt = PromptTemplate(
input_variables=["issue"],
template="""
You are a crisis management expert.
Draft a **short and professional statement for the press** addressing the crisis while maintaining trust in the company.
Your response should:
- Acknowledge the issue.
- Reassure customers, stakeholders, and the public.
- Briefly mention the steps being taken to resolve the situation.
- Be concise, clear, and confident.
Crisis Situation: {issue}
Press Statement:
"""
)
# Legal Expert Agent Prompt
legal_prompt = PromptTemplate(
input_variables=["crisis_response"],
template="""
You are a legal expert.
Review the following short press statement and edit it to (1) deny direct culpability, and (2) remove any language that could put the company in legal liability.
Ensure the statement remains professional and reassuring but avoids making admissions of fault or liability.
In the final shared statement, please add a note about what you changed from the original statement and why, giving atleast 1 concrete example.
Original Press Statement:
{crisis_response}
Legally Safe Press Statement:
"""
)
## Create Chains
# Define LLM Chains for each agent
crisis_chain = LLMChain(llm=llm, prompt=crisis_prompt, output_key="crisis_response")
legal_chain = LLMChain(llm=llm, prompt=legal_prompt, output_key="legal_response")
# Orchestrate using SequentialChain
crisis_management_chain = SequentialChain(
chains=[crisis_chain, legal_chain],
input_variables=["issue"],
output_variables=["crisis_response", "legal_response"]
)
## Describe Crisis Scenario
# Example: Switch the issue description for any crisis scenario
issue_description = "Kia recalls 80,000 vehicles due to faulty wiring, improper air bag deployment"
## Run Workflow
# Run the multi-agent crisis response workflow
final_output = crisis_management_chain({"issue": issue_description})
# Print first response (Crisis Management Expert)
print("\n-------- 🟥 Crisis Management Statement 🟥 --------\n")
print(final_output["crisis_response"])
# Print final legally refined response
print("\n-------- 🟦 Final Legal-Safe Press Statement 🟦 --------\n")
print(final_output["legal_response"])
Subscribe to the Deep Charts YouTube Channel for more informative AI and Machine Learning Tutorials.