Update routing prompt for UTC timestamps and current date/time.

Changed `SYSTEM_PROMPT` to a dynamic value that includes the current date and time in UTC format. This enhances the precision and relevance of the extracted routing information by ensuring timestamps are always up to date.
This commit is contained in:
sku 2024-09-18 14:01:56 +02:00
parent cf1770182c
commit 3f87add6e0
1 changed files with 9 additions and 4 deletions

View File

@ -4,6 +4,9 @@ import com.fasterxml.jackson.databind.ObjectMapper
import de.hbt.routing.openai.OpenAIService
import de.hbt.routing.openai.dto.ChatRequest.Companion.chatRequest
import org.springframework.stereotype.Service
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneOffset
@Service
class RoutingParametersService(private val conversationCache: ConversationCache, private val openAIService: OpenAIService, private val objectMapper: ObjectMapper) {
@ -29,7 +32,7 @@ class RoutingParametersService(private val conversationCache: ConversationCache,
}
companion object {
private const val SYSTEM_PROMPT = """
private val SYSTEM_PROMPT = """
You are a smart assistant that helps users with routing requests. Your goal is to extract three key parameters from each user query: the start location, destination location, and time. When a user provides a routing request, parse the following:
Start: The location where the journey begins (e.g., city, point of interest, address).
@ -39,13 +42,15 @@ Your task is to always output a structured JSON object with these three fields.
For example:
Input: 'How do I get from New York to Boston at 9 AM?'
Output: {"start": "New York", "destination": "Boston", "time": "9 AM"}
Input: How do I get from New York to Boston at 9 PM?
Output: {"start": "New York", "destination": "Boston", "time": "${LocalDate.now()}T21:00:00Z"}
Assume that the user means the next AM or PM time and adjust the time by adding 12 hours if necessary.
Always format the time as a UTC timestamp. Assumes that the current time is ${LocalDateTime.now().atOffset(ZoneOffset.UTC)}.
If the user does not specify a time, mark it as null.
If the input is ambiguous, do your best to infer the meaning and provide the most likely interpretation.
Be concise, clear, and precise in your extraction. Return a plain unformatted json (no markdown)."
Be concise, clear, and precise in your extraction. Return a plain unformatted json (no markdown).
"""
}
}