File tree Expand file tree Collapse file tree 4 files changed +2
-76
lines changed Expand file tree Collapse file tree 4 files changed +2
-76
lines changed Original file line number Diff line number Diff line change 1
- import { Tooltip , Typography } from '@mui/material'
1
+ import { Tooltip } from '@mui/material'
2
2
import EmailIcon from '@mui/icons-material/Email'
3
3
import ReactMarkdown from 'react-markdown'
4
4
import remarkGfm from 'remark-gfm'
Original file line number Diff line number Diff line change @@ -2,57 +2,6 @@ import type { ChatMessage } from '../../../shared/chat'
2
2
import { postAbortableStream } from '../../util/apiClient'
3
3
4
4
interface GetCompletionStreamProps {
5
- courseId ?: string
6
- assistantInstructions : string
7
- messages : ChatMessage [ ]
8
- model : string
9
- formData : FormData
10
- ragIndexId ?: number
11
- userConsent ?: boolean
12
- modelTemperature : number
13
- prevResponseId ?: string
14
- abortController ?: AbortController
15
- saveConsent : boolean
16
- }
17
- export const getCompletionStream = async ( {
18
- courseId,
19
- assistantInstructions,
20
- messages,
21
- model,
22
- formData,
23
- ragIndexId,
24
- userConsent,
25
- modelTemperature,
26
- prevResponseId,
27
- abortController,
28
- saveConsent,
29
- } : GetCompletionStreamProps ) => {
30
- const data = {
31
- courseId,
32
- options : {
33
- messages : [
34
- {
35
- role : 'system' ,
36
- content : assistantInstructions ,
37
- } ,
38
- ...messages ,
39
- ] ,
40
- assistantInstructions,
41
- ragIndexId,
42
- model,
43
- userConsent,
44
- modelTemperature,
45
- saveConsent,
46
- prevResponseId,
47
- } ,
48
- }
49
-
50
- formData . set ( 'data' , JSON . stringify ( data ) )
51
-
52
- return postAbortableStream ( '/ai/v2/stream' , formData , abortController )
53
- }
54
-
55
- interface GetCompletionStreamPropsV3 {
56
5
courseId ?: string
57
6
systemMessage : string
58
7
messages : ChatMessage [ ]
@@ -77,7 +26,7 @@ export const getCompletionStreamV3 = async ({
77
26
prevResponseId,
78
27
abortController,
79
28
saveConsent,
80
- } : GetCompletionStreamPropsV3 ) => {
29
+ } : GetCompletionStreamProps ) => {
81
30
const data = {
82
31
courseId,
83
32
options : {
Original file line number Diff line number Diff line change @@ -20,14 +20,6 @@ export const formatDate = (activityPeriod?: ActivityPeriod) => {
20
20
21
21
export const formatDateTime = ( date : string ) => `${ format ( new Date ( date ) , 'dd.MM.yyyy hh:mm:ss' ) } `
22
22
23
- export const sortCourses = ( a : Course , b : Course ) => {
24
- if ( ! a . activityPeriod || ! b . activityPeriod ) return 0
25
-
26
- const getStartTime = ( course : Course ) => new Date ( course . activityPeriod . startDate ) . getTime ( )
27
-
28
- return getStartTime ( b ) - getStartTime ( a )
29
- }
30
-
31
23
export const filterUsages = ( maxTokenLimit : number , usages : ChatInstanceUsage [ ] ) => {
32
24
const limit = maxTokenLimit * 0.9
33
25
Original file line number Diff line number Diff line change 1
1
import crypto from 'crypto'
2
2
3
- import { CustomMessage } from '../types'
4
3
import { DEFAUL_CONTEXT_LIMIT , validModels } from '../../config'
5
4
6
- /**
7
- * Filter out messages in a long conversation to save costs
8
- * and to stay within context limit.
9
- * Always keep system messages and last 10 messages
10
- */
11
- export const getMessageContext = ( messages : CustomMessage [ ] ) : CustomMessage [ ] => {
12
- const systemMessages = messages . filter ( ( message ) => message . role === 'system' )
13
- const otherMessages = messages . filter ( ( message ) => message . role !== 'system' )
14
-
15
- const latestMessages = otherMessages . slice ( - 10 )
16
-
17
- return systemMessages . concat ( latestMessages )
18
- }
19
-
20
5
export const getAllowedModels = ( model : string ) : string [ ] => {
21
6
const allModels = validModels . map ( ( { name } ) => name )
22
7
You can’t perform that action at this time.
0 commit comments