Skip to content

Commit

Permalink
fix: mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
jaluma committed Jul 8, 2024
1 parent 48f8aaf commit ee561c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
12 changes: 9 additions & 3 deletions private_gpt/components/vector_store/vector_store_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,29 @@ def __init__(self, settings: Settings) -> None:
)
case "clickhouse":
try:
from llama_index.vector_stores.clickhouse import ClickHouseVectorStore
from clickhouse_connect import get_client
from llama_index.vector_stores.clickhouse import ( # type: ignore
ClickHouseVectorStore,
)
except ImportError as e:
raise ImportError(
"ClickHouse dependencies not found, install with `poetry install --extras vector-stores-clickhouse`"
) from e

if settings.clickhouse is None:
raise ValueError("ClickHouse settings not found. Please provide settings.")
raise ValueError(
"ClickHouse settings not found. Please provide settings."
)

clickhouse_client = get_client(
host=settings.clickhouse.host,
port=settings.clickhouse.port,
username=settings.clickhouse.username,
password=settings.clickhouse.password,
)
self.vector_store = ClickHouseVectorStore(clickhouse_client=clickhouse_client)
self.vector_store = ClickHouseVectorStore(
clickhouse_client=clickhouse_client
)
case _:
# Should be unreachable
# The settings validator should have caught this
Expand Down
42 changes: 21 additions & 21 deletions private_gpt/settings/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Literal, Optional, Dict, Any, Union
from typing import Any, Literal

from pydantic import BaseModel, Field

Expand All @@ -15,7 +15,7 @@ class CorsSettings(BaseModel):

enabled: bool = Field(
description="Flag indicating if CORS headers are set or not."
"If set to True, the CORS headers will be set to allow all origins, methods and headers.",
"If set to True, the CORS headers will be set to allow all origins, methods and headers.",
default=False,
)
allow_credentials: bool = Field(
Expand Down Expand Up @@ -54,8 +54,8 @@ class AuthSettings(BaseModel):
)
secret: str = Field(
description="The secret to be used for authentication. "
"It can be any non-blank string. For HTTP basic authentication, "
"this value should be the whole 'Authorization' header that is expected"
"It can be any non-blank string. For HTTP basic authentication, "
"this value should be the whole 'Authorization' header that is expected"
)


Expand All @@ -76,7 +76,7 @@ class ServerSettings(BaseModel):
class DataSettings(BaseModel):
local_data_folder: str = Field(
description="Path to local storage."
"It will be treated as an absolute path if it starts with /"
"It will be treated as an absolute path if it starts with /"
)


Expand All @@ -95,10 +95,10 @@ class LLMSettings(BaseModel):
tokenizer: str = Field(
None,
description="The model id of a predefined tokenizer hosted inside a model repo on "
"huggingface.co. Valid model ids can be located at the root-level, like "
"`bert-base-uncased`, or namespaced under a user or organization name, "
"like `HuggingFaceH4/zephyr-7b-beta`. If not set, will load a tokenizer matching "
"gpt-3.5-turbo LLM.",
"huggingface.co. Valid model ids can be located at the root-level, like "
"`bert-base-uncased`, or namespaced under a user or organization name, "
"like `HuggingFaceH4/zephyr-7b-beta`. If not set, will load a tokenizer matching "
"gpt-3.5-turbo LLM.",
)
temperature: float = Field(
0.1,
Expand Down Expand Up @@ -356,51 +356,51 @@ class ClickHouseSettings(BaseModel):
"__default__",
description="The default database to use for connections",
)
secure: Union[bool, str] = Field(
secure: bool | str = Field(
False,
description="Use https/TLS for secure connection to the server",
)
interface: Optional[str] = Field(
interface: str | None = Field(
None,
description="Must be either 'http' or 'https'. Determines the protocol to use for the connection",
)
settings: Optional[Dict[str, Any]] = Field(
settings: dict[str, Any] | None = Field(
None,
description="Specific ClickHouse server settings to be used with the session",
)
connect_timeout: Optional[int] = Field(
connect_timeout: int | None = Field(
None,
description="Timeout in seconds for establishing a connection",
)
send_receive_timeout: Optional[int] = Field(
send_receive_timeout: int | None = Field(
None,
description="Read timeout in seconds for http connection",
)
verify: Optional[bool] = Field(
verify: bool | None = Field(
None,
description="Verify the server certificate in secure/https mode",
)
ca_cert: Optional[str] = Field(
ca_cert: str | None = Field(
None,
description="Path to Certificate Authority root certificate (.pem format)",
)
client_cert: Optional[str] = Field(
client_cert: str | None = Field(
None,
description="Path to TLS Client certificate (.pem format)",
)
client_cert_key: Optional[str] = Field(
client_cert_key: str | None = Field(
None,
description="Path to the private key for the TLS Client certificate",
)
http_proxy: Optional[str] = Field(
http_proxy: str | None = Field(
None,
description="HTTP proxy address",
)
https_proxy: Optional[str] = Field(
https_proxy: str | None = Field(
None,
description="HTTPS proxy address",
)
server_host_name: Optional[str] = Field(
server_host_name: str | None = Field(
None,
description="Server host name to be checked against the TLS certificate",
)
Expand Down

0 comments on commit ee561c3

Please sign in to comment.