Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SemanticLayerSchema): Adding a SemanticLayerSchema class with logical and business validation #1516

Merged
merged 6 commits into from
Jan 14, 2025
5 changes: 3 additions & 2 deletions extensions/connectors/sql/tests/test_sql.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import unittest
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import pandas as pd

# Assuming the functions are in a module called db_loader
from pandasai_sql import (
load_from_cockroachdb,
load_from_mysql,
load_from_postgres,
load_from_sqlite,
load_from_cockroachdb,
)


Expand Down
3 changes: 2 additions & 1 deletion extensions/connectors/yfinance/tests/test_yahoo_finance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import pandas as pd

# Assuming the functions are in a module called yahoo_finance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from google.cloud import bigquery
import pandas as pd
from google.cloud import bigquery


def load_from_bigquery(connection_info, query):
Expand Down
5 changes: 3 additions & 2 deletions extensions/ee/connectors/bigquery/tests/test_bigquery.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import pandas as pd
import pytest
from pandasai_bigquery import load_from_bigquery


Expand Down
3 changes: 2 additions & 1 deletion extensions/ee/connectors/databricks/tests/test_databricks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

from pandasai_databricks import (
load_from_databricks,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pandas as pd
import cx_Oracle
import pandas as pd


def load_from_oracle(connection_info, query):
Expand Down
3 changes: 2 additions & 1 deletion extensions/ee/connectors/oracle/tests/test_oracle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import pandas as pd
from pandasai_oracle import load_from_oracle

Expand Down
3 changes: 2 additions & 1 deletion extensions/ee/connectors/snowflake/tests/test_snowflake.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import pandas as pd
from pandasai_snowflake import load_from_snowflake

Expand Down
2 changes: 1 addition & 1 deletion extensions/ee/vectorstores/chromadb/tests/test_chromadb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

from extensions.ee.vectorstores.chromadb.pandasai_chromadb import ChromaDB

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import uuid
from typing import Any, Callable, Iterable, List, Optional, Union

import pinecone
import uuid

from pandasai.helpers.logger import Logger
from pandasai.vectorstores.vectorstore import VectorStore

Expand Down
4 changes: 2 additions & 2 deletions extensions/ee/vectorstores/qdrant/tests/test_qdrant.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
import uuid
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

from qdrant_client import models

from extensions.ee.vectorstores.qdrant.pandasai_qdrant.qdrant import (
Qdrant,
UUID_NAMESPACE,
Qdrant,
)


Expand Down
1 change: 0 additions & 1 deletion extensions/llms/bedrock/pandasai_bedrock/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .claude import BedrockClaude


__all__ = ["BedrockClaude"]
4 changes: 1 addition & 3 deletions extensions/llms/bedrock/pandasai_bedrock/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
from typing import TYPE_CHECKING, Optional

from pandasai.core.prompts.base import BasePrompt
from pandasai.helpers.memory import Memory

from pandasai.exceptions import (
MethodNotImplementedError,
)
from pandasai.helpers.memory import Memory
from pandasai.llm.base import LLM


if TYPE_CHECKING:
from pandasai.agent.state import AgentState

Expand Down
2 changes: 1 addition & 1 deletion extensions/llms/bedrock/tests/test_bedrock_claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import pytest

from extensions.llms.bedrock.pandasai_bedrock.claude import BedrockClaude
from pandasai.core.prompts.base import BasePrompt
from pandasai.exceptions import APIKeyNotFoundError, UnsupportedModelError
from extensions.llms.bedrock.pandasai_bedrock.claude import BedrockClaude


class MockBedrockRuntimeClient:
Expand Down
2 changes: 1 addition & 1 deletion extensions/llms/google/pandasai_google/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .google_gemini import GoogleGemini
from .google_vertexai import GoogleVertexAI

__all__ = ["GoogleGemini", "GoogleVertexAI"]
__all__ = ["GoogleGemini", "GoogleVertexAI"]
4 changes: 1 addition & 3 deletions extensions/llms/google/pandasai_google/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
from typing import TYPE_CHECKING, Optional

from pandasai.core.prompts.base import BasePrompt
from pandasai.helpers.memory import Memory

from pandasai.exceptions import (
MethodNotImplementedError,
)
from pandasai.helpers.memory import Memory
from pandasai.llm.base import LLM


if TYPE_CHECKING:
from pandasai.agent.state import AgentState

Expand Down
3 changes: 2 additions & 1 deletion extensions/llms/google/pandasai_google/google_gemini.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Any, Optional

from pandasai.core.code_execution.environment import import_dependency
from pandasai.exceptions import APIKeyNotFoundError
from pandasai.helpers.memory import Memory
from pandasai.core.code_execution.environment import import_dependency

from .base import BaseGoogle


Expand Down
4 changes: 2 additions & 2 deletions extensions/llms/google/pandasai_google/google_vertexai.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Optional

from pandasai.core.code_execution.environment import import_dependency
from pandasai.exceptions import UnsupportedModelError
from pandasai.helpers.memory import Memory

from pandasai.exceptions import UnsupportedModelError
from pandasai.core.code_execution.environment import import_dependency
from .base import BaseGoogle


Expand Down
2 changes: 1 addition & 1 deletion extensions/llms/google/tests/test_google_vertexai.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Unit tests for the openai LLM class"""

import pytest
from pandasai_google.google_vertexai import GoogleVertexAI

from pandasai.exceptions import UnsupportedModelError
from pandasai_google.google_vertexai import GoogleVertexAI


class MockedCompletion:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

from typing import TYPE_CHECKING, Any, Dict, List, Optional


from pandasai.core.prompts.base import BasePrompt
from pandasai.helpers import load_dotenv

from pandasai.llm.base import LLM

if TYPE_CHECKING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pandasai_huggingface.huggingface_text_gen import (
HuggingFaceTextGen,
)

from pandasai.core.prompts.base import BasePrompt


Expand Down
1 change: 0 additions & 1 deletion extensions/llms/ibm/pandasai_ibm/ibm_watsonx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pandasai.core.prompts.base import BasePrompt
from pandasai.exceptions import APIKeyNotFoundError
from pandasai.helpers import load_dotenv

from pandasai.llm.base import LLM

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion extensions/llms/ibm/tests/test_ibm_watsonx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import pytest

from pandasai.exceptions import APIKeyNotFoundError
from extensions.llms.ibm.pandasai_ibm.ibm_watsonx import IBMwatsonx
from pandasai.exceptions import APIKeyNotFoundError


@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.10 or higher")
Expand Down
1 change: 0 additions & 1 deletion extensions/llms/langchain/pandasai_langchain/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from typing import TYPE_CHECKING


from pandasai.llm.base import LLM

if TYPE_CHECKING:
Expand Down
7 changes: 4 additions & 3 deletions extensions/llms/langchain/tests/test_langchain_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
GenerationChunk,
LLMResult,
)

from pandasai.llm.base import LLM
from pandasai_langchain.langchain import LangchainLLM

from pandasai.core.prompts.base import BasePrompt
from pandasai.llm.base import LLM


class TestLangchainLLM:
Expand Down Expand Up @@ -69,9 +69,10 @@ def test_langchain_chat_call(self, langchain_chat_llm, prompt):
)

def test_agent_integration(self):
from pandasai.agent import Agent
from unittest.mock import MagicMock, PropertyMock

from pandasai.agent import Agent

class FakeChatOpenAI(LLM):
openai_api_key: str = "fake_key"

Expand Down
1 change: 0 additions & 1 deletion extensions/llms/local/pandasai_local/local_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from pandasai.core.prompts.base import BasePrompt
from pandasai.helpers.memory import Memory

from pandasai.llm.base import LLM

if TYPE_CHECKING:
Expand Down
4 changes: 2 additions & 2 deletions extensions/llms/local/tests/test_local_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from unittest.mock import MagicMock, patch

import pytest

from pandasai.helpers.memory import Memory
from pandasai_local.local_llm import LocalLLM

from pandasai.core.prompts.base import BasePrompt
from pandasai.helpers.memory import Memory


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion extensions/llms/openai/pandasai_openai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .openai import OpenAI
from .azure_openai import AzureOpenAI
from .openai import OpenAI

__all__ = ["OpenAI", "AzureOpenAI"]
1 change: 1 addition & 0 deletions extensions/llms/openai/pandasai_openai/azure_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from pandasai.exceptions import APIKeyNotFoundError, MissingModelError
from pandasai.helpers import load_dotenv

from .base import BaseOpenAI

load_dotenv()
Expand Down
1 change: 0 additions & 1 deletion extensions/llms/openai/pandasai_openai/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from pandasai.core.prompts.base import BasePrompt
from pandasai.helpers.memory import Memory

from pandasai.llm.base import LLM

if TYPE_CHECKING:
Expand Down
1 change: 1 addition & 0 deletions extensions/llms/openai/pandasai_openai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from pandasai.exceptions import APIKeyNotFoundError, UnsupportedModelError
from pandasai.helpers import load_dotenv

from .base import BaseOpenAI

load_dotenv()
Expand Down
2 changes: 1 addition & 1 deletion extensions/llms/openai/tests/test_azure_openai.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Unit tests for the openai LLM class"""
import openai
import pytest
from pandasai_openai import AzureOpenAI

from pandasai.exceptions import APIKeyNotFoundError, MissingModelError
from pandasai_openai import AzureOpenAI


class OpenAIObject:
Expand Down
7 changes: 4 additions & 3 deletions extensions/llms/openai/tests/test_openai.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Unit tests for the openai LLM class"""

import os
from unittest import mock

import openai
import pytest
from unittest import mock
import os

from pandasai.exceptions import APIKeyNotFoundError, UnsupportedModelError
from extensions.llms.openai.pandasai_openai import OpenAI
from pandasai.core.prompts.base import BasePrompt
from pandasai.exceptions import APIKeyNotFoundError, UnsupportedModelError


class OpenAIObject:
Expand Down
4 changes: 4 additions & 0 deletions pandasai/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@
"databricks",
"oracle",
]

VALID_COLUMN_TYPES = ["string", "integer", "float", "datetime", "boolean"]

VALID_TRANSFORMATION_TYPES = ["anonymize", "convert_timezone"]
Loading
Loading