Skip to content

Commit 51fba5a

Browse files
committed
allow querying available models from backend
1 parent 40f2eb6 commit 51fba5a

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

frontend/src/App.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import "./App.css";
22
import Input from "./components/Input";
33
import Sidebar from "./components/Sidebar";
44
import Chat, { WaitingStates } from "./components/Chat";
5-
import React, { useState } from "react";
5+
import React, { useState, useEffect } from "react";
66
import Config from "./config";
77
import { useLocalStorage } from "usehooks-ts";
88

@@ -14,16 +14,23 @@ export type MessageDict = {
1414

1515
function App() {
1616
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+
}, []);
2734

2835
let [selectedModel, setSelectedModel] = useLocalStorage<string>(
2936
"model",

gpt_code_ui/webapp/main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# The GPT web UI as a template based Flask app
22
import os
33
import requests
4-
import json
54
import asyncio
65
import re
76
import logging
@@ -197,6 +196,14 @@ def index():
197196
return send_from_directory('static', 'index.html')
198197

199198

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+
200207
@app.route('/api/<path:path>', methods=["GET", "POST"])
201208
def proxy_kernel_manager(path):
202209
if request.method == "POST":

0 commit comments

Comments
 (0)