feat: Add new model options for inference and update requirements for OAuth support in Gradio.
Browse files- app.py +6 -3
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -17,6 +17,9 @@ HF_TOKEN = os.getenv("HF_TOKEN")
|
|
| 17 |
MODELS = [
|
| 18 |
"Local-Model-1",
|
| 19 |
"Local-Model-2",
|
|
|
|
|
|
|
|
|
|
| 20 |
]
|
| 21 |
|
| 22 |
DATA_DIR = Path("logs")
|
|
@@ -56,11 +59,11 @@ def model_inference(user_message, history, model_name, system_message, max_token
|
|
| 56 |
else:
|
| 57 |
client = InferenceClient(token=token, model=model_name)
|
| 58 |
|
| 59 |
-
#
|
| 60 |
history.append({"role": "user", "content": user_message})
|
| 61 |
history.append({"role": "assistant", "content": ""})
|
| 62 |
|
| 63 |
-
#
|
| 64 |
api_messages = [{"role": "system", "content": system_message}] + history[:-1]
|
| 65 |
|
| 66 |
try:
|
|
@@ -95,7 +98,7 @@ def model_inference(user_message, history, model_name, system_message, max_token
|
|
| 95 |
with gr.Blocks() as demo:
|
| 96 |
with gr.Sidebar():
|
| 97 |
gr.Markdown("## Configuration")
|
| 98 |
-
|
| 99 |
|
| 100 |
# Local vLLM endpoint setting
|
| 101 |
local_endpoint_a = gr.Textbox(
|
|
|
|
| 17 |
MODELS = [
|
| 18 |
"Local-Model-1",
|
| 19 |
"Local-Model-2",
|
| 20 |
+
"Elfsong/VLM-iter_0000500",
|
| 21 |
+
"Elfsong/VLM-iter_0001000",
|
| 22 |
+
"Elfsong/VLM-iter_0001500",
|
| 23 |
]
|
| 24 |
|
| 25 |
DATA_DIR = Path("logs")
|
|
|
|
| 59 |
else:
|
| 60 |
client = InferenceClient(token=token, model=model_name)
|
| 61 |
|
| 62 |
+
# Construct message list
|
| 63 |
history.append({"role": "user", "content": user_message})
|
| 64 |
history.append({"role": "assistant", "content": ""})
|
| 65 |
|
| 66 |
+
# Construct API messages (including system prompt)
|
| 67 |
api_messages = [{"role": "system", "content": system_message}] + history[:-1]
|
| 68 |
|
| 69 |
try:
|
|
|
|
| 98 |
with gr.Blocks() as demo:
|
| 99 |
with gr.Sidebar():
|
| 100 |
gr.Markdown("## Configuration")
|
| 101 |
+
gr.LoginButton()
|
| 102 |
|
| 103 |
# Local vLLM endpoint setting
|
| 104 |
local_endpoint_a = gr.Textbox(
|
requirements.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
gradio
|
|
|
|
|
|
| 1 |
gradio
|
| 2 |
+
gradio[oauth]
|