@@ -9,12 +9,13 @@ import "oj-c/drawer-popup";
99import MutableArrayDataProvider = require( "ojs/ojmutablearraydataprovider" ) ;
1010import { MessageToastItem } from "oj-c/message-toast" ;
1111import { InputSearchElement } from "ojs/ojinputsearch" ;
12- import { useState , useEffect , useRef } from "preact/hooks" ;
12+ import { useState , useEffect , useRef , useContext } from "preact/hooks" ;
1313import * as Questions from "text!./data/questions.json" ;
1414import * as Answers from "text!./data/answers.json" ;
1515import { initWebSocket } from "./websocket-interface" ;
1616import { InitStomp , sendPrompt } from "./stomp-interface" ;
1717import { Client } from "@stomp/stompjs" ;
18+ import { ConvoCtx } from "../app" ;
1819
1920type ServiceTypes = "text" | "summary" | "sim" ;
2021type BackendTypes = "java" | "python" ;
@@ -26,12 +27,14 @@ type Chat = {
2627} ;
2728
2829const defaultServiceType : string = localStorage . getItem ( "service" ) || "text" ;
29- const defaultBackendType : String = localStorage . getItem ( "backend" ) || "java" ;
30+ const defaultBackendType : string = localStorage . getItem ( "backend" ) || "java" ;
3031
3132const Content = ( ) => {
33+ const conversationId = useContext ( ConvoCtx ) ;
3234 const [ update , setUpdate ] = useState < Array < object > > ( [ ] ) ;
3335 const [ busy , setBusy ] = useState < boolean > ( false ) ;
3436 const [ summaryResults , setSummaryResults ] = useState < string > ( "" ) ;
37+ const [ modelId , setModelId ] = useState < string | null > ( null ) ;
3538 const [ summaryPrompt , setSummaryPrompt ] = useState < string > ( ) ;
3639 const [ serviceType , setServiceType ] = useState < ServiceTypes > (
3740 defaultServiceType as ServiceTypes
@@ -76,6 +79,7 @@ const Content = () => {
7679 await sleep ( 2000 ) ;
7780 }
7881 } ;
82+
7983 useEffect ( ( ) => {
8084 switch ( serviceType ) {
8185 case "text" :
@@ -158,16 +162,13 @@ const Content = () => {
158162 setUpdate ( chatData . current ) ;
159163 setBusy ( true ) ;
160164
161- // simulating the delay for now just to show what the animation looks like.
162- setTimeout ( ( ) => {
163- if ( backendType === "python" ) {
164- socket . current ?. send (
165- JSON . stringify ( { msgType : "question" , data : question . current } )
166- ) ;
167- } else {
168- sendPrompt ( client , question . current ! ) ;
169- }
170- } , 300 ) ;
165+ if ( backendType === "python" ) {
166+ socket . current ?. send (
167+ JSON . stringify ( { msgType : "question" , data : question . current } )
168+ ) ;
169+ } else {
170+ sendPrompt ( client , question . current ! , modelId ! , conversationId ! ) ;
171+ }
171172 }
172173 } ;
173174
@@ -198,7 +199,10 @@ const Content = () => {
198199 localStorage . setItem ( "backend" , backend ) ;
199200 location . reload ( ) ;
200201 } ;
201-
202+ const modelIdChangeHandler = ( event : CustomEvent ) => {
203+ console . log ( "model Id: " , event . detail . value ) ;
204+ if ( event . detail . value != null ) setModelId ( event . detail . value ) ;
205+ } ;
202206 const clearSummary = ( ) => {
203207 setSummaryResults ( "" ) ;
204208 } ;
@@ -223,6 +227,7 @@ const Content = () => {
223227 backendType = { backendType }
224228 aiServiceChange = { serviceTypeChangeHandler }
225229 backendChange = { backendTypeChangeHandler }
230+ modelIdChange = { modelIdChangeHandler }
226231 />
227232 </ oj-c-drawer-popup >
228233 < div class = "oj-flex-bar oj-flex-item demo-header oj-sm-12" >
0 commit comments