Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
lingyielia committed Jul 23, 2024
1 parent fe48708 commit 365d875
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 36 deletions.
5 changes: 0 additions & 5 deletions vizro-ai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ name = "vizro_ai"
readme = "README.md"
requires-python = ">=3.9"

[project.optional-dependencies]
anthropic = [
"langchain-anthropic"
]

[tool.coverage.paths]
vizro = ["src/vizro_ai"] # omit tests for clarity, although this can be useful to see what test lines DID NOT run

Expand Down
1 change: 0 additions & 1 deletion vizro-ai/snyk/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ ipython>=8.10.0
urllib3>=2.0.7
aiohttp>=3.9.2
langchain-core>=0.1.31
langchain-anthropic
13 changes: 1 addition & 12 deletions vizro-ai/src/vizro_ai/chains/_llm_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_openai import ChatOpenAI

try:
from langchain_anthropic import ChatAnthropic
except ImportError:
ChatAnthropic = None


SUPPORTED_MODELS = {
"OpenAI": [
"gpt-4-0613",
Expand All @@ -25,14 +19,9 @@
"gpt-4o-2024-05-13",
"gpt-4o",
],
"Anthropic": [
"claude-3-haiku-20240307",
"claude-3-sonnet-20240229",
"claude-3-opus-20240229",
],
}

DEFAULT_WRAPPER_MAP: Dict[str, BaseChatModel] = {"OpenAI": ChatOpenAI, "Anthropic": ChatAnthropic}
DEFAULT_WRAPPER_MAP: Dict[str, BaseChatModel] = {"OpenAI": ChatOpenAI}
DEFAULT_MODEL = "gpt-3.5-turbo"
DEFAULT_TEMPERATURE = 0

Expand Down
6 changes: 4 additions & 2 deletions vizro-ai/src/vizro_ai/dashboard/response_models/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def create(self, model, df_metadata) -> ComponentType:
elif self.component_type == "AgGrid":
return vm.AgGrid(id=component_id_unique, figure=dash_ag_grid(data_frame=self.df_name))
elif self.component_type == "Card":
result_proxy = _get_pydantic_output(
query=self.component_description, llm_model=model, response_model=vm.Card
card_prompt = (
"The Card uses the dcc.Markdown component from Dash as its underlying text component. "
f"Create a card based on the card description: {self.component_description}."
)
result_proxy = _get_pydantic_output(query=card_prompt, llm_model=model, response_model=vm.Card)
proxy_dict = result_proxy.dict()
proxy_dict["id"] = component_id_unique
return vm.Card.parse_obj(proxy_dict)
Expand Down
18 changes: 2 additions & 16 deletions vizro-ai/src/vizro_ai/dashboard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
import tqdm.std as tsd
import vizro.models as vm

IMPORT_STATEMENTS = (
"import vizro.plotly.express as px\n"
"from vizro.models.types import capture\n"
"import plotly.graph_objects as go\n"
"from vizro.tables import dash_ag_grid\n"
"from vizro.models import AgGrid, Card, Dashboard, Filter, Layout, Page, Graph\n"
"from vizro.managers import data_manager\n"
"from vizro import Vizro\n"
"import pandas as pd\n"
)


@dataclass
class MetadataContent:
Expand Down Expand Up @@ -69,11 +58,8 @@ def _execute_step(pbar: tsd.tqdm, description: str, value: Any) -> Any:

def _dashboard_code(dashboard: vm.Dashboard) -> str:
"""Generate dashboard code from dashboard object."""
dashboard_code_str = IMPORT_STATEMENTS + repr(dashboard)

# TODO: use black or ruff to format the code
# formatted_code = black.format_str(dashboard_code_str, mode=black.Mode())
return dashboard_code_str
# return dashboard.to_python()
return


def _run_dashboard(dashboard: vm.Dashboard, df_metadata: DfMetadata) -> None:
Expand Down

0 comments on commit 365d875

Please sign in to comment.