Skip to content

Commit 18bf1df

Browse files
committed
Improving documentation
1 parent 5d6b967 commit 18bf1df

File tree

13 files changed

+109
-7
lines changed

13 files changed

+109
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Based on the [arXiv preprint](https://arxiv.org/abs/2506.11781), **GeoPandas-AI*
4343

4444
```bash
4545
pip install geopandas-ai
46-
````
46+
```
4747

4848
Python 3.8+ required.
4949

docs/api.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
::: geopandasai
1+
# API Documentation
2+
3+
## GeoDataFrame AI
4+
5+
::: geodataframe_ai
6+
7+
## Configuration
8+
9+
::: config
10+
11+
## GeoPandas Wrapper
12+
13+
::: wrapper
14+
15+
16+
## Services
17+
18+
### Cache Backend
19+
20+
::: external.cache.backend.base
21+
::: external.cache.backend.file_system
22+
::: external.cache.backend.in_memory
23+
24+
25+
### Code Execution Backend
26+
27+
::: services.code.executor.base
28+
::: services.code.executor.trusted
29+
::: services.code.executor.untrusted

docs/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GeoPandas-AI requires **Python 3.8+**. Install via pip:
1010

1111
```bash
1212
pip install geopandas-ai
13-
````
13+
```
1414

1515
This will pull in dependencies including GeoPandas and LiteLLM.
1616

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Based on the [arXiv preprint](https://arxiv.org/abs/2506.11781), **GeoPandas-AI*
4545

4646
```bash
4747
pip install geopandas-ai
48-
````
48+
```
4949

5050
Python 3.8+ required.
5151

geopandasai/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121

2222
@dataclass(frozen=True, eq=True)
2323
class GeoPandasAIConfig:
24+
"""
25+
Configuration class for GeoPandasAI.
26+
27+
This class holds the configuration settings for GeoPandasAI, including
28+
the lite LLM configuration, libraries to be used, cache backend,
29+
data descriptor, code injector, code executor, and return types.
30+
It is designed to be immutable after creation, ensuring that the configuration
31+
remains consistent throughout the application.
32+
"""
33+
2434
lite_llm_config: Optional[dict] = field(
2535
default_factory=lambda: _load_default_lite_llm_config()
2636
)

geopandasai/external/cache/backend/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33

44

55
class ACacheBackend(abc.ABC):
6+
"""
7+
Base class for all cache backends.
8+
This class defines the interface for caching mechanisms used in GeoPandasAI.
9+
It provides methods to get, set, clear, and reset cache entries.
10+
Subclasses should implement these methods to provide specific caching functionality.
11+
"""
12+
613
def get_cache(self, key: str) -> Optional[bytes]:
714
"""
815
Get the cached result for the given key.

geopandasai/external/cache/backend/file_system.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66

77
class FileSystemCacheBackend(ACacheBackend):
8+
"""
9+
FileSystemCacheBackend is a cache backend that stores cached results in the file system.
10+
"""
11+
812
def __init__(self, cache_dir: str = "./.geopandasai_cache"):
913
self.cache_dir = cache_dir
1014
os.makedirs(cache_dir, exist_ok=True)

geopandasai/external/cache/backend/in_memory.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55

66
class InMemoryCacheBackend(ACacheBackend):
7+
"""
8+
InMemoryCacheBackend is a cache backend that stores cached results in memory.
9+
"""
10+
711
def __init__(self):
812
self.cache = {}
913

geopandasai/services/code/executor/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66

77
class ACodeExecutor(abc.ABC):
8+
"""
9+
Abstract base class for executing Python code.
10+
"""
11+
812
@abc.abstractmethod
913
def execute(self, code: str, return_type: Type, *dfs: Iterable[GeoOrDataFrame]):
1014
pass

geopandasai/services/code/executor/trusted.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@
77

88

99
class TrustedCodeExecutor(ACodeExecutor):
10+
"""
11+
A class for executing trusted Python code in a temporary file.
12+
13+
This class inherits from `ACodeExecutor` and provides functionality
14+
to safely execute Python code passed as a string. It ensures the
15+
result matches the expected return type and wraps GeoDataFrame results
16+
with `GeoDataFrameAI` for additional functionality.
17+
"""
18+
1019
def execute(self, code: str, return_type: Type, *dfs: Iterable[GeoOrDataFrame]):
20+
"""
21+
Executes the provided Python code in a temporary file and returns the result.
22+
:param code: The Python code to execute as a string.
23+
:param return_type: The expected return type of the code execution.
24+
:param dfs: An iterable of GeoDataFrame or DataFrame objects to be passed as arguments to the executed code.
25+
:return: The result of the executed code, wrapped in GeoDataFrameAI if it is a GeoDataFrame.
26+
"""
1127
with tempfile.NamedTemporaryFile(delete=True, suffix=".py", mode="w") as f:
1228
f.write(code)
1329
f.flush()

0 commit comments

Comments
 (0)