4.3 C
United States of America
Wednesday, March 5, 2025

Construct a Negotiation Agent utilizing DeepSeek-R1 Distill LLaMA-70B


Negotiation is an artwork that impacts all the pieces from job provides to enterprise transactions. Whether or not you’re negotiating a wage, closing a enterprise deal, or settling a dispute over a contract, the correct approach might be the distinction between success and sacrifice. In an effort to simplify and streamline the negotiation course of, I developed an AI-Powered Negotiation Agent, a Streamlit net software constructed on LangChain and DeepSeek-R1. It supplies you with clever negotiation methods based mostly on what you enter, and also you negotiate the absolute best settlement.

Studying Targets

  • Perceive the position of AI in enhancing negotiation methods throughout varied domains.
  • Learn the way DeepSeek R1 Distill Llama 70B allows real-time AI-driven negotiation insights.
  • Discover key options of the AI Negotiation Agent, together with counteroffers and threat evaluation.
  • Achieve hands-on expertise establishing and utilizing the AI-powered negotiation instrument in Streamlit.
  • Uncover how AI-generated methods can optimize wage discussions, enterprise offers, and contract negotiations.

This text was revealed as part of the Knowledge Science Blogathon.

What’s DeepSeek R1 Distill Llama 70b?

DeepSeek-R1-Distill-Llama-70B is a high-performance GroqCloud AI mannequin. It’s a distilled model of Llama 3.3 70B and is made clever and environment friendly to answer math, coding, and factual questions.

This mannequin causes sequentially, step-by-step, and thus is acceptable for high-level decision-making. With Groq’s extraordinarily quick inference, customers can expertise real-time AI reasoning with out latency, unlocking new prospects for high-end AI functions.

Downside Assertion

Individuals battle to barter successfully because of a lack of awareness, emotional bias, or weak argument structuring.

  • Staff might accept decrease salaries because of poor negotiation expertise.
  • Companies might fail to shut offers as a result of they don’t perceive the opposite occasion’s wants.
  • Freelancers and startups battle with pricing and contracts.

Purpose: Create an AI agent that analyzes a negotiation situation, predicts counteroffers, and suggests optimum negotiation methods based mostly on logic and previous information.

Key Options of the AI Negotiation Agent

Allow us to now look into the important thing options of AI Negotiation Agent beneath:

  •  Helps a number of negotiation sorts (Wage, Enterprise Offers, Freelancing, Contract Disputes)
  • AI-generated counteroffers with justifications and threat evaluation
  • Customizable enter fields for customized negotiation situations
  • Confidence scoring for AI-suggested methods
  • Quick and environment friendly processing utilizing Groq API

How this Agent Works

The consumer begins by opening the Streamlit app and choosing the specified negotiation sort. They then enter the provide particulars, offering key info for the AI mannequin to course of. Upon clicking the ‘Generate AI Technique’ button, the system initializes and hundreds the Giant Language Mannequin (DeepSeek-R1). The enter information is then processed utilizing a predefined immediate template, guaranteeing that the AI understands the negotiation context successfully.

As soon as the processing is full, the AI generates a tailor-made negotiation technique based mostly on the supplied particulars. Lastly, the system shows the AI’s advised technique, providing insights and proposals to help the consumer of their negotiation course of.

negotiation_flow

Choose Your Negotiation Sort

Select from 4 predefined choices:

  • Wage Negotiation
  • Enterprise Deal
  • Freelance Pricing
  • Contract Dispute

Enter Your Provide and Constraints

Fill in:

  • Your proposed provide (₹ or %)
  • The opposite occasion’s anticipated provide
  • Key constraints, akin to minimal wage, funding limits, or deadlines

AI Generates a Technique

As soon as submitted, the AI analyzes your negotiation and supplies:

  • Greatest counteroffer based mostly on inputs
  • Justification for the provide
  • Danger evaluation (probability of acceptance)
  • Confidence rating (out of 100%)

Use AI Insights to Negotiate

Leverage the AI-generated technique to confidently negotiate and safe higher offers.

Setting Up the Base

Beneath we are going to arrange the bottom by first establishing the surroundings then adopted by putting in libraries:

Setting Setup

# Create a Setting
python -m venv env

