Binary files /dev/null and b/public/svg/copy/Bold-dark.png differ Binary files /dev/null and b/public/svg/copy/Bold.png differ Binary files /dev/null and b/public/svg/copy/Center-dark.png differ Binary files /dev/null and b/public/svg/copy/Center.png differ Binary files /dev/null and b/public/svg/copy/Italic-dark.png differ Binary files /dev/null and b/public/svg/copy/Italic.png differ Binary files /dev/null and b/public/svg/copy/Left-dark.png differ Binary files /dev/null and b/public/svg/copy/Left.png differ Binary files /dev/null and b/public/svg/copy/Ordered-dark.png differ Binary files /dev/null and b/public/svg/copy/Ordered.png differ Binary files /dev/null and b/public/svg/copy/Redo-dark.png differ Binary files /dev/null and b/public/svg/copy/Redo.png differ Binary files /dev/null and b/public/svg/copy/Right-dark.png differ Binary files /dev/null and b/public/svg/copy/Right.png differ Binary files /dev/null and b/public/svg/copy/Underline-dark.png differ Binary files /dev/null and b/public/svg/copy/Underline.png differ Binary files /dev/null and b/public/svg/copy/Undo-dark.png differ Binary files /dev/null and b/public/svg/copy/Undo.png differ Binary files /dev/null and b/public/svg/copy/Unordered-dark.png differ Binary files /dev/null and b/public/svg/copy/Unordered.png differ @@ -0,0 +1,24 @@ + + + + \ No newline at end of file Binary files /dev/null and b/public/spin-spinning.gif differ @@ -1,15 +0,0 @@ -import { Template } from '@/src/domains/copywrite/proxy/types/template' - -export const emptyTemplate: Template = { - id: 1000, - title: 'Пустой шаблон', - content: '', - keywords: [], - tov: '', - language: '', - theme: '', - resources_urls: [], - picture: '123', - target_audience: '', - description: '', -} @@ -1,6 +0,0 @@ -import { ContentState, EditorState } from 'draft-js' - -export const toEditorState = (text: string) => { - const newContentState = ContentState.createFromText(text) - return EditorState.createWithContent(newContentState) -} @@ -1,13 +0,0 @@ -export interface Template { - id: number - title: string - description: string - picture: string - theme: string - content: string - target_audience: string - resources_urls: string[] - keywords: string[] - tov: string - language: string -} @@ -1,34 +0,0 @@ -import axios from 'axios' - -import { Template } from '@/src/domains/copywrite/proxy/types/template' -import { API_URL } from '@/src/shared/lib/constants' -import { Message } from '@/src/shared/lib/types/model' - -export class CopywriteProxy { - token?: string - - constructor(token: string | undefined) { - this.token = token - } - - static async getGeneration(token?: string): Promise { - const { data } = await axios.get(API_URL + '/copywrite/', { - headers: { Authorization: `Bearer ${token}` }, - }) - return data - } - - static async getTemplates(token?: string): Promise { - const { data } = await axios.get(API_URL + '/copywrite/templates/', { - headers: { Authorization: `Bearer ${token}` }, - }) - return data - } - - static async createTemplates(token?: string): Promise { - const { data } = await axios.post(API_URL + '/copywrite/templates/', { - headers: { Authorization: `Bearer ${token}` }, - }) - return data - } -} @@ -1,30 +0,0 @@ -import React from 'react' -import { Typography } from '@mui/material' - -import { Input, Slider } from '@/src/shared' - -import { FiltersProps } from './types' - -export function Filters({ - strength, - setStrength, - upscale, - setUpscale, - negative_prompt, - num_inference_steps, - guidance_scale, - setGuidanceScale, - setNegative_prompt, - setSteps, -}: FiltersProps) { - return ( - <> - - - - - Запрос для исключения из генерации - - - ) -} @@ -1,17 +0,0 @@ -import { ChangeEvent } from 'react' - -export interface Setting { - strength: number - upscale: number - negative_prompt: string - num_inference_steps: number - guidance_scale: number -} - -export interface FiltersProps extends Setting { - setStrength: (e: Event, cur: number | number[]) => void - setUpscale: (e: Event, cur: number | number[]) => void - setGuidanceScale: (e: Event, cur: number | number[]) => void - setNegative_prompt: (e: ChangeEvent) => void - setSteps: (e: Event, cur: number | number[]) => void -} @@ -1,36 +0,0 @@ -import React from 'react' -import { Stack, Typography } from '@mui/material' - -import { Input, Slider } from '@/src/shared' -import { SelectUI } from '@/src/shared/ui/select' - -import { Filters } from './types' - -const sizes = [128, 256, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024] - -export function EpicPhotoFilters({ - guidance_scale, - height, - negative_prompt, - num_inference_steps, - num_outputs, - setGuidance_scale, - setHeight, - setNegative_prompt, - setNum_inference_steps, - setNum_outputs, - setWidth, - width, -}: Filters) { - return ( - <> - - - - - - Запрос для исключения из генерации - - - ) -} @@ -1,2 +0,0 @@ -export * from './epic-photo-filters' -export * from './types' @@ -1,20 +0,0 @@ -import { ChangeEvent, ChangeEventHandler } from 'react' -import { SelectChangeEvent } from '@mui/material' - -export interface Setting { - num_outputs: number - negative_prompt: string - width: number - height: number - num_inference_steps: number - guidance_scale: number -} - -export interface Filters extends Setting { - setWidth: (e: SelectChangeEvent) => void - setHeight: (e: SelectChangeEvent) => void - setNum_outputs: (e: Event, cur: number | number[]) => void - setNum_inference_steps: (e: Event, cur: number | number[]) => void - setGuidance_scale: (e: Event, cur: number | number[]) => void - setNegative_prompt: (e: ChangeEvent) => void -} @@ -1,2 +0,0 @@ -export * from './kandinsky-filters' -export * from './types' @@ -1,76 +0,0 @@ -import React from 'react' -import { Box, Typography } from '@mui/material' - -import { Input, Slider, SwitchCustom } from '@/src/shared' -import { SelectUI } from '@/src/shared/ui/select' - -import { Filters } from './types' - -export function KandinskyFilters({ - height, - isTranslate, - negativePrompt, - num_outputs, - setHeight, - setNegative_prompt, - setNumber, - setSteps, - setWidth, - steps, - width, - setIsTranslate, -}: Filters) { - return ( - <> - Настройки - - - - - - - - - - - - - - - - Переводить запрос - - - - - - - Запрос для исключения из генерации - - - - - ) -} @@ -1,20 +0,0 @@ -import { ChangeEvent } from 'react' -import { SelectChangeEvent } from '@mui/material' - -export interface Setting { - steps: number - num_outputs: number - width: number - height: number - isTranslate: boolean - negativePrompt: string -} - -export interface Filters extends Setting { - setWidth: (e: SelectChangeEvent) => void - setHeight: (e: SelectChangeEvent) => void - setSteps: (e: Event, cur: number | number[]) => void - setNumber: (e: Event, cur: number | number[]) => void - setNegative_prompt: (e: ChangeEvent) => void - setIsTranslate: () => void -} @@ -1,33 +0,0 @@ -import React from 'react' -import { Typography } from '@mui/material' - -import { Input, Slider } from '@/src/shared' -import { SelectUI } from '@/src/shared/ui/select' - -import { FiltersProps } from './types' - -const sizes = [384, 512, 576, 640, 704, 768] - -export function Filters({ - height, - negative_prompt, - num_inference_steps, - num_outputs, - setHeight, - setNegative_prompt, - setNumOutputs, - setSteps, - setWidth, - width, -}: FiltersProps) { - return ( - <> - - - - - Запрос для исключения из генерации - - - ) -} @@ -1,2 +0,0 @@ -export * from './filters' -export * from './types' @@ -1,18 +0,0 @@ -import { ChangeEvent } from 'react' -import { SelectChangeEvent } from '@mui/material' - -export interface Setting { - width: number - height: number - num_outputs: number - negative_prompt: string - num_inference_steps: number -} - -export interface FiltersProps extends Setting { - setWidth: (e: SelectChangeEvent) => void - setHeight: (e: SelectChangeEvent) => void - setNumOutputs: (e: Event, cur: number | number[]) => void - setSteps: (e: Event, cur: number | number[]) => void - setNegative_prompt: (e: ChangeEvent) => void -} @@ -1,12 +0,0 @@ -export const costModel: any = { - 'gpt-3.5-turbo': 0.0017, - 'gpt-3.5-turbo-16k': 0.00255, - 'text-davinci-003': 0.017, - 'text-curie-001': 0.0017, - 'text-babbage-001': 0.000425, - 'text-ada-001': 0.000034, - 'gpt-4': 0.01785, - 'gpt-4-32k': 0.0255, -} - -export const textTooltipCalculating = 'Столько токенов спишется за ваш текущий запрос.' @@ -1,8 +0,0 @@ -const price = { - '1024x1024': 8.5, - '512x512': 7.65, - '256x256': 6.8, -} -export const calculatingDalle = (count: number, quality: '1024x1024' | '512x512' | '256x256') => { - return price[quality] * count -} @@ -1,59 +0,0 @@ -import React from 'react' -import { encoding_for_model } from '@dqbd/tiktoken' - -import { costModel } from '@/src/features/calculation-tokens-gpt/lib/constants' -import { calculatingDalle } from '@/src/features/calculation-tokens-gpt/model/calculating-dalle' -import { ImessageContext } from '@/src/shared/lib/types/types-gpt' -import { TypeModelGPT, typeModels } from '@/src/widgets/filters-gpt/lib/constants' - -const getFullModelTypeName = (name: string): TypeModelGPT => { - return typeModels.filter((el) => el.key === name)[0].value as TypeModelGPT -} - -const getTransformPrice = (price: number, isGpt: boolean = false) => { - if (price === 0) { - return '0' - } - - return price < 1 ? ' < 1' : `${isGpt ? '≈' : ''} ${price.toFixed(2).replace('.', ',')}` -} - -const checkIsAdditional = (model: string, isAdditional?: boolean): any => { - if (model === 'gpt-3.5-turbo') { - return isAdditional ? 'gpt-3.5-turbo-16k' : model - } - - if (model === 'gpt-4') { - return isAdditional ? 'gpt-4-32k' : model - } - - return model -} -export const useCalculating = ( - model: 'gpt' | 'dalle' | 'sd', - count?: number, - quality?: any, - prompt?: string, - gptType?: TypeModelGPT, - isAdditionalCtx?: boolean, - context?: { message: string; uid: string }[] -): string => { - if (model === 'dalle') { - return getTransformPrice(calculatingDalle(count as number, quality)) - } - - // eslint-disable-next-line react-hooks/rules-of-hooks - const modelFullName = React.useMemo(() => getFullModelTypeName(gptType as TypeModelGPT), [gptType]) - - // eslint-disable-next-line react-hooks/rules-of-hooks - const encoding = React.useMemo(() => encoding_for_model(modelFullName), [gptType]) - - const tokens = - context?.length === 0 - ? encoding.encode(prompt as string).length - : encoding.encode((prompt as string) + context?.map((el) => el.message).toString()).length - - const price = prompt ? costModel[checkIsAdditional(modelFullName, isAdditionalCtx)] * tokens + 0.1 : 0 - - return getTransformPrice(price, true) -} @@ -1,89 +0,0 @@ -import React, { memo } from 'react' -import { Box, Tooltip } from '@mui/material' -import Typography from '@mui/material/Typography' -import Image from 'next/image' - -import { useCalculating } from '@/src/features/calculation-tokens-gpt/model/use-calculating' -import TooltipCalculating from '@/src/features/calculation-tokens-gpt/ui/tooltip-calculating' -import { useAppSelector } from '@/src/main/store/store' -import { baseColor } from '@/src/shared/lib/constants/colors' -import { ImessageContext } from '@/src/shared/lib/types/types-gpt' -import { TypeModelGPT } from '@/src/widgets/filters-gpt/lib/constants' - -interface ICalculationTokenProps { - model: 'gpt' | 'sd' | 'dalle' - quality?: string - count?: number - prompt?: string - isAdditional?: boolean - gptType?: TypeModelGPT - context?: { message: string; uid: string }[] -} - -export const Calculation: React.FC = memo(({ prompt, gptType, context, isAdditional, count, quality, model }) => { - const price = useCalculating(model, count, quality, prompt, gptType, isAdditional, context) - - const theme = useAppSelector((state) => state.theme.theme) - - return ( - } - componentsProps={{ - tooltip: { - sx: { - '&.MuiTooltip-tooltip': { - '&.MuiTooltip-tooltipPlacementBottom': { - marginTop: '2px', - }, - '&.MuiTooltip-tooltipPlacementTop': { - marginBottom: '7px', - }, - '&.MuiTooltip-tooltipPlacementLeft': { - marginRight: '24px', - }, - }, - bgcolor: theme === 'light' ? 'white' : '#4B4B4B', - borderRadius: '10px', - '& .MuiTooltip-arrow': { - color: theme === 'light' ? 'white' : '#4B4B4B', - }, - boxShadow: '0px 0px 4px rgba(0, 0, 0, 0.04), 0px 4px 32px rgba(0, 0, 0, 0.16)', - }, - }, - }} - arrow - > - - {''} - - {price} - - - - ) -}) - -Calculation.displayName = 'Calculation' @@ -1,39 +0,0 @@ -import React from 'react' -import { Box } from '@mui/material' -import Typography from '@mui/material/Typography' - -import { textTooltipCalculating } from '@/src/features/calculation-tokens-gpt/lib/constants' -import { useAppSelector } from '@/src/main/store/store' - -const TooltipCalculating = ({ model = 'dalle' }: { model?: 'gpt' | 'dalle' | 'sd' }) => { - const theme = useAppSelector((state) => state.theme.theme) - - return ( - - - {textTooltipCalculating} - - - {model === 'gpt' && ( - - Фактическое значение может немного отличаться - - )} - - ) -} - -export default TooltipCalculating @@ -1 +0,0 @@ -export { Calculation } from './ui/calculation' @@ -37,6 +37,7 @@ export function useChats(model: string): ChatsReturn { const { data } = useSession() useEffect(() => { + ;[][1] if (model && data?.access) { getAllChats(model, data?.access).then((res) => { setChats(res) @@ -8,6 +8,7 @@ interface IProps { setModal: Dispatch> image: string } + export default function FullScreenModal({ modal, setModal, image }: IProps) { const isSvg = image.includes('.svg') @@ -1,6 +1,6 @@ .close_block{ position: absolute; - z-index: 105; + z-index: 110; cursor: pointer; right: 25px; top: 25px; @@ -1,5 +1,5 @@ import React from 'react' -import { Box, Typography } from '@mui/material' +import { Avatar, Box, Typography } from '@mui/material' import Link from 'next/link' import styles from '@/src/shared/styles/chats-bot-pages.module.scss' @@ -10,11 +10,16 @@ export default function Title(props: any) { {' '} - {props.type} •{' '} + {props.linkBack && props.linkBack !== '' ? ( + {props.type} + ) : ( + {props.type} + )} •{' '} -  {props.title} +  {props.title} + {props.icon && } {props.title} @@ -56,10 +56,3 @@ export const options: Options = { doneLabel: 'Готово', disableInteraction: true, } - -export const responseGPT = - 'Для нахождения минимального элемента в массиве предлагаю написать собственную функцию с использованием функции высшего порядка reduce и стандартного метода Math.min():\n' + - '\n' + - 'const numbers = [-94, 87, 12, 0, -67, 32];\n' + - 'const min = (values) => values.reduce((x, y) => Math.min(x, y));\n' + - 'console.log(min(numbers)); // => -94\n' @@ -1,44 +0,0 @@ -import { createAsyncThunk, createSlice } from '@reduxjs/toolkit' - -import { CopywriteProxy } from '@/src/domains/copywrite/proxy/copywrite-proxy' -import { Template } from '@/src/domains/copywrite/proxy/types/template' -import { Message } from '@/src/shared/lib/types/model' - -export interface Theme { - templates: Template[] | null - generation: Message[] | null -} - -const initialState: Theme = { - templates: null, - generation: null, -} - -export const loadTemplates = createAsyncThunk('copywrite/loadTemplates', async (token?: string): Promise => { - return await CopywriteProxy.getTemplates(token) -}) - -export const loadGeneration = createAsyncThunk('copywrite/loadGeneration', async (token?: string): Promise => { - return await CopywriteProxy.getGeneration(token) -}) - -export const copySlice = createSlice({ - name: 'copySlice', - initialState, - reducers: { - loadTemplates: (state, action) => {}, - }, - extraReducers: (builder) => { - builder - .addCase(loadTemplates.fulfilled, (state, action) => { - state.templates = action.payload - }) - .addCase(loadGeneration.fulfilled, (state, action) => { - state.generation = action.payload - }) - }, -}) - -export const {} = copySlice.actions - -export default copySlice.reducer @@ -0,0 +1,98 @@ +import { createSlice } from '@reduxjs/toolkit' +import { EditorState } from 'draft-js' + +import { CopywriteDefaultVariables, CopywriteOverrideVariables } from '@/src/widgets/copy/api/models' +import { getHtmlText } from '@/src/widgets/copy/lib/getEditorHtml' + +export interface Theme { + output_content: string | null + input_content: string + variables: { [p: string]: string | null }[] + defaultVariables: CopywriteDefaultVariables[] | [] + overridenVariables: CopywriteOverrideVariables[] | [] +} + +const initialState: Theme = { + output_content: null, + input_content: '', + variables: [], + defaultVariables: [], + overridenVariables: [], +} + +export const copyStore = createSlice({ + name: 'copyStore', + initialState, + reducers: { + // OUTPUT CONTENT + setNewOutputContent: (state, action: { payload: string }) => { + state.output_content = action.payload + }, + addOutputContent: (state, action: { payload: string }) => { + state.output_content += action.payload + }, + + // INPUT CONTENT + setTextInputContent: (state, action: { payload: string }) => { + state.input_content = action.payload + }, + setEditorInputContent: (state, action: { payload: EditorState | undefined }) => { + if (action.payload !== undefined) state.output_content = getHtmlText(action.payload) + }, + + // VARIABLES + setAllVariables: (state, action: { payload: { [p: string]: string | null }[] }) => { + state.variables = action.payload + }, + updateVariable: (state, action: { payload: { id: string; value: string | null } }) => { + state.variables = state.variables.map((el) => { + if (el.id === action.payload.id) { + el.value = action.payload.value + } + return el + }) + }, + createVariables: (state) => {}, + + // DEFAULT VARIABLES + setDefaultVariables: (state, action: { payload: CopywriteDefaultVariables[] }) => { + state.defaultVariables = action.payload + }, + updateDefaultVariables: (state, action: { payload: { action: 'add' | 'remove'; variable: CopywriteDefaultVariables } }) => { + if (action.payload.action === 'add') { + state.defaultVariables = [...state.defaultVariables, action.payload.variable] + } + if (action.payload.action === 'remove') { + state.defaultVariables = state.defaultVariables.filter((el) => el.id !== action.payload.variable.id) + } + }, + + // OVERRIDE VARIABLES + setOverrideVariables: (state, action: { payload: CopywriteOverrideVariables[] }) => { + state.overridenVariables = action.payload + }, + updateOverrideVariables: (state, action: { payload: { action: 'add' | 'remove'; variable: CopywriteOverrideVariables } }) => { + if (action.payload.action === 'add') { + state.overridenVariables = [...state.overridenVariables, action.payload.variable] + } + if (action.payload.action === 'remove') { + state.overridenVariables = state.overridenVariables.filter((el) => el.variable !== action.payload.variable.id) + } + }, + }, +}) + +export const { + setNewOutputContent, + addOutputContent, + setTextInputContent, + setEditorInputContent, + updateVariable, + setAllVariables, + updateDefaultVariables, + setDefaultVariables, + setOverrideVariables, + updateOverrideVariables, +} = copyStore.actions + +export default copyStore.reducer @@ -1,72 +0,0 @@ -import { Dispatch, SetStateAction, useEffect, useMemo, useState } from 'react' -import { useRouter } from 'next/router' -import { useSession } from 'next-auth/react' - -import { emptyTemplate } from '@/src/domains/copywrite/lib/constants' -import { Template } from '@/src/domains/copywrite/proxy/types/template' -import { loadGeneration, loadTemplates } from '@/src/features/use-copy/copy-slice' -import { useAppDispatch, useAppSelector } from '@/src/main/store/store' -import { Message } from '@/src/shared/lib/types/model' - -interface UseCopy { - currentTemplate: Template | null - generations: Message[] | null - pickGeneration: Message | null - setPickGeneration: Dispatch> - createEmpty: () => void -} - -export const useCopy = (): UseCopy => { - const [pickGeneration, setPickGeneration] = useState(null) - - const { data } = useSession() - - const { query, push, pathname } = useRouter() - - const templates = useAppSelector((state) => state.copy.templates) - - const generations = useAppSelector((state) => state.copy.generation) - - const dispatch = useAppDispatch() - - const getId = () => { - const id = query['id'] - - if (id) { - return Number(id) - } - } - - const createEmpty = () => { - setPickGeneration({ - content: '', - uid: '123', - created_at: '123', - file: null, - info: null, - from_model: false, - elapsed_time: '12', - is_favourite: false, - is_sent: false, - }) - } - - useEffect(() => { - if (data?.access) { - dispatch(loadTemplates(data.access)) - dispatch(loadGeneration(data.access)) - } - }, [data?.access]) - - const currentTemplate = useMemo(() => { - const id = getId() - const foundTemplate = templates?.find((el) => el.id === id) - if (foundTemplate) { - return foundTemplate - } - - return emptyTemplate - }, [templates]) - - return { currentTemplate, generations, pickGeneration, setPickGeneration, createEmpty } -} @@ -1,166 +0,0 @@ -import { Dispatch, SetStateAction, useEffect, useState } from 'react' -import axios, { AxiosError, AxiosResponse } from 'axios' -import { ContentState, EditorState } from 'draft-js' -import { useSession } from 'next-auth/react' - -import { Template } from '@/src/domains/copywrite/proxy/types/template' -import { loadGeneration } from '@/src/features/use-copy/copy-slice' -import { useAppDispatch } from '@/src/main/store/store' -import { useShowData } from '@/src/shared' -import { API_URL } from '@/src/shared/lib/constants' -import { Message, MessageSend } from '@/src/shared/lib/types/model' - -type Languages = 'ru' | 'en' | 'it' | 'fr' -type LanguagesText = 'Русский' | 'Английский' | 'Итальянский' | 'Французский' - -export const langs: Record = { - Русский: 'ru', - Английский: 'en', - Итальянский: 'it', - Французский: 'fr', -} - -export const languages = { ...langs, Немецкий: 'de' } -export const target_audiences = ['Вся', '18+', '21+', '30+', '14-20', '35-40'] -export const tovs = ['Нейтральный', 'Спокойный', 'Агрессивный', 'Серьезный', 'Провокационный', 'Остроумный', 'Наставнический', 'Дружелюбный'] - -type Setting = Pick - -type UseTemplate = { - text: EditorState - isLoading: boolean - - lang: string - targetAudiences: string - tov: string - theme: string - content: string - keywords: string[] - resource_urls: string[] - - setLang: Dispatch> - setTargetAudiences: Dispatch> - setTov: Dispatch> - setTheme: Dispatch> - setContent: Dispatch> - setKeywords: Dispatch> - setResourceUrls: Dispatch> - - clearSetting: () => void - createText: () => void - onEditorChange: (a: any) => void -} - -export const useTemplate = (currentTemplate: Template | null): UseTemplate => { - const [text, setText] = useState(EditorState.createEmpty()) - - const onEditorChange = (editorState: any) => { - setText(editorState) - } - - const [isLoading, setIsLoading] = useState(false) - - const dispatch = useAppDispatch() - - const { showError } = useShowData() - - const { data: session } = useSession() - - const [lang, setLang] = useState(() => { - const a = Object.entries(languages) - - const b = a.find(([key, value]) => value === currentTemplate?.language) - - if (b) { - return b[0] - } else { - return a[0][0] - } - }) - - const [targetAudiences, setTargetAudiences] = useState(currentTemplate?.target_audience || target_audiences[0]) - - const [tov, setTov] = useState(currentTemplate?.tov || tovs[0]) - - const [theme, setTheme] = useState(currentTemplate?.theme || '') - - const [content, setContent] = useState(currentTemplate?.content || '') - - const [keywords, setKeywords] = useState(currentTemplate?.keywords || []) - - const [resource_urls, setResourceUrls] = useState(currentTemplate?.resources_urls || []) - - const clearSetting = () => { - setLang('Русский') - setTargetAudiences(currentTemplate?.target_audience || target_audiences[0]) - setTov(currentTemplate?.tov || tovs[0]) - setTheme(currentTemplate?.theme || '') - setKeywords(currentTemplate?.keywords || []) - setResourceUrls(currentTemplate?.resources_urls || []) - } - - const createText = async () => { - const dataForSend: MessageSend = { - content: content, - file: null, - info: { - keywords, - language: Object.entries(languages).find(([key, value]) => key === lang)![1], - tov, - resources_urls: resource_urls, - target_audience: targetAudiences, - theme: theme, - }, - } - - if (!session?.access) { - showError('У вас неактивный токен, попробуйте перезайти в аккаунт', true) - return - } - - try { - setIsLoading(true) - const { data } = await axios.post>(API_URL + '/copywrite/', dataForSend, { - withCredentials: true, - headers: { - Authorization: `Bearer ${session?.access}`, - }, - }) - setIsLoading(false) - - const newContentState = ContentState.createFromText(data[0].content) - - setText(EditorState.createWithContent(newContentState)) - dispatch(loadGeneration(session?.access)) - } catch (err: any) { - setIsLoading(false) - return { - error: true, - message: 'Произошла ошибка при выполнении запроса', - details: err as AxiosError, - } - } - } - - return { - tov, - setTov, - lang, - setLang, - clearSetting, - createText, - isLoading, - keywords, - setKeywords, - setResourceUrls, - resource_urls, - setTargetAudiences, - targetAudiences, - setTheme, - text, - onEditorChange, - theme, - setContent, - content, - } -} @@ -4,7 +4,7 @@ import Switch from '@mui/material/Switch' import { setParams } from '@/src/main/store/model-parametres-store' import { useAppDispatch } from '@/src/main/store/store' -import TooltipModelTypes from '@/src/widgets/filters-gpt/ui/tooltip-model-types' +import TooltipModelTypes from '@/src/shared/ui/tooltip-model-types' interface IProps { name: string @@ -8,7 +8,7 @@ import { setParams } from '@/src/main/store/model-parametres-store' import { useAppDispatch } from '@/src/main/store/store' import { InputStyleDark, InputStyleLight } from '@/src/shared' import { useThemeAndDevice } from '@/src/shared/lib/hooks' -import TooltipModelTypes from '@/src/widgets/filters-gpt/ui/tooltip-model-types' +import TooltipModelTypes from '@/src/shared/ui/tooltip-model-types' interface IProps { title: string @@ -21,7 +21,7 @@ interface IProps { setNewParam: (payload: { [p: string]: string | number | number[] | boolean }) => void } -export const InputFilter = ({ filters, item_key, values, title, description, setNewParam }: IProps) => { +export const InputFilter = ({ filters, item_key, values, title, description = '', setNewParam }: IProps) => { const { theme } = useThemeAndDevice() const [value, setValue] = React.useState(values?.default || '') @@ -5,7 +5,7 @@ import { MenuItem, Select, SelectChangeEvent, Stack, Typography } from '@mui/mat import { setParams } from '@/src/main/store/model-parametres-store' import { useAppDispatch, useAppSelector } from '@/src/main/store/store' import { baseColor } from '@/src/shared/lib/constants/colors' -import TooltipModelTypes from '@/src/widgets/filters-gpt/ui/tooltip-model-types' +import TooltipModelTypes from '@/src/shared/ui/tooltip-model-types' interface IProps { selects: { availables: string[]; default: any; end: number; start: number; step: number } @@ -3,7 +3,7 @@ import * as React from 'react' import { setParams } from '@/src/main/store/model-parametres-store' import { useAppDispatch } from '@/src/main/store/store' import { Slider as Sl } from '@/src/shared' -import TooltipModelTypes from '@/src/widgets/filters-gpt/ui/tooltip-model-types' +import TooltipModelTypes from '@/src/shared/ui/tooltip-model-types' interface IProps { title: string @@ -15,10 +15,6 @@ export type CardProps = { } const ChatCard = ({ text, icon, title, uid, slug, accessed_models }: CardProps) => { - useEffect(() => { - console.log(accessed_models) - }, [accessed_models]) - return ( @@ -5,7 +5,7 @@ import { MenuItem, Select, SelectChangeEvent, Stack, Typography } from '@mui/mat import { useAppSelector } from '@/src/main/store/store' import { IModelVersions } from '@/src/shared/api/models/models' import { baseColor } from '@/src/shared/lib/constants/colors' -import TooltipModelTypes from '@/src/widgets/filters-gpt/ui/tooltip-model-types' +import TooltipModelTypes from '@/src/shared/ui/tooltip-model-types' interface ISelect { value: string @@ -86,6 +86,7 @@ function Chat({ modelType={modelType} deleteMessage={deleteMessage} modelTitle={modelTitle} + loading={loading} />