Skip to content

Commit

Permalink
feat: add model download
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackBradshaw committed Nov 24, 2023
1 parent b5dbc01 commit 535f587
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def start_tool_server():
chat_history = ""

MAX_SLEEP_TIME = 40

def load_tools():
global valid_tools_info
global all_tools_list
Expand All @@ -130,6 +131,11 @@ def load_tools():
except BaseException as e:
print(repr(e))
all_tools_list = sorted(list(valid_tools_info.keys()))
# Download the VLLM model from the provided URL and add it to the dropdown array
vllm_model_url = os.environ.get("VLLM_MODEL_URL", "")
if vllm_model_url:
vllm_model = LLM.from_pretrained(vllm_model_url)
available_models.append(vllm_model)
return gr.update(choices=all_tools_list)

def set_environ(OPENAI_API_KEY: str,
Expand Down Expand Up @@ -162,6 +168,7 @@ def set_environ(OPENAI_API_KEY: str,
os.environ["HUGGINGFACE_API_KEY"] = HUGGINGFACE_API_KEY
os.environ["AMADEUS_ID"] = AMADEUS_ID
os.environ["AMADEUS_KEY"] = AMADEUS_KEY
os.environ["VLLM_MODEL_URL"] = VLLM_MODEL_URL
if not tool_server_flag:
start_tool_server()
time.sleep(MAX_SLEEP_TIME)
Expand Down Expand Up @@ -288,6 +295,7 @@ def clear_history():
HUGGINGFACE_API_KEY = gr.Textbox(label="Huggingface api key:", placeholder="Key to use models in huggingface hub", type="text")
AMADEUS_ID = gr.Textbox(label="Amadeus id:", placeholder="Id to use Amadeus", type="text")
AMADEUS_KEY = gr.Textbox(label="Amadeus key:", placeholder="Key to use Amadeus", type="text")
VLLM_MODEL_URL = gr.Textbox(label="VLLM Model URL:", placeholder="URL to download VLLM model from Hugging Face", type="text")
key_set_btn = gr.Button(value="Set keys!")


Expand Down Expand Up @@ -340,6 +348,7 @@ def clear_history():
HUGGINGFACE_API_KEY,
AMADEUS_ID,
AMADEUS_KEY,
VLLM_MODEL_URL,
], outputs=key_set_btn)
key_set_btn.click(fn=load_tools, outputs=tools_chosen)

Expand Down

0 comments on commit 535f587

Please sign in to comment.