# Activate it on Home windows
.envScriptsactivate

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

Set up the Necessities.txt

pip set up -r https://uncooked.githubusercontent.com/Gouravlohar/Negotiation-Agent/refs/heads/fundamental/necessities.txt

API Key Setup

go to Groq for API Key. 

API Key Setup

Paste the API key in .env File

GROQ_API_KEY="Your API KEY PASTE HERE"

Construct a Negotiation Agent utilizing DeepSeek-R1 Distill LLaMA-70B

Beneath we’ll stroll you thru constructing an AI negotiation agent utilizing DeepSeek-R1 Distill LLaMA-70B and Streamlit, enabling you to generate good, data-driven negotiation methods effortlessly. Let’s dive in!

Step1: Importing Required Libraries

The required libraries, together with Streamlit for UI, LangChain for AI processing, and dotenv for surroundings variable administration, are imported to arrange 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 appliance hundreds the Groq API key from the surroundings file. If the hot button is lacking, an error message is displayed, and execution stops to stop unauthorized entry.

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

Step3: Setting Up the Streamlit Interface

The Streamlit app is configured with a title and large structure. This ensures a structured and user-friendly interface for partaking with the negotiation agent.

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

A sidebar is added the place customers can choose their most well-liked negotiation sort—Wage Negotiation, Enterprise Deal, Freelance Pricing, or Contract Dispute—to customise AI-generated methods.

st.sidebar.header("Negotiation Settings")
st.sidebar.markdown("Choose your negotiation sort and discover the small print beneath.")

negotiation_type = st.sidebar.selectbox("Negotiation Sort", [
    "Salary Negotiation", 
    "Business Deal", 
    "Freelance Pricing", 
    "Contract Dispute"
])
  • Provides a sidebar the place customers choose the kind of negotiation.
  • Obtainable choices: Wage, Enterprise Deal, Freelance Pricing, Contract Dispute.

Step5: Directions for Customers

An expandable part supplies step-by-step steerage on methods to use the app. Customers enter their provide particulars, click on the “Generate AI Technique” button, and regulate negotiation settings as wanted.

with st.expander("Learn how to use this app"):
    st.markdown("""
    - Fill in your provide, the opposing provide, and key constraints.
    - Click on **Generate AI Technique** to obtain recommendations.
    - Use the sidebar to regulate the negotiation sort.
    """)

Step6: Immediate Template for AI Processing

A structured immediate template is outlined to make sure the AI mannequin receives key negotiation particulars. It consists of the negotiation sort, provides, constraints, and anticipated AI output like counteroffers, threat assessments, and confidence scores.

negotiation_template = """
You're an knowledgeable negotiator. Analyze this situation and counsel the perfect negotiation technique:

- **Negotiation Sort:** {negotiation_type}
- **Your Provide:** {your_offer}
- **Different Social gathering's Anticipated Provide:** {other_party_stance}
- **Key Constraints:** {key_constraints}

### Present:
1. The most effective counteroffer.
2. Justification with reasoning.
3. Danger evaluation (if any).
4. Confidence rating (out of 100%).
"""
  • Defines a structured immediate for AI processing.
  • AI will generate: counteroffers, reasoning, threat evaluation, confidence rating.

Step7: Perform to Load the AI Mannequin

A perform is applied to initialize the DeepSeek R1 (Distill LLaMA-70B) mannequin utilizing the ChatGroq API. The streaming=True parameter allows real-time response era.

