Skip to content

Commit

Permalink
/run-deploy-app
Browse files Browse the repository at this point in the history
  • Loading branch information
Lliillyy committed Dec 11, 2023
1 parent ce491cc commit e93c1f8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
14 changes: 6 additions & 8 deletions src/api-service/api/model_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
pwd = Path(__file__).parent.resolve()
import sys, os
sys.path.insert(0, "LLaVA")
# print(sys.path)
# print(os.environ.get("PYTHONPATH"))
from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN
from llava.conversation import conv_templates, SeparatorStyle
from llava.model.builder import load_pretrained_model
Expand Down Expand Up @@ -117,12 +115,12 @@ def post(self):
swagger = Swagger(app)
app.add_url_rule('/chat', view_func=ChatView.as_view('chat'), methods=['POST'])

# @app.route('/status', methods=['GET'])
# def get_api_status():
# return jsonify({
# "version": "1.0",
# "torch_version": torch.__version__
# })
@app.route('/status', methods=['GET'])
def get_api_status():
return jsonify({
"api_version": "1.1",
"torch_version": torch.__version__
})

CORS(app)

Expand Down
17 changes: 15 additions & 2 deletions src/frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@ function App() {
const [image, setImage] = useState(null);
const [chats, setChats] = useState([]);
const [isTyping, setIsTyping] = useState(false);
const [api_version, setAPIVersion] = useState(null);
const [torch_version, setTorchVersion] = useState(null);

useEffect(() => {
const delayBeforeHello = 1000; // Adjust the delay in milliseconds
console.log("API Version", api_version, torch_version)
fetch("/api/status", {
"method": "GET",
})
.then(response => response.json())
.then(data => {
console.log(data);
setAPIVersion(data.api_version);
setTorchVersion(data.torch_version);
})
.catch(error => console.error('Error:', error));

const delayBeforeHello = 1000; // Adjust the delay in milliseconds
setTimeout(() => {
const systemMessage =
"Hello! This is your Science Tutor. I can provide instant and expert answers to K12 science questions that you may have in different domains such as natural, social and language science. Feel free to ask me any questions you have and upload an image to start!";
Expand Down Expand Up @@ -117,7 +130,7 @@ function App() {

<main className="main-container">
<h1>ScienceTutor</h1>
<h4>version {APP_VERSION}</h4>
<h4>APP v{APP_VERSION} &nbsp; API v{api_version} &nbsp; PyTorch v{torch_version}</h4>

<section>
{chats && chats.length
Expand Down

0 comments on commit e93c1f8

Please sign in to comment.