simplified-genai 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. simplified_genai-0.1.0/.github/workflows/ci.yml +32 -0
  2. simplified_genai-0.1.0/.github/workflows/publish.yml +33 -0
  3. simplified_genai-0.1.0/.gitignore +224 -0
  4. simplified_genai-0.1.0/LICENSE +21 -0
  5. simplified_genai-0.1.0/PKG-INFO +172 -0
  6. simplified_genai-0.1.0/README.md +147 -0
  7. simplified_genai-0.1.0/pyproject.toml +52 -0
  8. simplified_genai-0.1.0/src/simplified_genai/__init__.py +58 -0
  9. simplified_genai-0.1.0/src/simplified_genai/exceptions/__init__.py +3 -0
  10. simplified_genai-0.1.0/src/simplified_genai/exceptions/gen_ai_overloaded_error.py +4 -0
  11. simplified_genai-0.1.0/src/simplified_genai/interfaces/__init__.py +16 -0
  12. simplified_genai-0.1.0/src/simplified_genai/interfaces/i_chat_session_service.py +19 -0
  13. simplified_genai-0.1.0/src/simplified_genai/interfaces/i_chat_session_store.py +22 -0
  14. simplified_genai-0.1.0/src/simplified_genai/interfaces/i_gen_ai_provider.py +57 -0
  15. simplified_genai-0.1.0/src/simplified_genai/interfaces/i_gen_ai_provider_factory.py +21 -0
  16. simplified_genai-0.1.0/src/simplified_genai/models/__init__.py +36 -0
  17. simplified_genai-0.1.0/src/simplified_genai/models/base_file_upload_result_dto.py +4 -0
  18. simplified_genai-0.1.0/src/simplified_genai/models/chat_session.py +12 -0
  19. simplified_genai-0.1.0/src/simplified_genai/models/file_dto.py +8 -0
  20. simplified_genai-0.1.0/src/simplified_genai/models/gemini_upload_result_dto.py +9 -0
  21. simplified_genai-0.1.0/src/simplified_genai/models/gen_ai_chat_message.py +13 -0
  22. simplified_genai-0.1.0/src/simplified_genai/models/gen_ai_model.py +14 -0
  23. simplified_genai-0.1.0/src/simplified_genai/models/gpt_upload_result_dto.py +9 -0
  24. simplified_genai-0.1.0/src/simplified_genai/models/grok_upload_result_dto.py +7 -0
  25. simplified_genai-0.1.0/src/simplified_genai/models/tool_choice.py +7 -0
  26. simplified_genai-0.1.0/src/simplified_genai/models/tool_definition.py +134 -0
  27. simplified_genai-0.1.0/src/simplified_genai/models/upload_result_wrapper_dto.py +19 -0
  28. simplified_genai-0.1.0/src/simplified_genai/providers/__init__.py +16 -0
  29. simplified_genai-0.1.0/src/simplified_genai/providers/gemini_gen_ai_provider.py +456 -0
  30. simplified_genai-0.1.0/src/simplified_genai/providers/gen_ai_provider_factory.py +60 -0
  31. simplified_genai-0.1.0/src/simplified_genai/providers/gpt_gen_ai_provider.py +425 -0
  32. simplified_genai-0.1.0/src/simplified_genai/providers/grok_gen_ai_provider.py +437 -0
  33. simplified_genai-0.1.0/src/simplified_genai/py.typed +1 -0
  34. simplified_genai-0.1.0/src/simplified_genai/services/__init__.py +4 -0
  35. simplified_genai-0.1.0/src/simplified_genai/services/chat_session_service.py +49 -0
  36. simplified_genai-0.1.0/src/simplified_genai/stores/__init__.py +6 -0
  37. simplified_genai-0.1.0/src/simplified_genai/stores/in_memory_chat_session_store.py +32 -0
  38. simplified_genai-0.1.0/tests/__init__.py +1 -0
  39. simplified_genai-0.1.0/tests/test_chat_session_service.py +70 -0
  40. simplified_genai-0.1.0/tests/test_provider_factory.py +132 -0
  41. simplified_genai-0.1.0/tests/test_tool_definition.py +129 -0
  42. simplified_genai-0.1.0/uv.lock +2079 -0
