diff --git a/ai_chat/agents.py b/ai_chat/agents.py index 1ac5a7a4b7..a9dc69963b 100644 --- a/ai_chat/agents.py +++ b/ai_chat/agents.py @@ -218,9 +218,9 @@ class SearchAgent(BaseChatAgent): you should include this parameter based on the following dictionary: {OfferedBy.as_dict()} DO NOT USE THE offered_by FILTER OTHERWISE. -certificate: true if the user is interested in resources that offer certificates, false -if the user does not want resources with a certificate offered. Do not used this filter -if the user does not indicate a preference. +certification: true if the user is interested in resources that offer certificates, +false if the user does not want resources with a certificate offered. Do not use +this filter if the user does not indicate a preference. free: true if the user is interested in free resources, false if the user is only interested in paid resources. Do not used this filter if the user does not indicate @@ -282,7 +282,7 @@ class SearchToolSchema(pydantic.BaseModel): q: The search query string resource_type: Filter by type of resource (course, program, etc) free: Filter for free resources only - certificate: Filter for resources offering certificates + certification: Filter for resources offering certificates offered_by: Filter by institution offering the resource """ @@ -301,7 +301,7 @@ class SearchToolSchema(pydantic.BaseModel): default=None, description="Whether the resource is free to access, true|false", ) - certificate: Optional[bool] = Field( + certification: Optional[bool] = Field( default=None, description=( "Whether the resource offers a certificate upon completion, true|false" @@ -319,7 +319,7 @@ class SearchToolSchema(pydantic.BaseModel): "q": "machine learning", "resource_type": ["course"], "free": True, - "certificate": False, + "certification": False, "offered_by": "MIT", } ] @@ -366,7 +366,7 @@ def search_courses(self, q: str, **kwargs) -> str: "resource_type": kwargs.get("resource_type"), "free": kwargs.get("free"), "offered_by": kwargs.get("offered_by"), - "certificate": kwargs.get("certificate"), + "certification": kwargs.get("certification"), } params.update({k: v for k, v in valid_params.items() if v is not None}) self.search_parameters.append(params) @@ -461,7 +461,6 @@ def get_comment_metadata(self) -> str: "metadata": { "search_parameters": self.search_parameters, "search_results": self.search_results, - "system_prompt": self.instructions, } } return json.dumps(metadata) diff --git a/ai_chat/agents_test.py b/ai_chat/agents_test.py index 2ae8b415f0..f5fd5e6029 100644 --- a/ai_chat/agents_test.py +++ b/ai_chat/agents_test.py @@ -208,7 +208,7 @@ def test_search_agent_tool(settings, mocker): "q": "physics", "resource_type": ["course", "program"], "free": False, - "certificate": True, + "certification": True, "offered_by": "xpro", "limit": 5, } diff --git a/frontends/main/src/app-pages/ChatPage/ChatPage.tsx b/frontends/main/src/app-pages/ChatPage/ChatPage.tsx index 39b65f0eaf..6b3e4b5ada 100644 --- a/frontends/main/src/app-pages/ChatPage/ChatPage.tsx +++ b/frontends/main/src/app-pages/ChatPage/ChatPage.tsx @@ -7,11 +7,24 @@ import { NluxAiChat } from "@/page-components/Nlux-AiChat/AiChat" import { FeatureFlags } from "@/common/feature_flags" import { useFeatureFlagEnabled } from "posthog-js/react" -const CONVERSATION_OPTTIONS = { +const CONVERSATION_OPTIONS = { conversationStarters: [ - { prompt: "I'm interested in quantum computing." }, - { prompt: "I want to learn about global warming." }, - { prompt: "I am curious about AI applications for business." }, + { + prompt: + "I'm interested in courses on quantum computing that offer certificates.", + }, + { + prompt: + "I want to learn about global warming, can you recommend any videos?", + }, + { + prompt: + "I am curious about AI applications for business. Do you have any free courses about that?", + }, + { + prompt: + "I would like to learn about linear regression, preferably at no cost.", + }, ], } @@ -41,7 +54,7 @@ const ChatPage = () => { ) : ( <> diff --git a/frontends/ol-utilities/src/lib/utils.ts b/frontends/ol-utilities/src/lib/utils.ts index c5dbaf81c7..b7d7b6da42 100644 --- a/frontends/ol-utilities/src/lib/utils.ts +++ b/frontends/ol-utilities/src/lib/utils.ts @@ -71,5 +71,10 @@ export const pluralize = (singular: string, count: number, plural?: string) => { */ export const extractJSONFromComment = (comment: string) => { const jsonStr = comment.toString().match(//)?.[1] || "{}" - return JSON.parse(jsonStr) + try { + return JSON.parse(jsonStr) + } catch (e) { + console.error("error parsing JSON from comment", comment, e) + return {} + } }