@@ -157,7 +157,10 @@ class SearchAgentService(BaseChatAgentService):
157
157
dictionary: { OfferedBy .as_dict ()} DO NOT USE THE offered_by FILTER OTHERWISE.
158
158
159
159
If the user mentions courses, programs, videos, or podcasts in particular, filter
160
- the search by resource_category. DO NOT USE THE resource_type FILTER OTHERWISE.
160
+ the search by resource_type. DO NOT USE THE resource_type FILTER OTHERWISE.
161
+ You MUST combine multiple resource types in one request like this:
162
+ "resource_type=course&resource_type=program". Do not attempt more than one query per
163
+ user message.
161
164
162
165
If the user asks what other courses are taught by a particular instructor,
163
166
search the catalog for courses taught by that instructor.
@@ -175,7 +178,9 @@ class SearchToolSchema(pydantic.BaseModel):
175
178
"""Schema for the search_courses function tool"""
176
179
177
180
q : str
178
- resource_type : Optional [enum_zip ("resource_type" , LearningResourceType .names ())]
181
+ resource_type : Optional [
182
+ list [enum_zip ("resource_type" , LearningResourceType .names ())]
183
+ ]
179
184
level : Optional [enum_zip ("level" , LevelType .names ())]
180
185
free : Optional [bool ]
181
186
certificate : Optional [bool ]
@@ -205,6 +210,7 @@ def __init__( # noqa: PLR0913
205
210
)
206
211
self .temperature = temperature
207
212
self .search_parameters = []
213
+ self .search_results = []
208
214
self .agent = self .create_agent ()
209
215
self .create_agent ()
210
216
@@ -247,6 +253,7 @@ def search_courses(self, q: str, **kwargs) -> str:
247
253
{k : result .get (k ) for k in main_properties }
248
254
for result in response .json ().get ("results" , [])
249
255
]
256
+ self .search_results .append (results )
250
257
return json .dumps (results )
251
258
except requests .exceptions .RequestException as e :
252
259
log .exception ("Error querying MIT API" )
@@ -289,6 +296,7 @@ def get_comment_metadata(self):
289
296
metadata = {
290
297
"metadata" : {
291
298
"search_parameters" : self .search_parameters ,
299
+ "search_results" : self .search_results ,
292
300
"system_prompt" : self .instructions ,
293
301
}
294
302
}
0 commit comments