iT邦幫忙

2025 iThome 鐵人賽

DAY 27
0
Cloud Native

《30 天 Cloud Native:AI 行程規劃後端開發》系列 第 27

Day27 - 提升旅遊行程解析準確性的提示設計

  • 分享至 

  • xImage
  •  

在設計旅遊行程的自動化系統時,提示語(Prompt)的精準性直接影響解析結果與使用者體驗。為了讓生成的行程更貼近真實需求,我們針對活動類型、時間連貫性、地點資訊與使用者偏好等面向,設計了一系列提示語,以提升系統的穩定性與靈活性。

因為沒有特別限定活動型態和交通方式,有時候會有其他不同的值導致解析失敗,所以加入以下 Prompt :

- The activity type must be one of the following: sightseeing, restaurant, shopping, accommodation, freeTime, transport, or other.
- The transportType must be one of the following: train, highSpeedTrain, flight, bus, taxi, bike, walk, car, boat, motorcycle, or other

活動與活動之前不連貫,會有一些空著的時間,所以加入以下 Prompt :

- Please ensure that the each activity has the continuous time slot. Use `freeTime` to fill any gaps and prevent empty activity slots.

有時候會出現不同 Activity 但卻是在同的地點的狀況,所以當經緯度相同時自動合併成一個活動:

- Consolidate activities into childActivities when their lantitude and longitude are the same.

避免地點文字過長不好閱讀,請 Agent 縮短字數:

- Trim the location name to a maximum 10 words.

避免有些活動只是個大範圍的地點導致經緯度定位在正中央,加入當不確定地點時不要填入經緯度的條件:

- If the activity location is not a specific place, remove the `placeUri` and `latLng` fields.

新增行程緊湊度, 0 為最輕鬆, 10 為最緊湊,提供更多的客製化:

    if payload.pace != None:
        prompt += (
            f'The pace level range from 0 to 10, '
            f'where 0 indicates a relaxed trip and 10 represents an intense one. '
            f'This trip has a pace level {payload.pace}. '
        )

新增偏好的交通方式,為了保留彈性使用 List 來儲存:

    if payload.transportTypes:
        prompt += f'The prefered transport types for this trip are '
        prompt += ','.join(payload.transportTypes) + '. '

透過這些提示語的設計與優化,我們不僅提升了行程解析的準確度,也讓使用者能夠獲得更符合期待的旅遊規劃結果。未來,我們將持續根據使用者回饋與實際案例,調整提示策略,打造更智慧、更貼心的旅遊行程生成體驗。


上一篇
Day26 - AI 行程修改 API 實作與對話流程解析
下一篇
Day28 - Vertex AI 資源耗盡與模型重構心得
系列文
《30 天 Cloud Native:AI 行程規劃後端開發》29
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言