Build a Negotiation Agent Using DeepSeek-R1 Distill LLaMA-70B

Gourav Lohar Last Updated : 05 Mar, 2025
7 min read

Negotiation is an art that affects everything from job offers to business transactions. Whether you are negotiating a salary, closing a business deal, or settling a dispute over a contract, the proper technique can be the difference between success and sacrifice. In order to simplify and streamline the negotiation process, I developed an AI-Powered Negotiation Agent, a Streamlit web application built on LangChain and DeepSeek-R1. It provides you with intelligent negotiation strategies based on what you input, and you negotiate the best possible agreement.

Learning Objectives

  • Understand the role of AI in enhancing negotiation strategies across various domains.
  • Learn how DeepSeek R1 Distill Llama 70B enables real-time AI-driven negotiation insights.
  • Explore key features of the AI Negotiation Agent, including counteroffers and risk assessment.
  • Gain hands-on experience setting up and using the AI-powered negotiation tool in Streamlit.
  • Discover how AI-generated strategies can optimize salary discussions, business deals, and contract negotiations.

This article was published as a part of the Data Science Blogathon.

What is DeepSeek R1 Distill Llama 70b?

DeepSeek-R1-Distill-Llama-70B is a high-performance GroqCloud AI model. It is a distilled version of Llama 3.3 70B and is made intelligent and efficient to respond to math, coding, and factual questions.

This model reasons sequentially, step by step, and thus is appropriate for high-level decision-making. With Groq’s extremely fast inference, users can experience real-time AI reasoning without latency, unlocking new possibilities for high-end AI applications.

Problem Statement

People struggle to negotiate effectively due to a lack of information, emotional bias, or weak argument structuring.

  • Employees may settle for lower salaries due to poor negotiation skills.
  • Businesses may fail to close deals because they don’t understand the other party’s needs.
  • Freelancers and startups struggle with pricing and contracts.

Goal: Create an AI agent that analyzes a negotiation scenario, predicts counteroffers, and suggests optimal negotiation strategies based on logic and past data.

Key Features of the AI Negotiation Agent

Let us now look into the key features of AI Negotiation Agent below:

  •  Supports multiple negotiation types (Salary, Business Deals, Freelancing, Contract Disputes)
  • AI-generated counteroffers with justifications and risk assessment
  • Customizable input fields for personalized negotiation scenarios
  • Confidence scoring for AI-suggested strategies
  • Fast and efficient processing using Groq API

How this Agent Works

The user begins by opening the Streamlit app and selecting the desired negotiation type. They then input the offer details, providing key information for the AI model to process. Upon clicking the ‘Generate AI Strategy’ button, the system initializes and loads the Large Language Model (DeepSeek-R1). The input data is then processed using a predefined prompt template, ensuring that the AI understands the negotiation context effectively.

Once the processing is complete, the AI generates a tailored negotiation strategy based on the provided details. Finally, the system displays the AI’s suggested strategy, offering insights and recommendations to assist the user in their negotiation process.

negotiation_flow

Select Your Negotiation Type

Choose from four predefined options:

  • Salary Negotiation
  • Business Deal
  • Freelance Pricing
  • Contract Dispute

Enter Your Offer and Constraints

Fill in:

  • Your proposed offer (₹ or %)
  • The other party’s expected offer
  • Key constraints, such as minimum salary, investment limits, or deadlines

AI Generates a Strategy

Once submitted, the AI analyzes your negotiation and provides:

  • Best counteroffer based on inputs
  • Justification for the offer
  • Risk assessment (likelihood of acceptance)
  • Confidence score (out of 100%)

Use AI Insights to Negotiate

Leverage the AI-generated strategy to confidently negotiate and secure better deals.

Setting Up the Base

Below we will set up the base by first setting up the environment then followed by installing libraries:

Environment Setup

# Create a Environment
python -m venv env

# Activate it on Windows
.\env\Scripts\activate

# Activate in MacOS/Linux
source env/bin/activate

Install the Requirements.txt

pip install -r https://raw.githubusercontent.com/Gouravlohar/Negotiation-Agent/refs/heads/main/requirements.txt

API Key Setup

visit Groq for API Key. 

API Key Setup

Paste the API key in .env File

GROQ_API_KEY="Your API KEY PASTE HERE"

