mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: use session access_tokens
This commit is contained in:
parent
08cc97f557
commit
52f2235942
74 changed files with 413 additions and 440 deletions
|
|
@ -24,6 +24,7 @@ import {
|
|||
startActivityAIChatSession,
|
||||
} from '@services/ai/ai'
|
||||
import useGetAIFeatures from '@components/AI/Hooks/useGetAIFeatures'
|
||||
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||
|
||||
type AIEditorToolkitProps = {
|
||||
editor: Editor
|
||||
|
|
@ -32,11 +33,11 @@ type AIEditorToolkitProps = {
|
|||
|
||||
type AIPromptsLabels = {
|
||||
label:
|
||||
| 'Writer'
|
||||
| 'ContinueWriting'
|
||||
| 'MakeLonger'
|
||||
| 'GenerateQuiz'
|
||||
| 'Translate'
|
||||
| 'Writer'
|
||||
| 'ContinueWriting'
|
||||
| 'MakeLonger'
|
||||
| 'GenerateQuiz'
|
||||
| 'Translate'
|
||||
selection: string
|
||||
}
|
||||
|
||||
|
|
@ -141,6 +142,8 @@ function AIEditorToolkit(props: AIEditorToolkitProps) {
|
|||
const UserFeedbackModal = (props: AIEditorToolkitProps) => {
|
||||
const dispatchAIEditor = useAIEditorDispatch() as any
|
||||
const aiEditorState = useAIEditor() as AIEditorStateTypes
|
||||
const session = useLHSession() as any
|
||||
const access_token = session.data.tokens.access_token;
|
||||
|
||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
await dispatchAIEditor({
|
||||
|
|
@ -159,7 +162,7 @@ const UserFeedbackModal = (props: AIEditorToolkitProps) => {
|
|||
const response = await sendActivityAIChatMessage(
|
||||
message,
|
||||
aiEditorState.aichat_uuid,
|
||||
props.activity.activity_uuid
|
||||
props.activity.activity_uuid, access_token
|
||||
)
|
||||
if (response.success === false) {
|
||||
await dispatchAIEditor({ type: 'setIsNoLongerWaitingForResponse' })
|
||||
|
|
@ -191,7 +194,7 @@ const UserFeedbackModal = (props: AIEditorToolkitProps) => {
|
|||
})
|
||||
await dispatchAIEditor({ type: 'setIsWaitingForResponse' })
|
||||
const response = await startActivityAIChatSession(
|
||||
message,
|
||||
message, access_token,
|
||||
props.activity.activity_uuid
|
||||
)
|
||||
if (response.success === false) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue