Skip to content

Commit

Permalink
add model service check to chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelClifford committed Feb 13, 2024
1 parent 2c5a0f6 commit d9711ae
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions chatbot/ai_applications/chat_ui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import gradio as gr
from gradio_client import Client
import requests
import time
import os


Expand All @@ -17,8 +19,22 @@ def ask(self, prompt, history):
yield r
yield str(job.outputs()[-1])

def checking_model_service(model_service):
print("Waiting for Model Service Availability...")
ready = False
while not ready:
try:
request = requests.get(f'{model_service}')
if request.status_code == 200:
ready = True
except:
pass
time.sleep(1)
print("Model Service Available")

if __name__ == "__main__":
model_endpoint = os.getenv('MODEL_ENDPOINT', "http://0.0.0.0:7860")
checking_model_service(model_endpoint)
chat = Chat(model_endpoint)
demo = gr.ChatInterface(chat.ask)
demo.launch(server_name="0.0.0.0", server_port=8080)

0 comments on commit d9711ae

Please sign in to comment.