Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,28 @@ import { Lightbulb, ThumbsDown, ThumbsUp } from "@/icons/app"

import { F0AiChat, F0AiChatProvider, useAiChat } from ".."

const AiChatWrapper = ({ children }: { children: React.ReactElement }) => {
const { setOpen, setWelcomeScreenSuggestions } = useAiChat()
const defaultSuggestions = [
{
icon: Lightbulb,
message: "Hello, how can I help you today?",
prompt: "Hello, how can I help you today?",
},
{
icon: ThumbsUp,
message: "Share feedback",
prompt:
"Share feedback and help shape One with your feedback in the next message (optional)",
},
{
icon: ThumbsDown,
message: "Very long message to test the layout of the suggestions list",
prompt:
"Very long message to test the layout of the suggestions list and help shape One with your feedback in the next message (optional)",
},
]

useEffect(() => {
setWelcomeScreenSuggestions([
{
icon: Lightbulb,
message: "Hello, how can I help you today?",
prompt: "Hello, how can I help you today?",
},
{
icon: ThumbsUp,
message: "Share feedback",
prompt:
"Share feedback and help shape One with your feedback in the next message (optional)",
},
{
icon: ThumbsDown,
message: "Very long message to test the layout of the suggestions list",
prompt:
"Very long message to test the layout of the suggestions list and help shape One with your feedback in the next message (optional)",
},
])
}, [setWelcomeScreenSuggestions])
const AiChatWrapper = ({ children }: { children: React.ReactElement }) => {
const { setOpen } = useAiChat()

useEffect(() => {
setOpen(true)
Expand Down Expand Up @@ -56,6 +54,7 @@ const meta = {
credentials="include"
showDevConsole={false}
greeting="Hello, John"
welcomeScreenSuggestions={defaultSuggestions}
disclaimer={{
text: "One works within your permissions.",
link: "/permissions",
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/sds/ai/F0AiChat/internal-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ export type AiChatProviderReturnValue = {
React.SetStateAction<string | string[] | undefined>
>
welcomeScreenSuggestions: WelcomeScreenSuggestion[]
setWelcomeScreenSuggestions: React.Dispatch<
React.SetStateAction<WelcomeScreenSuggestion[]>
>
onThumbsUp?: (
message: AIMessage,
{ threadId, feedback }: { threadId: string; feedback: string }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
import { useI18n } from "@/lib/providers/i18n"

import { AiChatProviderReturnValue, AiChatState } from "../internal-types"
import { WelcomeScreenSuggestion } from "../types"

const AiChatStateContext = createContext<AiChatProviderReturnValue | null>(null)

Expand Down Expand Up @@ -55,9 +54,6 @@ export const AiChatStateProvider: FC<PropsWithChildren<AiChatState>> = ({
const [shouldPlayEntranceAnimation, setShouldPlayEntranceAnimation] =
useState(true)
const [agent, setAgent] = useState<string | undefined>(initialAgent)
const [welcomeScreenSuggestions, setWelcomeScreenSuggestions] = useState<
WelcomeScreenSuggestion[]
>(initialWelcomeScreenSuggestions)
const i18n = useI18n()
const [placeholders, setPlaceholders] = useState<string[]>([
i18n.t("ai.inputPlaceholder"),
Expand Down Expand Up @@ -164,8 +160,7 @@ export const AiChatStateProvider: FC<PropsWithChildren<AiChatState>> = ({
autoClearMinutes: enabledInternal ? autoClearMinutes : null,
initialMessage,
setInitialMessage,
welcomeScreenSuggestions,
setWelcomeScreenSuggestions,
welcomeScreenSuggestions: initialWelcomeScreenSuggestions,
onThumbsUp,
onThumbsDown,
clear,
Expand Down Expand Up @@ -210,7 +205,6 @@ export function useAiChat(): AiChatProviderReturnValue {
placeholders: [],
setPlaceholders: noopFn,
welcomeScreenSuggestions: [],
setWelcomeScreenSuggestions: noopFn,
onThumbsUp: noopFn,
onThumbsDown: noopFn,
sendMessage: noopFn,
Expand Down
Loading