@@ -29,13 +29,6 @@ import (
2929 "strings"
3030)
3131
32- type POIQuery struct {
33- Location string
34- Query string
35- LanguageCode string
36- Units string
37- }
38-
3932type POIResponse struct {
4033 Results []util.POI
4134 Warning string `json:"CriticalRequirement,omitempty"`
@@ -70,12 +63,12 @@ func init() {
7063 },
7164 Fn : searchPoi ,
7265 Thought : searchPoiThought ,
73- InputType : POIQuery {},
66+ InputType : util. POIQuery {},
7467 })
7568}
7669
7770func searchPoiThought (args any ) string {
78- poiQuery := args .(* POIQuery )
71+ poiQuery := args .(* util. POIQuery )
7972 if poiQuery .Location != "" {
8073 location , _ , _ := strings .Cut (poiQuery .Location , "," )
8174 return fmt .Sprintf ("Looking for %s near %s..." , poiQuery .Query , location )
@@ -86,7 +79,14 @@ func searchPoiThought(args any) string {
8679func searchPoi (ctx context.Context , quotaTracker * quota.Tracker , args any ) any {
8780 ctx , span := beeline .StartSpan (ctx , "search_poi" )
8881 defer span .Send ()
89- poiQuery := args .(* POIQuery )
82+ threadContext := query .ThreadContextFromContext (ctx )
83+ poiQuery := args .(* util.POIQuery )
84+ if threadContext .ContextStorage .PoiQuery != nil && poiQuery .Equal (threadContext .ContextStorage .PoiQuery ) {
85+ log .Printf ("Reusing the POI results from before." )
86+ return & POIResponse {
87+ Results : threadContext .ContextStorage .POIs ,
88+ }
89+ }
9090 span .AddField ("query" , poiQuery .Query )
9191 location := query .LocationFromContext (ctx )
9292 if poiQuery .Location != "" {
@@ -183,8 +183,8 @@ func searchPoi(ctx context.Context, quotaTracker *quota.Tracker, args any) any {
183183 }
184184 }
185185
186- threadContext := query .ThreadContextFromContext (ctx )
187186 threadContext .ContextStorage .POIs = pois
187+ threadContext .ContextStorage .PoiQuery = poiQuery
188188
189189 var attributionList []string
190190 for provider := range attributions {
0 commit comments