File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ async function findAvailablePort(startPort: number): Promise<number> {
3737
3838const API_CONFIG : ApiConfig = {
3939 key : process . env . BITTE_API_KEY ! ,
40- url : process . env . BITTE_API_URL || "https://wallet.bitte.ai/api/v1/chat " ,
40+ url : process . env . BITTE_API_URL || "https://wallet.bitte.ai/api/v1" ,
4141 serverPort : DEFAULT_PORT ,
4242} ;
4343
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ const Main: React.FC = (): JSX.Element => {
7676 } ,
7777 } }
7878 apiUrl = { config . bitteApiUrl }
79+ historyApiUrl = "/api/history"
7980 apiKey = { config . bitteApiKey }
8081 colors = { {
8182 generalBackground : "#18181A" ,
Original file line number Diff line number Diff line change @@ -79,14 +79,34 @@ export async function startUIServer(
7979 spec : agentSpec ,
8080 } ,
8181 bitteApiKey : apiConfig . key ,
82- bitteApiUrl : apiConfig . url ,
82+ bitteApiUrl : ` ${ apiConfig . url } /chat` ,
8383 } ;
8484 res . json ( serverConfig ) ;
8585 } catch ( error ) {
8686 res . status ( 500 ) . json ( { error : "Failed to fetch AI plugin spec" } ) ;
8787 }
8888 } ) ;
8989
90+ app . get ( "/api/history" , async ( req , res ) => {
91+ try {
92+ const id = req . query . id ;
93+ if ( ! id ) {
94+ throw new Error ( "No history id on request." ) ;
95+ }
96+ const url = `${ apiConfig . url } /history?id=${ id } ` ;
97+
98+ const response = await fetch ( url , {
99+ headers : {
100+ Authorization : `Bearer ${ apiConfig . key } ` ,
101+ } ,
102+ } ) ;
103+ const result = await response . json ( ) ;
104+ res . json ( result ) ;
105+ } catch ( err ) {
106+ res . status ( 500 ) . json ( { error : `Failed to fetch chat history: ${ err } ` } ) ;
107+ }
108+ } ) ;
109+
90110 // Serve index.html for all routes
91111 app . get ( "*" , async ( req , res ) => {
92112 console . log ( req . path ) ;
You can’t perform that action at this time.
0 commit comments