An AI-powered conversation optimization service that uses Monte Carlo Tree Search (MCTS) and Large Language Models to suggest optimal conversational moves and evaluate conversation quality.
- Conversation optimization using MCTS
- Multi-dimensional conversation evaluation
- FastAPI-based REST API
- Caching and rate limiting for LLM calls
- Async support for improved performance
- Clone the repository:
git clone https://github.com/yourusername/conversation-optimizer.git
cd conversation-optimizer
- Install uv (if not already installed):
pip install uv
- Create a virtual environment and install dependencies:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .
- Create a
.env
file in the project root with your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
LLM_MODEL=gpt-3.5-turbo # Optional: Change the model
- Start the API server:
uvicorn src.api.main:app --reload
-
The API will be available at
http://localhost:8000
-
Access the API documentation at
http://localhost:8000/docs
Optimize a conversation by suggesting the best next moves.
Request:
{
"conversation": [
{"speaker": "you", "text": "Hi, I wanted to discuss our project strategy."},
{"speaker": "opponent", "text": "I'm concerned about the risks involved."}
],
"goal": "Discuss project strategy while addressing risks"
}
Evaluate a conversation based on multiple dimensions.
Request:
{
"conversation": [
{"speaker": "you", "text": "Hi, I wanted to discuss our project strategy."},
{"speaker": "opponent", "text": "I'm concerned about the risks involved."}
],
"goal": "Discuss project strategy while addressing risks"
}
- Install development dependencies:
uv pip install -e ".[dev]"
- Run tests:
pytest
- Format code:
black src/
isort src/
- Run linting:
ruff check src/
mypy src/
The application can be configured through environment variables or a .env
file:
OPENAI_API_KEY
: Your OpenAI API key (required)LLM_MODEL
: The LLM model to use (default: gpt-3.5-turbo)SIMULATION_DEPTH
: MCTS simulation depth (default: 4)SIMULATION_BREADTH
: MCTS simulation breadth (default: 5)MCTS_ITERATIONS
: Number of MCTS iterations (default: 20)
See src/api/core/config.py
for all available settings.
MIT License