LLM-based negotiators for the negmas negotiation framework
Project description
negmas-llm
LLM-based negotiators for the negmas negotiation framework.
Overview
negmas-llm integrates Large Language Models with the negmas negotiation framework, allowing you to create negotiators that use LLMs for decision-making. The library supports multiple LLM providers through litellm, including:
- Cloud providers: OpenAI, Anthropic, Google Gemini, Cohere, Mistral, Groq, Together AI, Azure OpenAI, AWS Bedrock, OpenRouter, DeepSeek, Hugging Face
- Local models: Ollama, vLLM, LM Studio, text-generation-webui
Installation
pip install negmas-llm
Or with uv:
uv add negmas-llm
Quick Start
from negmas import SAOMechanism
from negmas.preferences import LinearAdditiveUtilityFunction
from negmas.outcomes import make_issue
from negmas_llm import OllamaNegotiator, OpenAINegotiator
# Define negotiation issues
issues = [
make_issue("price", (0, 100)),
make_issue("quantity", (1, 10)),
]
# Create utility functions for each party
seller_ufun = LinearAdditiveUtilityFunction(
weights=[0.6, 0.4],
issues=issues,
)
buyer_ufun = LinearAdditiveUtilityFunction(
weights=[-0.6, 0.4], # Buyer prefers lower prices
issues=issues,
)
# Create LLM-based negotiators
seller = OpenAINegotiator(
model="gpt-4o",
name="seller",
ufun=seller_ufun,
)
buyer = OllamaNegotiator(
model="llama3.2",
name="buyer",
ufun=buyer_ufun,
)
# Run the negotiation
mechanism = SAOMechanism(outcome_space=issues, n_steps=20)
mechanism.add(seller)
mechanism.add(buyer)
result = mechanism.run()
print(f"Agreement: {result.agreement}")
Supported Negotiators
| Class | Provider | Default Model |
|---|---|---|
OpenAINegotiator |
OpenAI | gpt-4o |
AnthropicNegotiator |
Anthropic | claude-sonnet-4-20250514 |
GeminiNegotiator |
gemini-2.0-flash | |
CohereNegotiator |
Cohere | command-r-plus |
MistralNegotiator |
Mistral AI | mistral-large-latest |
GroqNegotiator |
Groq | llama-3.3-70b-versatile |
TogetherAINegotiator |
Together AI | Meta-Llama-3.1-70B-Instruct-Turbo |
AzureOpenAINegotiator |
Azure OpenAI | (deployment name) |
AWSBedrockNegotiator |
AWS Bedrock | claude-3-sonnet |
OpenRouterNegotiator |
OpenRouter | openai/gpt-4o |
DeepSeekNegotiator |
DeepSeek | deepseek-chat |
HuggingFaceNegotiator |
Hugging Face | Llama-3.2-3B-Instruct |
OllamaNegotiator |
Ollama (local) | llama3.2 |
VLLMNegotiator |
vLLM (local) | (model name) |
LMStudioNegotiator |
LM Studio (local) | local-model |
TextGenWebUINegotiator |
text-generation-webui | local-model |
Customization
You can customize how information is presented to the LLM by subclassing LLMNegotiator and overriding the formatting methods:
from negmas_llm import LLMNegotiator
class CustomNegotiator(LLMNegotiator):
def format_outcome_space(self, state):
# Customize how the outcome space is described
return "Custom outcome space description..."
def format_own_ufun(self, state):
# Customize how your utility function is described
return "Custom utility function description..."
def format_state(self, state, offer=None):
# Customize how the negotiation state is presented
return "Custom state description..."
For complete control over the prompts, override build_system_prompt or build_user_message:
from negmas_llm import LLMNegotiator
class CustomPromptNegotiator(LLMNegotiator):
def build_system_prompt(self, state):
# Complete control over the system prompt
# By default, this combines: format_outcome_space(), format_nmi_info(),
# format_own_ufun(), format_partner_ufun(), format_response_instructions()
return f"""You are an aggressive negotiator who never accepts the first offer.
{self.format_outcome_space(state)}
{self.format_own_ufun(state)}
{self.format_response_instructions()}
Always aim for at least 80% of your maximum utility."""
def build_user_message(self, state, offer, source):
# Complete control over the per-round user message
if offer is not None:
return f"Round {state.step}: Opponent offered {offer}. Counter aggressively."
return f"Round {state.step}: Make an ambitious opening offer."
Documentation
Full documentation is available at negmas-llm.readthedocs.io.
License
GNU Affero General Public License v3.0 or later - see LICENSE for details.
Related Projects
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file negmas_llm-0.1.2.tar.gz.
File metadata
- Download URL: negmas_llm-0.1.2.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16d28eb8224077fe5562a50164af4955e06f415cee9dda2846a512afabc6659c
|
|
| MD5 |
f38b0a33c63a87af00cd71affcd9bcb9
|
|
| BLAKE2b-256 |
f210c5d3d8deaff2cddfc243a21dfbac07b126d195f7758963cb21effe4df267
|
Provenance
The following attestation bundles were made for negmas_llm-0.1.2.tar.gz:
Publisher:
publish.yml on autoneg/negmas-llm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
negmas_llm-0.1.2.tar.gz -
Subject digest:
16d28eb8224077fe5562a50164af4955e06f415cee9dda2846a512afabc6659c - Sigstore transparency entry: 806990320
- Sigstore integration time:
-
Permalink:
autoneg/negmas-llm@0e4b3025ccbfe6514df83b8de803f1ef2fed8f3c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/autoneg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0e4b3025ccbfe6514df83b8de803f1ef2fed8f3c -
Trigger Event:
push
-
Statement type:
File details
Details for the file negmas_llm-0.1.2-py3-none-any.whl.
File metadata
- Download URL: negmas_llm-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06eff9bc41f7b3c313d2758d86763c6c90ee9436d72676c9317db525874c76a2
|
|
| MD5 |
82721d8f94098de8bdcd9c56e6c78d6c
|
|
| BLAKE2b-256 |
4edc1ce9b35d8d8f45b088347dde01affeea28c7c3336716187569ac6ccfa5fd
|
Provenance
The following attestation bundles were made for negmas_llm-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on autoneg/negmas-llm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
negmas_llm-0.1.2-py3-none-any.whl -
Subject digest:
06eff9bc41f7b3c313d2758d86763c6c90ee9436d72676c9317db525874c76a2 - Sigstore transparency entry: 806990371
- Sigstore integration time:
-
Permalink:
autoneg/negmas-llm@0e4b3025ccbfe6514df83b8de803f1ef2fed8f3c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/autoneg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0e4b3025ccbfe6514df83b8de803f1ef2fed8f3c -
Trigger Event:
push
-
Statement type: