Monday, March 31, 2025

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

Negotiation is an artwork that impacts every thing from job gives to enterprise transactions. Whether or not you’re negotiating a wage, closing a enterprise deal, or settling a dispute over a contract, the correct method could be the distinction between success and sacrifice. So as 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 gives 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 numerous domains.
  • Find out how DeepSeek R1 Distill Llama 70B allows real-time AI-driven negotiation insights.
  • Discover key options of the AI Negotiation Agent, together with counteroffers and danger evaluation.
  • Acquire hands-on expertise establishing and utilizing the AI-powered negotiation device in Streamlit.
  • Uncover how AI-generated methods can optimize wage discussions, enterprise offers, and contract negotiations.

This text was printed 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 reply to 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 purposes.

Downside Assertion

Folks wrestle to barter successfully resulting from a lack of expertise, emotional bias, or weak argument structuring.

  • Workers could accept decrease salaries resulting from poor negotiation abilities.
  • Companies could fail to shut offers as a result of they don’t perceive the opposite social gathering’s wants.
  • Freelancers and startups wrestle with pricing and contracts.

Purpose: Create an AI agent that analyzes a negotiation state of affairs, 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 under:

  •  Helps a number of negotiation sorts (Wage, Enterprise Offers, Freelancing, Contract Disputes)
  • AI-generated counteroffers with justifications and danger 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 person begins by opening the Streamlit app and deciding on the specified negotiation kind. 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 Massive 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 recommended technique, providing insights and suggestions to help the person of their negotiation course of.

negotiation_flow

Choose Your Negotiation Kind

Select from 4 predefined choices:

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

Enter Your Supply and Constraints

Fill in:

  • Your proposed provide (₹ or %)
  • The opposite social gathering’s anticipated provide
  • Key constraints, reminiscent of minimal wage, funding limits, or deadlines

AI Generates a Technique

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

  • Greatest counteroffer based mostly on inputs
  • Justification for the provide
  • Danger evaluation (chance 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

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

Atmosphere Setup

# Create a Atmosphere 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/major/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

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

Step1: Importing Required Libraries

The mandatory libraries, together with Streamlit for UI, LangChain for AI processing, and dotenv for setting 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 setting file. If the secret’s 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 broad format. This ensures a structured and user-friendly interface for participating with the negotiation agent.

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

A sidebar is added the place customers can choose their most well-liked negotiation kind—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 kind and discover the small print under.") negotiation_type = st.sidebar.selectbox("Negotiation Kind", [     "Salary Negotiation",      "Business Deal",      "Freelance Pricing",      "Contract Dispute" ])
  • Provides a sidebar the place customers choose the kind of negotiation.
  • Out there choices: Wage, Enterprise Deal, Freelance Pricing, Contract Dispute.

Step5: Directions for Customers

An expandable part gives step-by-step steering on how you can use the app. Customers enter their provide particulars, click on the “Generate AI Technique” button, and regulate negotiation settings as wanted.

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

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 kind, gives, constraints, and anticipated AI output like counteroffers, danger assessments, and confidence scores.

negotiation_template = """ You might be an professional negotiator. Analyze this state of affairs and counsel the perfect negotiation technique: - **Negotiation Kind:** {negotiation_type} - **Your Supply:** {your_offer} - **Different Social gathering's Anticipated Supply:** {other_party_stance} - **Key Constraints:** {key_constraints} ### Present: 1. The perfect 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, danger evaluation, confidence rating.

Step7: Operate 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):     """Masses 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 Consumer Inputs

A kind captures person 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 state of affairs under:") with st.kind(key="negotiation_form"):     col1, col2 = st.columns(2)     with col1:         your_offer = st.text_input("Your Supply (₹ or %):", placeholder="Enter your proposed provide...")     with col2:         other_party_stance = st.text_input("Different Social gathering's Anticipated Supply (₹ or %):", placeholder="Enter anticipated counteroffer...")     key_constraints = st.text_area("Key Constraints", top=150, placeholder="Listing deal-breakers, objectives, must-haves...")     submit_button = st.form_submit_button("Generate AI Technique")

Creates a kind 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 shipped for technique era. The response consists of counteroffers, justifications, danger assessments, and confidence scores. If any subject is lacking, an error message prompts the person 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 Instructed Technique:")         st.markdown(outcome)     else:         st.error("Please fill in all fields earlier than producing a method.") 
  • Consumer submits a negotiation state of affairs (Supply, Opponent’s Supply, 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 an alternative.

Get full code on GitHub Right here

Output

output; Negotiation Agent using DeepSeek-R1

Enter

Negotiation Kind: Wage Negotiation

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

Key Constraints:

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

Output

output; Negotiation Agent using DeepSeek-R1

Conclusion

Negotiation is a priceless 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 selections with AI-generated counteroffers, danger 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 charge.

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

Key Takeaways

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

Ceaselessly 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 person enter and generates negotiation methods.

Q2. What’s the objective of PromptTemplate?

A. PromptTemplate defines the construction of the immediate despatched to the AI. It ensures the AI receives all obligatory particulars (provide, constraints, negotiation kind) 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 setting with out exposing it within the code.

This autumn.  How does the app deal with lacking person enter?

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

The media proven on this article just isn’t 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