Build a Negotiation Agent using DeepSeek-R1 Distill LLaMA-70B

Below we’ll walk you through building an AI negotiation agent using DeepSeek-R1 Distill LLaMA-70B and Streamlit, enabling you to generate smart, data-driven negotiation strategies effortlessly. Let’s dive in!

Step1: Importing Required Libraries

The necessary libraries, including Streamlit for UI, LangChain for AI processing, and dotenv for environment variable management, are imported to set up the negotiation agent.

import os
import streamlit as st
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain_groq import ChatGroq
from dotenv import load_dotenv

 Step2: Loading the Groq API Key

The application loads the Groq API key from the environment file. If the key is missing, an error message is displayed, and execution stops to prevent unauthorized access.

load_dotenv()
groq_api_key = os.getenv("GROQ_API_KEY")
if not groq_api_key:
    st.error("Groq API Key not found in .env file")
    st.stop()

Step3: Setting Up the Streamlit Interface

The Streamlit app is configured with a title and wide layout. This ensures a structured and user-friendly interface for engaging with the negotiation agent.

st.set_page_config(page_title="AI Negotiation Agent", layout="wide")
st.title("🤝 AI-Powered Negotiation Agent")

Step4: Sidebar for Negotiation Settings

A sidebar is added where users can select their preferred negotiation type—Salary Negotiation, Business Deal, Freelance Pricing, or Contract Dispute—to customize AI-generated strategies.

st.sidebar.header("Negotiation Settings")
st.sidebar.markdown("Select your negotiation type and explore the details below.")

negotiation_type = st.sidebar.selectbox("Negotiation Type", [
    "Salary Negotiation", 
    "Business Deal", 
    "Freelance Pricing", 
    "Contract Dispute"
])
  • Adds a sidebar where users select the type of negotiation.
  • Available options: Salary, Business Deal, Freelance Pricing, Contract Dispute.

Step5: Instructions for Users

An expandable section provides step-by-step guidance on how to use the app. Users input their offer details, click the “Generate AI Strategy” button, and adjust negotiation settings as needed.

with st.expander("How to use this app"):
    st.markdown("""
    - Fill in your offer, the opposing offer, and key constraints.
    - Click **Generate AI Strategy** to receive suggestions.
    - Use the sidebar to adjust the negotiation type.
    """)

Step6: Prompt Template for AI Processing

A structured prompt template is defined to ensure the AI model receives key negotiation details. It includes the negotiation type, offers, constraints, and expected AI output like counteroffers, risk assessments, and confidence scores.

negotiation_template = """
You are an expert negotiator. Analyze this scenario and suggest the best negotiation strategy:

- **Negotiation Type:** {negotiation_type}
- **Your Offer:** {your_offer}
- **Other Party's Expected Offer:** {other_party_stance}
- **Key Constraints:** {key_constraints}

### Provide:
1. The best counteroffer.
2. Justification with reasoning.
3. Risk assessment (if any).
4. Confidence score (out of 100%).
"""
  • Defines a structured prompt for AI processing.
  • AI will generate: counteroffers, reasoning, risk assessment, confidence score.

Step7: Function to Load the AI Model

A function is implemented to initialize the DeepSeek R1 (Distill LLaMA-70B) model using the ChatGroq API. The streaming=True parameter enables real-time response generation.

def load_LLM(groq_api_key):
    """Loads the ChatGroq model for processing."""
    llm = ChatGroq(groq_api_key=groq_api_key, model_name="deepseek-r1-distill-llama-70b", streaming=True)
    return llm
  • Initializes DeepSeek R1 (Distill LLaMA 70B) via ChatGroq API.
  • Streaming=True allows real-time responses.

Step8: Collecting User Inputs

A form captures user inputs, including their offer, the opponent’s expected offer, and key constraints. This information is essential for the AI model to generate an effective negotiation strategy.

st.header(f"💼 {negotiation_type}")
st.markdown("Enter details of your negotiation scenario below:")

with st.form(key="negotiation_form"):
    col1, col2 = st.columns(2)
    with col1:
        your_offer = st.text_input("Your Offer (₹ or %):", placeholder="Enter your proposed offer...")
    with col2:
        other_party_stance = st.text_input("Other Party's Expected Offer (₹ or %):", placeholder="Enter expected counteroffer...")
    key_constraints = st.text_area("Key Constraints", height=150, placeholder="List deal-breakers, goals, must-haves...")
    submit_button = st.form_submit_button("Generate AI Strategy")

Creates a form where users enter:

  • Their offer
  • The expected counteroffer
  • Any constraints or deal-breakers

Step9: Generating AI-Based Negotiation Strategy

Upon submission, the app validates input fields before processing the data. The AI model is loaded, and a prompt is sent for strategy generation. The response includes counteroffers, justifications, risk assessments, and confidence scores. If any field is missing, an error message prompts the user to complete the form.

if submit_button:
    if your_offer and other_party_stance and key_constraints:
        with st.spinner("Generating negotiation strategy..."):
            llm = load_LLM(groq_api_key)
            prompt_obj = PromptTemplate(
                input_variables=["negotiation_type", "your_offer", "other_party_stance", "key_constraints"],
                template=negotiation_template
            )
            chain = LLMChain(llm=llm, prompt=prompt_obj)
            result = chain.run(
                negotiation_type=negotiation_type, 
                your_offer=your_offer, 
                other_party_stance=other_party_stance, 
                key_constraints=key_constraints
            )
        st.success("Strategy generated successfully!")
        st.subheader("💡 AI's Suggested Strategy:")
        st.markdown(result)
    else:
        st.error("Please fill in all fields before generating a strategy.")
  • User submits a negotiation scenario (Offer, Opponent’s Offer, Constraints).
  • Code checks if all fields are filled.
  • A loading spinner appears while AI processes the input.
  • DeepSeek AI generates a negotiation strategy based on the prompt.
  • The strategy is displayed, including counteroffers, risks, and justification.
  • If input is missing, an error message appears instead.

Get full code on GitHub Here

Output

output; Negotiation Agent using DeepSeek-R1

Input

Negotiation Type: Salary Negotiation

  • Your Offer: ₹15 LPA (Lakh per annum)
  • Other Party’s Expected Offer: ₹12 LPA

Key Constraints:

  • Minimum ₹14 LPA to meet expenses.
  • Prefer hybrid work flexibility.
  • Open to performance-based incentives.

Output

output; Negotiation Agent using DeepSeek-R1

Conclusion

Negotiation is a valuable skill in both professional and personal life, and the Negotiation Agent using DeepSeek-R1 employs data to assist you in negotiating improved deals. Whether you are negotiating a raise, a business investment, or contract terms, this app helps you make better decisions with AI-generated counteroffers, risk levels, and confidence scores.

This utility leverages DeepSeek-R1 Distill LLaMA-70B, LangChain, and Streamlit to facilitate negotiations. It assists you in minimizing uncertainty and maximizing your success rate.

Thanks to AI, you don’t have to second-guess your best move anymore—you can negotiate with confidence!

Key Takeaways

  • The app analyzes offers and constraints to provide intelligent counteroffers.
  • Supports salary negotiation, business deals, freelance pricing, and contract disputes.
  • AI assesses the probability of success and potential risks in your negotiation.
  • Users can input their offers and key constraints to generate tailored strategies.
  • Using DeepSeek R1 Distill Llama 70b & LangChain, the app quickly processes data and delivers actionable strategies.

Frequently Asked Questions

Q1. What does load_LLM() function do?

A. The load_LLM() function initializes the DeepSeek R1 Distill Llama 70b model using the ChatGroq API. It returns an LLM (Language Model) that processes user input and generates negotiation strategies.

Q2. What is the purpose of PromptTemplate?

A. PromptTemplate defines the structure of the prompt sent to the AI. It ensures the AI receives all necessary details (offer, constraints, negotiation type) to generate a meaningful response.

Q3. Why is the API key stored in .env file?

A. The API key is sensitive data, and storing it in a .env file keeps it secure. The dotenv package loads this key into the environment without exposing it in the code.

Q4.  How does the app handle missing user input?

A. Before submitting, the app validates input fields (your_offer, other_party_stance, key_constraints). If any field is empty, it displays an error message to ensure complete data entry.

The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.

Hi I'm Gourav, a Data Science Enthusiast with a medium foundation in statistical analysis, machine learning, and data visualization. My journey into the world of data began with a curiosity to unravel insights from datasets.

Responses From Readers

We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.

Show details