File tree Expand file tree Collapse file tree 3 files changed +20
-29
lines changed Expand file tree Collapse file tree 3 files changed +20
-29
lines changed Original file line number Diff line number Diff line change 1
1
import { ChatBotHistoryItem } from "@/components/chatbot/types" ;
2
2
import { Dispatch , SetStateAction } from "react" ;
3
3
import { BACKEND_URL } from "../tools/const" ;
4
+ import { DEFAULT_QUERY_CONFIG } from "../enum/DefaultQueryEnum" ;
4
5
5
6
export interface QueryProps {
6
7
query : string ;
@@ -14,12 +15,12 @@ export async function query(props: QueryProps) {
14
15
try {
15
16
const param = {
16
17
query : props . query ,
17
- bedrock_model_id : props . configuration . selectedLLM ,
18
+ bedrock_model_id : props . configuration . selectedLLM || DEFAULT_QUERY_CONFIG . selectedLLM ,
18
19
use_rag_flag : true ,
19
20
visualize_results_flag : true ,
20
21
intent_ner_recognition_flag : props . configuration . intentChecked ,
21
22
agent_cot_flag : props . configuration . complexChecked ,
22
- profile_name : props . configuration . selectedDataPro ,
23
+ profile_name : props . configuration . selectedDataPro || DEFAULT_QUERY_CONFIG . selectedDataPro ,
23
24
explain_gen_process_flag : true ,
24
25
gen_suggested_question_flag : props . configuration . modelSuggestChecked ,
25
26
top_k : props . configuration . topK ,
Original file line number Diff line number Diff line change @@ -71,18 +71,33 @@ export default function Chat(
71
71
72
72
// On first render and on unmount there is no DOM element so `element` will be `null`
73
73
const scrollTo = ( element : any ) => {
74
- if ( element ) {
74
+ if ( element && ! isInViewPort ( element ) ) {
75
75
element . scrollIntoView ( { behavior : "smooth" } ) ;
76
76
}
77
77
} ;
78
78
79
+ function isInViewPort ( element : any ) {
80
+ const viewWidth = window . innerWidth || document . documentElement . clientWidth ;
81
+ const viewHeight = window . innerHeight || document . documentElement . clientHeight ;
82
+ const {
83
+ top,
84
+ right,
85
+ bottom,
86
+ left,
87
+ } = element . getBoundingClientRect ( ) ;
88
+
89
+ return (
90
+ top >= 0 && left >= 0 && right <= viewWidth && bottom <= ( viewHeight - 200 )
91
+ ) ;
92
+ }
93
+
79
94
return (
80
95
< div className = { styles . chat_container } >
81
96
< SpaceBetween size = { 'xxl' } >
82
97
{ messageHistory . map ( ( message , idx ) => {
83
98
const isLast = idx === messageHistory . length - 1 ;
84
99
return (
85
- < div key = { idx } ref = { isLast ? scrollTo : undefined } >
100
+ < div key = { idx } ref = { isLast && ! loading ? scrollTo : undefined } >
86
101
< ChatMessage
87
102
key = { idx }
88
103
message = { message }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments