File tree Expand file tree Collapse file tree 2 files changed +26
-12
lines changed Expand file tree Collapse file tree 2 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import "./App.css";
2
2
import Input from "./components/Input" ;
3
3
import Sidebar from "./components/Sidebar" ;
4
4
import Chat , { WaitingStates } from "./components/Chat" ;
5
- import React , { useState } from "react" ;
5
+ import React , { useState , useEffect } from "react" ;
6
6
import Config from "./config" ;
7
7
import { useLocalStorage } from "usehooks-ts" ;
8
8
@@ -14,16 +14,23 @@ export type MessageDict = {
14
14
15
15
function App ( ) {
16
16
const COMMANDS = [ "reset" ] ;
17
- const MODELS = [
18
- {
19
- displayName : "GPT-3.5" ,
20
- name : "gpt-3.5-turbo" ,
21
- } ,
22
- {
23
- displayName : "GPT-4" ,
24
- name : "gpt-4" ,
25
- } ,
26
- ] ;
17
+
18
+ let [ MODELS , setModels ] = useState ( [ { displayName : "GPT-3.5" , name : "gpt-3.5-turbo" } ] ) ;
19
+
20
+ useEffect ( ( ) => {
21
+ const getModels = async ( ) => {
22
+ try {
23
+ const response = await fetch ( `${ Config . WEB_ADDRESS } /models` ) ;
24
+ const json = await response . json ( ) ;
25
+ console . log ( json ) ;
26
+ setModels ( json ) ;
27
+ } catch ( e ) {
28
+ console . error ( e ) ;
29
+ } ;
30
+ } ;
31
+
32
+ getModels ( ) ;
33
+ } , [ ] ) ;
27
34
28
35
let [ selectedModel , setSelectedModel ] = useLocalStorage < string > (
29
36
"model" ,
Original file line number Diff line number Diff line change 1
1
# The GPT web UI as a template based Flask app
2
2
import os
3
3
import requests
4
- import json
5
4
import asyncio
6
5
import re
7
6
import logging
@@ -197,6 +196,14 @@ def index():
197
196
return send_from_directory ('static' , 'index.html' )
198
197
199
198
199
+ @app .route ("/models" )
200
+ def models ():
201
+ return jsonify ([
202
+ {"displayName" : "GPT-3.5" , "name" : "gpt-3.5-turbo" },
203
+ {"displayName" : "GPT-4" , "name" : "gpt-4" },
204
+ ])
205
+
206
+
200
207
@app .route ('/api/<path:path>' , methods = ["GET" , "POST" ])
201
208
def proxy_kernel_manager (path ):
202
209
if request .method == "POST" :
You can’t perform that action at this time.
0 commit comments