def load_LLM(groq_api_key):
    """Hundreds the ChatGroq mannequin 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) through ChatGroq API.
  • Streaming=True permits real-time responses.

Step8: Gathering Person Inputs

A type captures consumer inputs, together with their provide, the opponent’s anticipated provide, and key constraints. This info is crucial for the AI mannequin to generate an efficient negotiation technique.

st.header(f"💼 {negotiation_type}")
st.markdown("Enter particulars of your negotiation situation beneath:")

with st.type(key="negotiation_form"):
    col1, col2 = st.columns(2)
    with col1:
        your_offer = st.text_input("Your Provide (₹ or %):", placeholder="Enter your proposed provide...")
    with col2:
        other_party_stance = st.text_input("Different Social gathering's Anticipated Provide (₹ or %):", placeholder="Enter anticipated counteroffer...")
    key_constraints = st.text_area("Key Constraints", top=150, placeholder="Listing deal-breakers, targets, must-haves...")
    submit_button = st.form_submit_button("Generate AI Technique")

Creates a type the place customers enter:

  • Their provide
  • The anticipated counteroffer
  • Any constraints or deal-breakers

Step9: Producing AI-Based mostly Negotiation Technique

Upon submission, the app validates enter fields earlier than processing the information. The AI mannequin is loaded, and a immediate is distributed for technique era. The response consists of counteroffers, justifications, threat assessments, and confidence scores. If any discipline is lacking, an error message prompts the consumer to finish the shape.

if submit_button:
    if your_offer and other_party_stance and key_constraints:
        with st.spinner("Producing negotiation technique..."):
            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, immediate=prompt_obj)
            outcome = chain.run(
                negotiation_type=negotiation_type, 
                your_offer=your_offer, 
                other_party_stance=other_party_stance, 
                key_constraints=key_constraints
            )
        st.success("Technique generated efficiently!")
        st.subheader("💡 AI's Recommended Technique:")
        st.markdown(outcome)
    else:
        st.error("Please fill in all fields earlier than producing a method.")
  • Person submits a negotiation situation (Provide, Opponent’s Provide, Constraints).
  • Code checks if all fields are stuffed.
  • A loading spinner seems whereas AI processes the enter.
  • DeepSeek AI generates a negotiation technique based mostly on the immediate.
  • The technique is displayed, together with counteroffers, dangers, and justification.
  • If enter is lacking, an error message seems as a substitute.

Get full code on GitHub Right here

Output

output; Negotiation Agent using DeepSeek-R1

Enter

Negotiation Sort: Wage Negotiation

  • Your Provide: ₹15 LPA (Lakh every year)
  • Different Social gathering’s Anticipated Provide: ₹12 LPA

Key Constraints:

  • Minimal ₹14 LPA to fulfill bills.
  • Desire hybrid work flexibility.
  • Open to performance-based incentives.

Output

output; Negotiation Agent using DeepSeek-R1

Conclusion

Negotiation is a helpful ability in each skilled and private life, and the Negotiation Agent utilizing DeepSeek-R1 employs information to help you in negotiating improved offers. Whether or not you’re negotiating a increase, a enterprise funding, or contract phrases, this app helps you make higher choices with AI-generated counteroffers, threat ranges, 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 fee.

Due to AI, you don’t need to second-guess your greatest transfer anymore—you’ll be able to negotiate with confidence!

Key Takeaways

  • The app analyzes provides and constraints to supply clever counteroffers.
  • Helps wage negotiation, enterprise offers, freelance pricing, and contract disputes.
  • AI assesses the likelihood of success and potential dangers in your negotiation.
  • Customers can enter their provides and key constraints to generate tailor-made methods.
  • Utilizing DeepSeek R1 Distill Llama 70b & LangChain, the app shortly processes information and delivers actionable methods.

Incessantly Requested Questions

Q1. What does load_LLM() perform do?

A. The load_LLM() perform initializes the DeepSeek R1 Distill Llama 70b mannequin utilizing the ChatGroq API. It returns an LLM (Language Mannequin) that processes consumer enter and generates negotiation methods.

Q2. What’s the function of PromptTemplate?

A. PromptTemplate defines the construction of the immediate despatched to the AI. It ensures the AI receives all vital particulars (provide, constraints, negotiation sort) to generate a significant response.

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

A. The API secret is delicate information, and storing it in a .env file retains it safe. The dotenv bundle hundreds this key into the surroundings with out exposing it within the code.

This fall.  How does the app deal with lacking consumer enter?

A. Earlier than submitting, the app validates enter fields (your_offer, other_party_stance, key_constraints). If any discipline is empty, it shows an error message to make sure full information entry.

The media proven on this article will not be owned by Analytics Vidhya and is used on the Writer’s discretion.

Hello I am Gourav, a Knowledge Science Fanatic with a medium basis in statistical evaluation, machine studying, and information visualization. My journey into the world of information started with a curiosity to unravel insights from datasets.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles