MCPcopy Create free account
hub / github.com/TaskingAI/TaskingAI / handleRequest

Function handleRequest

frontend/src/components/playground/index.tsx:543–608  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

541 setSystemPromptTemplate(updatedInputValues);
542 }
543 const handleRequest = async () => {
544 const inputValueMap = (drawerAssistantRef.current?.getRetrievalSelectedList() || []).map((item: any) => {
545 return {
546 type: 'collection', id: item
547 }
548 }).filter((item: any) => item.id)
549 const inputPluginValues = (drawerAssistantRef.current?.getActionSelectedList() || []).map((item: any) => ({ type: item.type, id: item.value })).filter((item: any) => item.id)
550
551 let systemTemplate: string[] = [];
552 if (systemPromptTemplate.length === 1 && systemPromptTemplate[0] === '') {
553 systemTemplate = []
554 } else {
555 systemTemplate = systemPromptTemplate
556 }
557 const params = {
558 model_id: Array.isArray(originalModelData) ? originalModelData[0].slice(-8) : originalModelData,
559 name: drawerName || '',
560 description: drawerDesc || '',
561 system_prompt_template: systemTemplate,
562 tools: inputPluginValues,
563 retrievals: inputValueMap,
564 memory: {
565 type: memoryValue,
566 max_messages: Number(inputValueOne) || undefined,
567 max_tokens: Number(inputValueTwo) || undefined
568 },
569 retrieval_configs: {
570 top_k: Number(topk) || undefined,
571 method: retrievalConfig,
572 max_tokens: Number(maxTokens) || undefined
573 }
574 }
575 let count = 0
576
577 systemPromptTemplate.forEach(item => {
578 const length = item.length
579 count += length
580 })
581 if (count > 16384) {
582 return toast.error(`${t('projectAssistantSystemPromptRequired')}`)
583 }
584 let id;
585 if (assistantId[0].split('-')[1]) {
586 const splitArray = assistantId[0].split('-')
587 id = splitArray.slice(-1)[0]
588 } else {
589 id = assistantId[0]
590 }
591
592 try {
593 if (id) {
594 await updateAssistant(id, params)
595 setAssistantName(drawerName)
596 setOpenDrawer(false)
597 }
598
599 await fetchAssistantsList()
600 dispatch(fetchAssistantsData() as any)

Callers 1

PlaygroundFunction · 0.70

Calls 4

updateAssistantFunction · 0.90
fetchAssistantsDataFunction · 0.90
fetchAssistantsListFunction · 0.85
filterMethod · 0.45

Tested by

no test coverage detected