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

Reverting SQL Server Integration #872

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
"type": "chrome",
"request": "launch",
"name": "Frontend: Launch Chrome debugger",
"url": "http://127.0.0.1:50505",
"webRoot": "${workspaceFolder}/frontend",
"smartStep": true
"url": "http://127.0.0.1:50505"
}
]
}
3 changes: 0 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,9 @@ async def assets(path):
},
"sanitize_answer": app_settings.base_settings.sanitize_answer,
}


# Enable Microsoft Defender for Cloud Integration
MS_DEFENDER_ENABLED = os.environ.get("MS_DEFENDER_ENABLED", "true").lower() == "true"


# Initialize Azure OpenAI Client
def init_openai_client():
azure_openai_client = None
Expand Down
57 changes: 5 additions & 52 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ class _AzureSearchSettings(BaseSettings, DatasourcePayloadConstructor):
extra="ignore",
env_ignore_empty=True
)
_type: Literal["azure_search"] = PrivateAttr(default="azure_search")
service: str = Field(exclude=True)
endpoint_suffix: str = Field(default="search.windows.net", exclude=True)
index: str = Field(serialization_alias="index_name")
Expand Down Expand Up @@ -328,7 +327,7 @@ def construct_payload_configuration(
parameters.update(self._settings.search.model_dump(exclude_none=True, by_alias=True))

return {
"type": self._type,
"type": "azure_search",
"parameters": parameters
}

Expand All @@ -343,7 +342,6 @@ class _AzureCosmosDbMongoVcoreSettings(
extra="ignore",
env_ignore_empty=True
)
_type: Literal["azure_cosmosdb"] = PrivateAttr(default="azure_cosmosdb")
query_type: Literal['vector'] = "vector"
connection_string: str = Field(exclude=True)
index: str = Field(serialization_alias="index_name")
Expand Down Expand Up @@ -397,7 +395,7 @@ def construct_payload_configuration(
parameters = self.model_dump(exclude_none=True, by_alias=True)
parameters.update(self._settings.search.model_dump(exclude_none=True, by_alias=True))
return {
"type": self._type,
"type": "azure_cosmos_db",
"parameters": parameters
}

Expand All @@ -409,7 +407,6 @@ class _ElasticsearchSettings(BaseSettings, DatasourcePayloadConstructor):
extra="ignore",
env_ignore_empty=True
)
_type: Literal["elasticsearch"] = PrivateAttr(default="elasticsearch")
endpoint: str
encoded_api_key: str = Field(exclude=True)
index: str = Field(serialization_alias="index_name")
Expand Down Expand Up @@ -467,7 +464,7 @@ def construct_payload_configuration(
parameters.update(self._settings.search.model_dump(exclude_none=True, by_alias=True))

return {
"type": self._type,
"type": "elasticsearch",
"parameters": parameters
}

Expand All @@ -479,7 +476,6 @@ class _PineconeSettings(BaseSettings, DatasourcePayloadConstructor):
extra="ignore",
env_ignore_empty=True
)
_type: Literal["pinecone"] = PrivateAttr(default="pinecone")
environment: str
api_key: str = Field(exclude=True)
index_name: str
Expand Down Expand Up @@ -534,7 +530,7 @@ def construct_payload_configuration(
parameters.update(self._settings.search.model_dump(exclude_none=True, by_alias=True))

return {
"type": self._type,
"type": "pinecone",
"parameters": parameters
}

Expand All @@ -546,7 +542,6 @@ class _AzureMLIndexSettings(BaseSettings, DatasourcePayloadConstructor):
extra="ignore",
env_ignore_empty=True
)
_type: Literal["azure_ml_index"] = PrivateAttr(default="azure_ml_index")
name: str
version: str
project_resource_id: str = Field(validation_alias="AZURE_ML_PROJECT_RESOURCE_ID")
Expand Down Expand Up @@ -587,49 +582,11 @@ def construct_payload_configuration(
parameters.update(self._settings.search.model_dump(exclude_none=True, by_alias=True))

return {
"type": self._type,
"type": "azure_ml_index",
"parameters": parameters
}


class _AzureSqlServerSettings(BaseSettings, DatasourcePayloadConstructor):
model_config = SettingsConfigDict(
env_prefix="AZURE_SQL_SERVER_",
env_file=DOTENV_PATH,
extra="ignore"
)
_type: Literal["azure_sql_server"] = PrivateAttr(default="azure_sql_server")

connection_string: str = Field(exclude=True)
table_schema: str
schema_max_row: Optional[int] = None
top_n_results: Optional[int] = None

# Constructed fields
authentication: Optional[dict] = None

@model_validator(mode="after")
def construct_authentication(self) -> Self:
self.authentication = {
"type": "connection_string",
"connection_string": self.connection_string
}
return self

def construct_payload_configuration(
self,
*args,
**kwargs
):
parameters = self.model_dump(exclude_none=True, by_alias=True)
#parameters.update(self._settings.search.model_dump(exclude_none=True, by_alias=True))

return {
"type": self._type,
"parameters": parameters
}


class _BaseSettings(BaseSettings):
model_config = SettingsConfigDict(
env_file=DOTENV_PATH,
Expand Down Expand Up @@ -695,10 +652,6 @@ def set_datasource_settings(self) -> Self:
elif self.base_settings.datasource_type == "AzureMLIndex":
self.datasource = _AzureMLIndexSettings(settings=self, _env_file=DOTENV_PATH)
logging.debug("Using Azure ML Index")

elif self.base_settings.datasource_type == "AzureSqlServer":
self.datasource = _AzureSqlServerSettings(settings=self, _env_file=DOTENV_PATH)
logging.debug("Using SQL Server")

else:
self.datasource = None
Expand Down
Loading
Loading