Skip to content

Commit

Permalink
Fix llm display bug
Browse files Browse the repository at this point in the history
  • Loading branch information
moria97 committed Sep 6, 2024
1 parent 005a003 commit 1afa2d6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ ENV VIRTUAL_ENV=/app/.venv \
RUN apt-get update && apt-get install -y libgl1 libglib2.0-0

WORKDIR /app
COPY . .
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY . .
CMD ["pai_rag", "run"]
2 changes: 1 addition & 1 deletion Dockerfile_gpu
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ ENV VIRTUAL_ENV=/app/.venv \
RUN apt-get update && apt-get install -y libgl1 libglib2.0-0

WORKDIR /app
COPY . .
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY . .
CMD ["pai_rag", "run"]
2 changes: 1 addition & 1 deletion Dockerfile_ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ ENV VIRTUAL_ENV=/app/.venv \
RUN apt-get update && apt-get install -y libgl1 libglib2.0-0

WORKDIR /app
COPY . .
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY . .
CMD ["pai_rag", "ui"]
50 changes: 27 additions & 23 deletions src/pai_rag/app/web/tabs/settings_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,23 @@ def change_emb_model(source, model):
elem_id="llm",
interactive=DEFAULT_IS_INTERACTIVE.lower() != "false",
)
with gr.Column(visible=(llm == "PaiEas")) as eas_col:
llm_eas_url = gr.Textbox(
label="EAS Url",
elem_id="llm_eas_url",
)
llm_eas_token = gr.Textbox(
label="EAS Token",
elem_id="llm_eas_token",
type="password",
)
llm_eas_model_name = gr.Textbox(
label="EAS Model name",
elem_id="llm_eas_model_name",
)
with gr.Column(visible=(llm != "PaiEas")) as api_llm_col:
llm_api_model_name = gr.Dropdown(
label="LLM Model Name",
elem_id="llm_api_model_name",
)
llm_eas_url = gr.Textbox(
label="EAS Url",
elem_id="llm_eas_url",
)
llm_eas_token = gr.Textbox(
label="EAS Token",
elem_id="llm_eas_token",
type="password",
)
llm_eas_model_name = gr.Textbox(
label="EAS Model name",
elem_id="llm_eas_model_name",
)
llm_api_model_name = gr.Dropdown(
label="LLM Model Name",
elem_id="llm_api_model_name",
)

components.extend(
[
Expand All @@ -128,17 +126,23 @@ def change_llm(value):
model_options = LLM_MODEL_KEY_DICT.get(value, [])
cur_model = model_options[0] if model_options else ""
return {
eas_col: gr.update(visible=eas_visible),
api_llm_col: gr.update(visible=api_visible),
llm_eas_url: gr.update(visible=eas_visible),
llm_eas_token: gr.update(visible=eas_visible),
llm_eas_model_name: gr.update(visible=eas_visible),
llm_api_model_name: gr.update(
choices=model_options, value=cur_model
choices=model_options, value=cur_model, visible=api_visible
),
}

llm.input(
fn=change_llm,
inputs=llm,
outputs=[eas_col, api_llm_col, llm_api_model_name],
outputs=[
llm_eas_url,
llm_eas_token,
llm_eas_model_name,
llm_api_model_name,
],
)
"""
with gr.Column():
Expand Down
15 changes: 12 additions & 3 deletions src/pai_rag/app/web/view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,18 @@ def to_component_settings(self) -> Dict[str, Dict[str, Any]]:
settings["embed_batch_size"] = {"value": self.embed_batch_size}

settings["llm"] = {"value": self.llm}
settings["llm_eas_url"] = {"value": self.llm_eas_url}
settings["llm_eas_token"] = {"value": self.llm_eas_token}
settings["llm_eas_model_name"] = {"value": self.llm_eas_model_name}
settings["llm_eas_url"] = {
"value": self.llm_eas_url,
"visible": self.llm.lower() == "paieas",
}
settings["llm_eas_token"] = {
"value": self.llm_eas_token,
"visible": self.llm.lower() == "paieas",
}
settings["llm_eas_model_name"] = {
"value": self.llm_eas_model_name,
"visible": self.llm.lower() == "paieas",
}
settings["llm_api_model_name"] = {
"value": self.llm_api_model_name,
"choices": LLM_MODEL_KEY_DICT.get(self.llm, []),
Expand Down

0 comments on commit 1afa2d6

Please sign in to comment.