Skip to content

Latest commit

 

History

History
91 lines (60 loc) · 4.32 KB

File metadata and controls

91 lines (60 loc) · 4.32 KB

📄 Prompt Documentation – LLM Integration

Author:Peter Muturi Contact:peterwairimu2019@gmail.com Last Updated:27th/May/2025

🔍 Purpose

The prompt system is designed to dynamically generate localized, contextual instructions for the LLM (GPT-3.5-turbo), based on user questions. It helps the assistant deliver accurate, structured, and relevant information specifically tailored for Kenyan travelers.


🧠 Prompt Generation Strategy

Base Prompt (System Instruction):

You are a helpful travel assistant based in Kenya. Your goal is to provide accurate, up-to-date, and structured travel advice to Kenyan citizens who are preparing to travel abroad.

This base prompt is always included to:

  • Establish geographic and cultural context (Kenya-based).
  • Ensure answers remain relevant to Kenyan citizens.
  • Encourage well-organized responses (e.g., in bullet points).

🧩 Intent-Based Prompt Variants

To provide better context to the LLM, the prompt is expanded depending on detected keywords or "intent" in the user's question.

Intent Detected Trigger Keywords Prompt Additions
Visa Information visa "Focus specifically on visa requirements, types of visas, embassy locations, application fees, and processing timelines for Kenyan citizens."
Passport Requirements passport "Give detailed advice on passport validity, renewal options in Kenya, and any extra documentation needed based on the destination."
Flight Booking flight, book "Provide insights on booking flights from major Kenyan airports, budget airlines, layovers, and flight preparation tips."
Weather & Packing weather, pack "Include destination-specific weather details and packing suggestions for Kenyan travelers."
Travel Documents documents "List all essential travel documents required for Kenyan citizens traveling to the mentioned destination."
Default/General Travel Help (no match) "Provide general travel advice in bullet points."

🧾 Final Prompt Template

The full user prompt sent to the LLM looks like this:

{base_intro}
{intent_based_addition}

Question: {user_input}
Answer in bullet points if possible.

Example – User Question:

"What documents do I need to travel from Kenya to Ireland?"

Final Prompt Sent:

You are a helpful travel assistant based in Kenya. Your goal is to provide accurate, up-to-date, and structured travel advice to Kenyan citizens who are preparing to travel abroad. List all essential travel documents required for Kenyan citizens traveling to the mentioned destination.

Question: What documents do I need to travel from Kenya to Ireland?
Answer in bullet points if possible.

🛠 File Location

All prompt logic is implemented in:

backend/app/llm_service.py
  • build_prompt(question: str) handles prompt generation.
  • generate_response(question: str) sends the prompt to OpenAI’s GPT-3.5 API.

💡 Future Enhancements

Idea Description
✨ NLP-based intent detection Use keyword scoring or ML models to detect user intent more accurately.
🌍 Dynamic localization Add logic to localize prompts for different countries if supporting more than Kenya.
🧾 Prompt templates Store prompts in a JSON/YAML or CMS to allow non-developers to update them.
🧠 Prompt tuning Test multiple variations of prompts to improve output accuracy.