Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions backend/app/conversations/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ async def send(self, user_id: str, session_id: int, user_input: str, clear_memor
filter_pii: bool,
city: str | None = None,
province: str | None = None,
discuss_recommendations: bool = True) -> ConversationResponse:
discuss_recommendations: bool = True,
is_artificial: bool = False) -> ConversationResponse:
# TODO: discuss filter pii and clear_memory
"""
Get a message from the user and return a response from Compass, save the message and response into the application state
Expand Down Expand Up @@ -151,14 +152,15 @@ async def send(self, user_id: str, session_id: int, user_input: str, clear_memor
filter_pii: bool,
city: str | None = None,
province: str | None = None,
discuss_recommendations: bool = True) -> ConversationResponse:
discuss_recommendations: bool = True,
is_artificial: bool = False) -> ConversationResponse:
if clear_memory:
await self._application_state_metrics_recorder.delete_state(session_id)
if filter_pii:
user_input = await sensitive_filter.obfuscate(user_input)

# set the sent_at for the user input
user_input = AgentInput(message=user_input, sent_at=datetime.now(timezone.utc))
user_input = AgentInput(message=user_input, sent_at=datetime.now(timezone.utc), is_artificial=is_artificial)

state = await self._application_state_metrics_recorder.get_state(session_id, city=city, province=province)

Expand Down Expand Up @@ -306,6 +308,7 @@ async def refresh_recommendations(self, user_id: str, session_id: int,
filter_pii=False,
city=city,
province=province,
is_artificial=True,
)

def _should_save_preference_vector(self, state: ApplicationState) -> bool:
Expand Down
3 changes: 2 additions & 1 deletion backend/app/conversations/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def _create_test_client_with_mocks(auth) -> TestClientWithMocks:
# mock the conversation service
class MockConversationService(IConversationService):
async def send(self, user_id: str, session_id: int, user_input: str, clear_memory: bool, filter_pii: bool,
city: str | None = None, province: str | None = None, discuss_recommendations: bool = True):
city: str | None = None, province: str | None = None, discuss_recommendations: bool = True,
is_artificial: bool = False):
raise NotImplementedError

async def get_history_by_session_id(self, user_id: str, session_id: int):
Expand Down
48 changes: 34 additions & 14 deletions frontend-new/src/chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
parseConversationPhase,
} from "./util";
import { useSnackbar } from "src/theme/SnackbarProvider/SnackbarProvider";
import { Box, Fab, Tooltip, useTheme } from "@mui/material";
import { Box, Fab, useTheme } from "@mui/material";
import AutorenewIcon from "@mui/icons-material/Autorenew";
import debounce from "lodash.debounce";
import ChatHeader from "./ChatHeader/ChatHeader";
Expand Down Expand Up @@ -1185,19 +1185,39 @@ export const Chat: React.FC<Readonly<ChatProps>> = ({
>
<ChatList messages={messages} />
{currentPhase.phase === ConversationPhase.RECOMMENDATION && (
<Tooltip title={t("chat.chat.refreshRecommendations.tooltip")} placement="left">
<span style={{ position: "sticky", bottom: theme.spacing(2), float: "right", display: "block" }}>
<Fab
size="small"
color="primary"
disabled={aiIsTyping || isRefreshingRecommendations}
onClick={() => activeSessionId && handleRefreshRecommendations(activeSessionId)}
aria-label={t("chat.chat.refreshRecommendations.tooltip")}
>
<AutorenewIcon />
</Fab>
</span>
</Tooltip>
<Box
sx={{
position: "sticky",
bottom: theme.spacing(2),
display: "flex",
justifyContent: "flex-end",
pointerEvents: "none",
}}
>
<Fab
variant="extended"
size="small"
color="primary"
disabled={aiIsTyping || isRefreshingRecommendations}
onClick={() => activeSessionId && handleRefreshRecommendations(activeSessionId)}
aria-label={t("chat.chat.refreshRecommendations.label")}
sx={{
pointerEvents: "auto",
textTransform: "none",
fontWeight: 500,
fontSize: { xs: "0.75rem", md: "0.8125rem" },
paddingX: { xs: 1.25, md: 1.5 },
height: { xs: 32, md: 34 },
minHeight: 0,
}}
>
<AutorenewIcon
fontSize="small"
sx={{ marginRight: 0.5, fontSize: { xs: "1rem", md: "1.125rem" } }}
/>
{t("chat.chat.refreshRecommendations.label")}
</Fab>
</Box>
)}
</Box>
{showBackdrop && <InactiveBackdrop isShown={showBackdrop} />}
Expand Down
2 changes: 1 addition & 1 deletion frontend-new/src/i18n/locales/en-GB/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"confirmation": "Are you sure you want to start a new conversation?"
},
"refreshRecommendations": {
"tooltip": "Get new recommendations"
"label": "Refresh recommendations"
},
"refreshConfirmationDialog": {
"title": "Are you sure you would like to refresh?",
Expand Down
2 changes: 1 addition & 1 deletion frontend-new/src/i18n/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"confirmation": "Are you sure you want to start a new conversation?"
},
"refreshRecommendations": {
"tooltip": "Get new recommendations"
"label": "Refresh recommendations"
},
"refreshConfirmationDialog": {
"title": "Are you sure you would like to refresh?",
Expand Down
2 changes: 1 addition & 1 deletion frontend-new/src/i18n/locales/es-AR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"confirmation": "¿Estás seguro de que deseas iniciar una nueva conversación?"
},
"refreshRecommendations": {
"tooltip": "Obtener nuevas recomendaciones"
"label": "Actualizar recomendaciones"
},
"refreshConfirmationDialog": {
"title": "¿Estás seguro de que querés actualizar?",
Expand Down
2 changes: 1 addition & 1 deletion frontend-new/src/i18n/locales/es-ES/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"confirmation": "¿Estás seguro de que deseas iniciar una nueva conversación?"
},
"refreshRecommendations": {
"tooltip": "Obtener nuevas recomendaciones"
"label": "Actualizar recomendaciones"
},
"refreshConfirmationDialog": {
"title": "¿Estás seguro de que quieres actualizar?",
Expand Down
2 changes: 1 addition & 1 deletion frontend-new/src/i18n/locales/sw-KE/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"confirmation": "Una uhakika unataka kuanza mazungumzo mapya?"
},
"refreshRecommendations": {
"tooltip": "Pata mapendekezo mapya"
"label": "Onyesha mapendekezo upya"
},
"refreshConfirmationDialog": {
"title": "Una uhakika ungependa kupaisha upya?",
Expand Down
Loading