@@ -0,0 +1,32 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v5
21
+ with:
22
+ enable-cache: true
23
+
24
+ - name: Set up Python ${{ matrix.python-version }}
25
+ run: uv python install ${{ matrix.python-version }}
26
+
27
+ - name: Install dependencies
28
+ run: uv sync --all-extras --dev
29
+
30
+ - name: Run tests
31
+ run: uv run pytest
32
+
@@ -0,0 +1,33 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build-and-publish:
11
+ name: Build distribution and publish to PyPI
12
+ runs-on: ubuntu-latest
13
+ environment:
14
+ name: pypi
15
+ url: https://pypi.org/p/simplified-genai
16
+ permissions:
17
+ id-token: write
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+
22
+ - name: Install uv
23
+ uses: astral-sh/setup-uv@v5
24
+
25
+ - name: Set up Python
26
+ run: uv python install 3.12
27
+
28
+ - name: Build distributions
29
+ run: uv build
30
+
31
+ - name: Publish package distributions to PyPI
32
+ uses: pypa/gh-action-pypi-publish@release/v1
33
+
@@ -0,0 +1,224 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # UV
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Spyder project settings
163
+ .spyderproject
164
+ .spyproject
165
+
166
+ # Rope project settings
167
+ .ropeproject
168
+
169
+ # mkdocs documentation
170
+ /site
171
+
172
+ # mypy
173
+ .mypy_cache/
174
+ .dmypy.json
175
+ dmypy.json
176
+
177
+ # Pyre type checker
178
+ .pyre/
179
+
180
+ # pytype static type analyzer
181
+ .pytype/
182
+
183
+ # Cython debug symbols
184
+ cython_debug/
185
+
186
+ # PyCharm
187
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
190
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
191
+ # .idea/
192
+
193
+ # Abstra
194
+ # Abstra is an AI-powered process automation framework.
195
+ # Ignore directories containing user credentials, local state, and settings.
196
+ # Learn more at https://abstra.io/docs
197
+ .abstra/
198
+
199
+ # Visual Studio Code
200
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
201
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
203
+ # you could uncomment the following to ignore the entire vscode folder
204
+ # .vscode/
205
+ # Temporary file for partial code execution
206
+ tempCodeRunnerFile.py
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
221
+
222
+ #### Custom ####
223
+ .vscode/
224
+ .idea/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.4
2
+ Name: simplified-genai
3
+ Version: 0.1.0
4
+ Summary: A streamlined, multi-provider Generative AI abstraction layer for Gemini, OpenAI GPT, and xAI Grok.
5
+ Author-email: Daniyal <57293258+DaniyalAhmadSE@users.noreply.github.com>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: ai,gemini,genai,grok,llm,openai,tools
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: google-genai>=1.0.0
20
+ Requires-Dist: loguru>=0.7.0
21
+ Requires-Dist: openai>=1.0.0
22
+ Requires-Dist: pydantic>=2.0.0
23
+ Requires-Dist: xai-sdk>=1.8.1
24
+ Description-Content-Type: text/markdown
25
+
26
+ # simplified-genai
27
+
28
+ A streamlined, unified Generative AI abstraction layer for Python supporting **Google Gemini**, **OpenAI GPT**, and **xAI Grok**.
29
+
30
+ ## Features
31
+
32
+ - **Unified Provider Interface (`IGenAiProvider`)**: Switch seamlessly between Gemini, GPT, and Grok without rewriting code.
33
+ - **Structured Outputs**: Direct type-safe deserialization into Pydantic models with schema enforcement.
34
+ - **Python Function Calling / Tool Use (`ToolDefinition`)**: Automatic JSON schema generation from standard Python functions and type hints.
35
+ - **Multimodal File Uploads**: Uniform file uploading and handling across multimodal models.
36
+ - **Decoupled Chat Sessions**: `IChatSessionStore` protocol with a built-in `InMemoryChatSessionStore` for instant local usage or testing.
37
+ - **Provider Factory (`GenAiProviderFactory`)**: Dynamic primary and fallback provider resolution.
38
+
39
+ ---
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ pip install simplified-genai
45
+ ```
46
+
47
+ Or using `uv`:
48
+
49
+ ```bash
50
+ uv add simplified-genai
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Quickstart
56
+
57
+ ### 1. Basic Text Generation
58
+
59
+ ```python
60
+ import asyncio
61
+ from simplified_genai import GeminiGenAiProvider, GenAiModel
62
+
63
+ async def main():
64
+ provider = GeminiGenAiProvider(
65
+ api_key="YOUR_GEMINI_API_KEY",
66
+ supported_models=[GenAiModel.GEMINI_2_5_FLASH],
67
+ default_model=GenAiModel.GEMINI_2_5_FLASH,
68
+ )
69
+
70
+ response = await provider.get_raw_text_response(
71
+ user_prompt="Explain quantum computing in one sentence."
72
+ )
73
+ print(response)
74
+
75
+ asyncio.run(main())
76
+ ```
77
+
78
+ ### 2. Structured Output with Pydantic
79
+
80
+ ```python
81
+ import asyncio
82
+ from pydantic import BaseModel
83
+ from simplified_genai import GptGenAiProvider, GenAiModel
84
+
85
+ class CapitalCity(BaseModel):
86
+ country: str
87
+ capital: str
88
+ population_millions: float
89
+
90
+ async def main():
91
+ provider = GptGenAiProvider(
92
+ api_key="YOUR_OPENAI_API_KEY",
93
+ supported_models=[GenAiModel.GPT_5_NANO],
94
+ default_model=GenAiModel.GPT_5_NANO,
95
+ )
96
+
97
+ result = await provider.get_structured_response(
98
+ schema=CapitalCity,
99
+ user_prompt="What is the capital of France?",
100
+ )
101
+ print(f"{result.capital}, {result.country} (Pop: {result.population_millions}M)")
102
+
103
+ asyncio.run(main())
104
+ ```
105
+
106
+ ### 3. Tool Calling / Function Calling
107
+
108
+ ```python
109
+ import asyncio
110
+ from simplified_genai import GeminiGenAiProvider, GenAiModel, ToolDefinition
111
+
112
+ def get_weather(location: str) -> str:
113
+ """Get the current weather for a given location."""
114
+ return f"Weather in {location} is 22°C and sunny."
115
+
116
+ weather_tool = ToolDefinition(
117
+ function=get_weather,
118
+ description="Get current weather in a city"
119
+ )
120
+
121
+ async def main():
122
+ provider = GeminiGenAiProvider(
123
+ api_key="YOUR_GEMINI_API_KEY",
124
+ supported_models=[GenAiModel.GEMINI_2_5_FLASH],
125
+ default_model=GenAiModel.GEMINI_2_5_FLASH,
126
+ )
127
+
128
+ response = await provider.get_raw_text_response(
129
+ user_prompt="What's the weather in Tokyo?",
130
+ tools=[weather_tool],
131
+ )
132
+ print(response)
133
+
134
+ asyncio.run(main())
135
+ ```
136
+
137
+ ### 4. Chat Session Management
138
+
139
+ ```python
140
+ import asyncio
141
+ from simplified_genai import (
142
+ ChatSessionService,
143
+ InMemoryChatSessionStore,
144
+ GenAiChatMessage,
145
+ GenAiChatMessageRole,
146
+ )
147
+
148
+ async def main():
149
+ # Use the built-in in-memory store, or implement IChatSessionStore for Redis/Postgres/Mongo
150
+ store = InMemoryChatSessionStore()
151
+ chat_service = ChatSessionService(store=store)
152
+
153
+ session_id = chat_service.start_session()
154
+
155
+ await chat_service.append_turn(
156
+ session_id=session_id,
157
+ user_message=GenAiChatMessage(role=GenAiChatMessageRole.USER, content="Hello!"),
158
+ assistant_message=GenAiChatMessage(role=GenAiChatMessageRole.ASSISTANT, content="Hi there! How can I help?"),
159
+ )
160
+
161
+ history = await chat_service.get_history(session_id)
162
+ for msg in history:
163
+ print(f"[{msg.role}]: {msg.content}")
164
+
165
+ asyncio.run(main())
166
+ ```
167
+
168
+ ---
169
+
170
+ ## License
171
+
172
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,147 @@
1
+ # simplified-genai
2
+
3
+ A streamlined, unified Generative AI abstraction layer for Python supporting **Google Gemini**, **OpenAI GPT**, and **xAI Grok**.
4
+
5
+ ## Features
6
+
7
+ - **Unified Provider Interface (`IGenAiProvider`)**: Switch seamlessly between Gemini, GPT, and Grok without rewriting code.
8
+ - **Structured Outputs**: Direct type-safe deserialization into Pydantic models with schema enforcement.
9
+ - **Python Function Calling / Tool Use (`ToolDefinition`)**: Automatic JSON schema generation from standard Python functions and type hints.
10
+ - **Multimodal File Uploads**: Uniform file uploading and handling across multimodal models.
11
+ - **Decoupled Chat Sessions**: `IChatSessionStore` protocol with a built-in `InMemoryChatSessionStore` for instant local usage or testing.
12
+ - **Provider Factory (`GenAiProviderFactory`)**: Dynamic primary and fallback provider resolution.
13
+
14
+ ---
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install simplified-genai
20
+ ```
21
+
22
+ Or using `uv`:
23
+
24
+ ```bash
25
+ uv add simplified-genai
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Quickstart
31
+
32
+ ### 1. Basic Text Generation
33
+
34
+ ```python
35
+ import asyncio
36
+ from simplified_genai import GeminiGenAiProvider, GenAiModel
37
+
38
+ async def main():
39
+ provider = GeminiGenAiProvider(
40
+ api_key="YOUR_GEMINI_API_KEY",
41
+ supported_models=[GenAiModel.GEMINI_2_5_FLASH],
42
+ default_model=GenAiModel.GEMINI_2_5_FLASH,
43
+ )
44
+
45
+ response = await provider.get_raw_text_response(
46
+ user_prompt="Explain quantum computing in one sentence."
47
+ )
48
+ print(response)
49
+
50
+ asyncio.run(main())
51
+ ```
52
+
53
+ ### 2. Structured Output with Pydantic
54
+
55
+ ```python
56
+ import asyncio
57
+ from pydantic import BaseModel
58
+ from simplified_genai import GptGenAiProvider, GenAiModel
59
+
60
+ class CapitalCity(BaseModel):
61
+ country: str
62
+ capital: str
63
+ population_millions: float
64
+
65
+ async def main():
66
+ provider = GptGenAiProvider(
67
+ api_key="YOUR_OPENAI_API_KEY",
68
+ supported_models=[GenAiModel.GPT_5_NANO],
69
+ default_model=GenAiModel.GPT_5_NANO,
70
+ )
71
+
72
+ result = await provider.get_structured_response(
73
+ schema=CapitalCity,
74
+ user_prompt="What is the capital of France?",
75
+ )
76
+ print(f"{result.capital}, {result.country} (Pop: {result.population_millions}M)")
77
+
78
+ asyncio.run(main())
79
+ ```
80
+
81
+ ### 3. Tool Calling / Function Calling
82
+
83
+ ```python
84
+ import asyncio
85
+ from simplified_genai import GeminiGenAiProvider, GenAiModel, ToolDefinition
86
+
87
+ def get_weather(location: str) -> str:
88
+ """Get the current weather for a given location."""
89
+ return f"Weather in {location} is 22°C and sunny."
90
+
91
+ weather_tool = ToolDefinition(
92
+ function=get_weather,
93
+ description="Get current weather in a city"
94
+ )
95
+
96
+ async def main():
97
+ provider = GeminiGenAiProvider(
98
+ api_key="YOUR_GEMINI_API_KEY",
99
+ supported_models=[GenAiModel.GEMINI_2_5_FLASH],
100
+ default_model=GenAiModel.GEMINI_2_5_FLASH,
101
+ )
102
+
103
+ response = await provider.get_raw_text_response(
104
+ user_prompt="What's the weather in Tokyo?",
105
+ tools=[weather_tool],
106
+ )
107
+ print(response)
108
+
109
+ asyncio.run(main())
110
+ ```
111
+
112
+ ### 4. Chat Session Management
113
+
114
+ ```python
115
+ import asyncio
116
+ from simplified_genai import (
117
+ ChatSessionService,
118
+ InMemoryChatSessionStore,
119
+ GenAiChatMessage,
120
+ GenAiChatMessageRole,
121
+ )
122
+
123
+ async def main():
124
+ # Use the built-in in-memory store, or implement IChatSessionStore for Redis/Postgres/Mongo
125
+ store = InMemoryChatSessionStore()
126
+ chat_service = ChatSessionService(store=store)
127
+
128
+ session_id = chat_service.start_session()
129
+
130
+ await chat_service.append_turn(
131
+ session_id=session_id,
132
+ user_message=GenAiChatMessage(role=GenAiChatMessageRole.USER, content="Hello!"),
133
+ assistant_message=GenAiChatMessage(role=GenAiChatMessageRole.ASSISTANT, content="Hi there! How can I help?"),
134
+ )
135
+
136
+ history = await chat_service.get_history(session_id)
137
+ for msg in history:
138
+ print(f"[{msg.role}]: {msg.content}")
139
+
140
+ asyncio.run(main())
141
+ ```
142
+
143
+ ---
144
+
145
+ ## License
146
+
147
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "simplified-genai"
7
+ version = "0.1.0"
8
+ description = "A streamlined, multi-provider Generative AI abstraction layer for Gemini, OpenAI GPT, and xAI Grok."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Daniyal", email = "57293258+DaniyalAhmadSE@users.noreply.github.com" }
14
+ ]
15
+ keywords = ["llm", "genai", "gemini", "openai", "grok", "ai", "tools"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ "Typing :: Typed",
26
+ ]
27
+ dependencies = [
28
+ "pydantic>=2.0.0",
29
+ "loguru>=0.7.0",
30
+ "google-genai>=1.0.0",
31
+ "openai>=1.0.0",
32
+ "xai-sdk>=1.8.1",
33
+ ]
34
+
35
+ [dependency-groups]
36
+ dev = [
37
+ "pytest>=8.0.0",
38
+ "pytest-asyncio>=0.23.0",
39
+ "twine>=5.0.0",
40
+ ]
41
+
42
+ [tool.pytest.ini_options]
43
+ asyncio_mode = "auto"
44
+ testpaths = ["tests"]
45
+
46
+ [tool.hatch.build.targets.wheel]
47
+ packages = ["src/simplified_genai"]
48
+ core-metadata-version = "2.4"
49
+
50
+ [tool.hatch.build.targets.sdist]
51
+ core-metadata-version = "2.4"
52
+