A hybrid travel itinerary planner that uses natural language constraints, LLM-based code generation, and Z3 optimization to solve multi-city travel planning problems.
- Input: user query (text constraints + persona + destination/origin/dates)
- Pipeline:
- Normalize with LLM prompt (role: turn query into JSON)
- Convert constraints → planning steps via LLM (e.g., destination, departure, transportation, budget)
- Convert steps → Python code templates via LLM prompts
- Append hard-coded solve routine (
prompts/solve_{3,5,7}.txt) - Execute generated code with Z3 solver (
z3Optimize/Solver) - If satisfiable, generate an initial travel plan
- Run POI scheduling with Z3 solver and optimizer
- Produce the final travel plan with POI scheduling
run_planner.py: main workflow and pipeline implementation.z3_code_execution.py: execute generated code in parallel across query batch outputs.z3_temporal_scheduler.py: temporal POI scheduling and itinerary optimization.z3_temporal_scheduler_with_relaxation.py: temporal POI scheduling with relaxation using soft constraints for more flexible schedule generation.tools/: API wrapper modules for external data fetching.cities/apis.pyflights/apis.pyaccommodations/apis.pyattractions/apisv3.pygoogleDistanceMatrix/apis.pyrestaurants/apis.py
prompts/: prompt templates for LLM stages.utils/: helper logic (budget, selection, etc.).openai_func.py/open_source_models.py: LLM integration utilities.requirements.txt: Python dependencies.output/: generated run outputs (plans, codes, logs).
-
Clone the repo:
git clone <repo-url> cd TripWeaver
After cloning the repo put the tripcraft database in the root folder. TripCraft_database folder should be in root folder ie., tripcraft_3day.csv, tripcraft_5day.csv, tripcraft_7day.csv should be in root folder.
-
Create and activate a Python environment:
- Using
conda(env nametripweaver):conda create -n tripweaver python=3.11 -y conda activate tripweaver
-
Install deps:
pip install -r requirements.txt
-
API keys (if you want real external API behavior):
HUGGING_FACE_TOKEN
python run_planner.py --set_type 3d --model_name phiArguments:
--set_type: Dataset type to use3d: Use tripcraft_3day.csv dataset5d: Use tripcraft_5day.csv dataset7d: Use tripcraft_7day.csv dataset- Default:
3d
--model_name: LLM model to use for code generationgpt: OpenAI GPT modelsqwen: Qwen modelphi: Phi modelllama: Llama modelmistral: Mistral model- Default:
gpt
python z3_code_execution.py --days 3d --model_name phiThis script reads generated query.json and codes.txt from output/<set_type>/<model_name>_nl/<index>/, executes the generated Python code in parallel using ProcessPoolExecutor, and writes per-job run results.
python z3_temporal_scheduler.pyor with relaxed scheduling:
python z3_temporal_scheduler_with_relaxation.pyThese scripts process plan outputs and build a scheduled itinerary with POIs, meals, accommodations, and transportation timing.
output/<set_type>/<model_name>_nl/<index>/plans/output/<set_type>/<model_name>_nl/<index>/codes/
# set_type: 3d/5d/7d
cd evaluation
python eval.py --set_type <SET_TYPE> --evaluation_file_path <EVALUATION_FILE_PATH>cd evaluation
python qualitative_metrics.py --gen_file <generated_output_jsonl_file> --anno_file <annotation_jsonl_file>