llmfy 0.2.1__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 (70) hide show
  1. llmfy-0.2.1/LICENSE +21 -0
  2. llmfy-0.2.1/PKG-INFO +158 -0
  3. llmfy-0.2.1/README.md +126 -0
  4. llmfy-0.2.1/app/__init__.py +64 -0
  5. llmfy-0.2.1/app/exception/__init__.py +3 -0
  6. llmfy-0.2.1/app/exception/llmfy_exception.py +4 -0
  7. llmfy-0.2.1/app/llmfy/__init__.py +60 -0
  8. llmfy-0.2.1/app/llmfy/llmfy.py +361 -0
  9. llmfy-0.2.1/app/llmfy/messages/__init__.py +15 -0
  10. llmfy-0.2.1/app/llmfy/messages/content.py +51 -0
  11. llmfy-0.2.1/app/llmfy/messages/content_type.py +15 -0
  12. llmfy-0.2.1/app/llmfy/messages/message.py +68 -0
  13. llmfy-0.2.1/app/llmfy/messages/message_temp.py +84 -0
  14. llmfy-0.2.1/app/llmfy/messages/role.py +15 -0
  15. llmfy-0.2.1/app/llmfy/messages/tool_call.py +11 -0
  16. llmfy-0.2.1/app/llmfy/models/__init__.py +46 -0
  17. llmfy-0.2.1/app/llmfy/models/base_ai_model.py +31 -0
  18. llmfy-0.2.1/app/llmfy/models/bedrock/__init__.py +22 -0
  19. llmfy-0.2.1/app/llmfy/models/bedrock/bedrock_config.py +12 -0
  20. llmfy-0.2.1/app/llmfy/models/bedrock/bedrock_formatter.py +396 -0
  21. llmfy-0.2.1/app/llmfy/models/bedrock/bedrock_model.py +317 -0
  22. llmfy-0.2.1/app/llmfy/models/bedrock/bedrock_pricing_list.py +90 -0
  23. llmfy-0.2.1/app/llmfy/models/bedrock/bedrock_stream_usage_tracker.py +70 -0
  24. llmfy-0.2.1/app/llmfy/models/bedrock/bedrock_usage.py +200 -0
  25. llmfy-0.2.1/app/llmfy/models/bedrock/bedrock_usage_tracker.py +98 -0
  26. llmfy-0.2.1/app/llmfy/models/model_formatter.py +38 -0
  27. llmfy-0.2.1/app/llmfy/models/model_pricing.py +10 -0
  28. llmfy-0.2.1/app/llmfy/models/model_provider.py +13 -0
  29. llmfy-0.2.1/app/llmfy/models/openai/__init__.py +21 -0
  30. llmfy-0.2.1/app/llmfy/models/openai/openai_config.py +12 -0
  31. llmfy-0.2.1/app/llmfy/models/openai/openai_formatter.py +260 -0
  32. llmfy-0.2.1/app/llmfy/models/openai/openai_model.py +276 -0
  33. llmfy-0.2.1/app/llmfy/models/openai/openai_pricing_list.py +16 -0
  34. llmfy-0.2.1/app/llmfy/models/openai/openai_stream_usage_tracker.py +92 -0
  35. llmfy-0.2.1/app/llmfy/models/openai/openai_usage.py +165 -0
  36. llmfy-0.2.1/app/llmfy/models/openai/openai_usage_tracker.py +84 -0
  37. llmfy-0.2.1/app/llmfy/responses/__init__.py +4 -0
  38. llmfy-0.2.1/app/llmfy/responses/ai_response.py +12 -0
  39. llmfy-0.2.1/app/llmfy/responses/chat_response.py +13 -0
  40. llmfy-0.2.1/app/llmfy/tools/__init__.py +4 -0
  41. llmfy-0.2.1/app/llmfy/tools/deprecated.py +62 -0
  42. llmfy-0.2.1/app/llmfy/tools/function_parser.py +29 -0
  43. llmfy-0.2.1/app/llmfy/tools/function_type_mapping.py +9 -0
  44. llmfy-0.2.1/app/llmfy/tools/tool.py +38 -0
  45. llmfy-0.2.1/app/llmfy/tools/tool_registry.py +51 -0
  46. llmfy-0.2.1/app/llmfy/usage/__init__.py +4 -0
  47. llmfy-0.2.1/app/llmfy/usage/llmfy_usage.py +361 -0
  48. llmfy-0.2.1/app/llmfy/usage/usage_tracker.py +141 -0
  49. llmfy-0.2.1/app/llmfypipe/__init__.py +19 -0
  50. llmfy-0.2.1/app/llmfypipe/edge/__init__.py +3 -0
  51. llmfy-0.2.1/app/llmfypipe/edge/edge.py +13 -0
  52. llmfy-0.2.1/app/llmfypipe/helper/__init__.py +3 -0
  53. llmfy-0.2.1/app/llmfypipe/helper/tools_node/__init__.py +3 -0
  54. llmfy-0.2.1/app/llmfypipe/helper/tools_node/tools_node.py +25 -0
  55. llmfy-0.2.1/app/llmfypipe/llmfypipe.py +421 -0
  56. llmfy-0.2.1/app/llmfypipe/node/__init__.py +3 -0
  57. llmfy-0.2.1/app/llmfypipe/node/node.py +25 -0
  58. llmfy-0.2.1/app/llmfypipe/state/__init__.py +5 -0
  59. llmfy-0.2.1/app/llmfypipe/state/memory_manager.py +142 -0
  60. llmfy-0.2.1/app/llmfypipe/state/workflow_state.py +26 -0
  61. llmfy-0.2.1/app/llmfypipe/visualizer/__init__.py +3 -0
  62. llmfy-0.2.1/app/llmfypipe/visualizer/visualizer.py +57 -0
  63. llmfy-0.2.1/app/py.typed +0 -0
  64. llmfy-0.2.1/llmfy.egg-info/PKG-INFO +158 -0
  65. llmfy-0.2.1/llmfy.egg-info/SOURCES.txt +68 -0
  66. llmfy-0.2.1/llmfy.egg-info/dependency_links.txt +1 -0
  67. llmfy-0.2.1/llmfy.egg-info/requires.txt +7 -0
  68. llmfy-0.2.1/llmfy.egg-info/top_level.txt +1 -0
  69. llmfy-0.2.1/setup.cfg +4 -0
  70. llmfy-0.2.1/setup.py +30 -0
llmfy-0.2.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 irufano
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.
llmfy-0.2.1/PKG-INFO ADDED
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.4
2
+ Name: llmfy
3
+ Version: 0.2.1
4
+ Summary: `LLMfy` is a framework for developing applications with large language models (LLMs).
5
+ Home-page: https://github.com/irufano/llmfy
6
+ Author: irufano
7
+ Author-email: irufano.official@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires: pydantic
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: pydantic
16
+ Provides-Extra: openai
17
+ Requires-Dist: openai; extra == "openai"
18
+ Provides-Extra: boto3
19
+ Requires-Dist: boto3; extra == "boto3"
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: provides-extra
28
+ Dynamic: requires
29
+ Dynamic: requires-dist
30
+ Dynamic: requires-python
31
+ Dynamic: summary
32
+
33
+
34
+ <div align="center">
35
+
36
+ <a href="https://pypi.org/project/aigoofusion/">![llmfy](https://img.shields.io/badge/llmfy-0.2.1-30B445.svg?style=for-the-badge)</a>
37
+ <a href="">![python](https://img.shields.io/badge/python->=3.12-4392FF.svg?style=for-the-badge&logo=python&logoColor=4392FF)</a>
38
+
39
+ </div>
40
+
41
+ # llmfy
42
+
43
+ ![](llmfy-banner.png)
44
+
45
+ `LLMfy` is a framework for developing applications with large language models (LLMs).
46
+ - `LLMfy` is llm abstraction to use various llm on one module.
47
+ - `LLMfyPipe` is llm apps workflow.
48
+
49
+ ## How to install
50
+
51
+ - Prerequisites:
52
+ - Install [pydantic](https://pypi.org/project/pydantic) [required],
53
+ - Install [openai](https://pypi.org/project/openai) to use OpenAI models [optional].
54
+ - Install [boto3](https://pypi.org/project/boto3/) to use AWS Bedrock models [optional].
55
+
56
+ ### Using pip
57
+ ```sh
58
+ pip install llmfy
59
+ ```
60
+ ### using requirements.txt
61
+ - Add into requirements.txt
62
+ ```txt
63
+ llmfy
64
+ ```
65
+ - Then install
66
+ ```txt
67
+ pip install -r requirements.txt
68
+ ```
69
+
70
+ ## How to use
71
+ ### OpenAI models
72
+ To use `OpenAIModel`, add below config to your env:
73
+ - `OPENAI_API_KEY`
74
+
75
+ ### AWS Bedrock models
76
+ To use `BedrockModel`, add below config to your env:
77
+ - `AWS_ACCESS_KEY_ID`
78
+ - `AWS_SECRET_ACCESS_KEY`
79
+ - `AWS_BEDROCK_REGION`
80
+
81
+ ## Example
82
+ ### LLMfy Example
83
+ ```python
84
+ from aigoofusion import (
85
+ OpenAIModel,
86
+ OpenAIConfig,
87
+ LLMfy,
88
+ Message,
89
+ Role,
90
+ openai_usage_tracker,
91
+ LLMfyException,
92
+ )
93
+
94
+ def sample_prompt():
95
+ info = """
96
+ Irufano adalah seorang software engineer.
97
+ Dia berasal dari Indonesia.
98
+ Kamu bisa mengunjungi websitenya di https:://irufano.github.io
99
+ """
100
+
101
+ # Configuration
102
+ config = OpenAIConfig(temperature=0.7)
103
+ llm = OpenAIModel(model="gpt-4o-mini", config=config)
104
+
105
+ SYSTEM_PROMPT = """Answer any user questions based solely on the data below:
106
+ <data>
107
+ {info}
108
+ </data>
109
+
110
+ DO NOT response outside context."""
111
+
112
+ # Initialize framework
113
+ framework = LLMfy(llm, system_message=SYSTEM_PROMPT, input_variables=["info"])
114
+
115
+ try:
116
+ messages = [Message(role=Role.USER, content="apa ibukota china")]
117
+
118
+ response = framework.generate(messages, info=info)
119
+ print(f"\n>> {response.result.content}\n")
120
+
121
+ except LLMfyException as e:
122
+ print(f"{e}")
123
+
124
+
125
+ if __name__ == "__main__":
126
+ sample_prompt()
127
+ ```
128
+
129
+ ## Develop as Contributor
130
+ ### Build the container
131
+ ```sh
132
+ docker-compose build
133
+ ```
134
+
135
+ ### Run the container
136
+ ```sh
137
+ docker-compose up -d aigoofusion
138
+ ```
139
+
140
+ ### Stop the container
141
+ ```sh
142
+ docker-compose stop aigoofusion
143
+ ```
144
+
145
+ ### Access the container shell
146
+ ```sh
147
+ docker exec -it aigoofusion bash
148
+ ```
149
+
150
+ ### Build package
151
+ ```sh
152
+ python setup.py sdist bdist_wheel
153
+ ```
154
+
155
+ ### Upload package
156
+ ```sh
157
+ twine upload dist/*
158
+ ```
llmfy-0.2.1/README.md ADDED
@@ -0,0 +1,126 @@
1
+
2
+ <div align="center">
3
+
4
+ <a href="https://pypi.org/project/aigoofusion/">![llmfy](https://img.shields.io/badge/llmfy-0.2.1-30B445.svg?style=for-the-badge)</a>
5
+ <a href="">![python](https://img.shields.io/badge/python->=3.12-4392FF.svg?style=for-the-badge&logo=python&logoColor=4392FF)</a>
6
+
7
+ </div>
8
+
9
+ # llmfy
10
+
11
+ ![](llmfy-banner.png)
12
+
13
+ `LLMfy` is a framework for developing applications with large language models (LLMs).
14
+ - `LLMfy` is llm abstraction to use various llm on one module.
15
+ - `LLMfyPipe` is llm apps workflow.
16
+
17
+ ## How to install
18
+
19
+ - Prerequisites:
20
+ - Install [pydantic](https://pypi.org/project/pydantic) [required],
21
+ - Install [openai](https://pypi.org/project/openai) to use OpenAI models [optional].
22
+ - Install [boto3](https://pypi.org/project/boto3/) to use AWS Bedrock models [optional].
23
+
24
+ ### Using pip
25
+ ```sh
26
+ pip install llmfy
27
+ ```
28
+ ### using requirements.txt
29
+ - Add into requirements.txt
30
+ ```txt
31
+ llmfy
32
+ ```
33
+ - Then install
34
+ ```txt
35
+ pip install -r requirements.txt
36
+ ```
37
+
38
+ ## How to use
39
+ ### OpenAI models
40
+ To use `OpenAIModel`, add below config to your env:
41
+ - `OPENAI_API_KEY`
42
+
43
+ ### AWS Bedrock models
44
+ To use `BedrockModel`, add below config to your env:
45
+ - `AWS_ACCESS_KEY_ID`
46
+ - `AWS_SECRET_ACCESS_KEY`
47
+ - `AWS_BEDROCK_REGION`
48
+
49
+ ## Example
50
+ ### LLMfy Example
51
+ ```python
52
+ from aigoofusion import (
53
+ OpenAIModel,
54
+ OpenAIConfig,
55
+ LLMfy,
56
+ Message,
57
+ Role,
58
+ openai_usage_tracker,
59
+ LLMfyException,
60
+ )
61
+
62
+ def sample_prompt():
63
+ info = """
64
+ Irufano adalah seorang software engineer.
65
+ Dia berasal dari Indonesia.
66
+ Kamu bisa mengunjungi websitenya di https:://irufano.github.io
67
+ """
68
+
69
+ # Configuration
70
+ config = OpenAIConfig(temperature=0.7)
71
+ llm = OpenAIModel(model="gpt-4o-mini", config=config)
72
+
73
+ SYSTEM_PROMPT = """Answer any user questions based solely on the data below:
74
+ <data>
75
+ {info}
76
+ </data>
77
+
78
+ DO NOT response outside context."""
79
+
80
+ # Initialize framework
81
+ framework = LLMfy(llm, system_message=SYSTEM_PROMPT, input_variables=["info"])
82
+
83
+ try:
84
+ messages = [Message(role=Role.USER, content="apa ibukota china")]
85
+
86
+ response = framework.generate(messages, info=info)
87
+ print(f"\n>> {response.result.content}\n")
88
+
89
+ except LLMfyException as e:
90
+ print(f"{e}")
91
+
92
+
93
+ if __name__ == "__main__":
94
+ sample_prompt()
95
+ ```
96
+
97
+ ## Develop as Contributor
98
+ ### Build the container
99
+ ```sh
100
+ docker-compose build
101
+ ```
102
+
103
+ ### Run the container
104
+ ```sh
105
+ docker-compose up -d aigoofusion
106
+ ```
107
+
108
+ ### Stop the container
109
+ ```sh
110
+ docker-compose stop aigoofusion
111
+ ```
112
+
113
+ ### Access the container shell
114
+ ```sh
115
+ docker exec -it aigoofusion bash
116
+ ```
117
+
118
+ ### Build package
119
+ ```sh
120
+ python setup.py sdist bdist_wheel
121
+ ```
122
+
123
+ ### Upload package
124
+ ```sh
125
+ twine upload dist/*
126
+ ```
@@ -0,0 +1,64 @@
1
+ from .llmfy import (
2
+ LLMfy,
3
+ AIResponse,
4
+ ChatResponse,
5
+ Message,
6
+ Role,
7
+ Tool,
8
+ ToolRegistry,
9
+ OpenAIConfig,
10
+ OpenAIModel,
11
+ openai_usage_tracker,
12
+ track_openai_usage,
13
+ openai_stream_usage_tracker,
14
+ BedrockConfig,
15
+ BedrockModel,
16
+ bedrock_usage_tracker,
17
+ track_bedrock_usage,
18
+ bedrock_stream_usage_tracker,
19
+ llmfy_usage_tracker,
20
+ )
21
+
22
+ from .exception import LLMfyException
23
+
24
+ from .llmfypipe import (
25
+ LLMfyPipe,
26
+ Edge,
27
+ tools_node,
28
+ Node,
29
+ WorkflowState,
30
+ MemoryManager,
31
+ START,
32
+ END,
33
+ )
34
+
35
+ __all__ = [
36
+ "LLMfy",
37
+ "Message",
38
+ "Role",
39
+ "Tool",
40
+ "ToolRegistry",
41
+ "AIResponse",
42
+ "ChatResponse",
43
+ "OpenAIConfig",
44
+ "OpenAIModel",
45
+ "track_openai_usage",
46
+ "openai_usage_tracker",
47
+ "openai_stream_usage_tracker",
48
+ "LLMfyException",
49
+ "LLMfyPipe",
50
+ "Edge",
51
+ "tools_node",
52
+ "Node",
53
+ "START",
54
+ "END",
55
+ "WorkflowState",
56
+ "MemoryManager",
57
+ "BedrockConfig",
58
+ "BedrockModel",
59
+ "bedrock_usage_tracker",
60
+ "track_bedrock_usage",
61
+ "bedrock_stream_usage_tracker",
62
+ "LLMfyUsage",
63
+ "llmfy_usage_tracker",
64
+ ]
@@ -0,0 +1,3 @@
1
+ from .llmfy_exception import LLMfyException
2
+
3
+ __all__ = ["LLMfyException"]
@@ -0,0 +1,4 @@
1
+ class LLMfyException(Exception):
2
+ """LLMfyException Class"""
3
+
4
+ pass
@@ -0,0 +1,60 @@
1
+ from .llmfy import LLMfy
2
+ from .messages import Message, MessageTemp, Role, ToolCall, Content, ContentType
3
+ from .tools import ToolRegistry, Tool
4
+ from .responses import AIResponse, ChatResponse
5
+ from .models import (
6
+ BaseAIModel,
7
+ ModelPricing,
8
+ OpenAIConfig,
9
+ OpenAIModel,
10
+ OPENAI_PRICING,
11
+ track_openai_usage,
12
+ openai_usage_tracker,
13
+ track_openai_stream_usage,
14
+ openai_stream_usage_tracker,
15
+ OpenAIUsage,
16
+ BedrockFormatter,
17
+ BedrockConfig,
18
+ BedrockModel,
19
+ BEDROCK_PRICING,
20
+ bedrock_usage_tracker,
21
+ track_bedrock_usage,
22
+ BedrockUsage,
23
+ bedrock_stream_usage_tracker,
24
+ track_bedrock_stream_usage,
25
+ )
26
+ from .usage import llmfy_usage_tracker
27
+
28
+ __all__ = [
29
+ "LLMfy",
30
+ "MessageTemp",
31
+ "Message",
32
+ "Role",
33
+ "ToolCall",
34
+ "ToolRegistry",
35
+ "Tool",
36
+ "AIResponse",
37
+ "ChatResponse",
38
+ "BaseAIModel",
39
+ "ModelPricing",
40
+ "OpenAIConfig",
41
+ "OpenAIModel",
42
+ "OPENAI_PRICING",
43
+ "track_openai_usage",
44
+ "openai_usage_tracker",
45
+ "track_openai_stream_usage",
46
+ "openai_stream_usage_tracker",
47
+ "OpenAIUsage",
48
+ "BedrockConfig",
49
+ "BedrockFormatter",
50
+ "BedrockModel",
51
+ "BEDROCK_PRICING",
52
+ "bedrock_usage_tracker",
53
+ "track_bedrock_usage",
54
+ "BedrockUsage",
55
+ "bedrock_stream_usage_tracker",
56
+ "track_bedrock_stream_usage",
57
+ "Content",
58
+ "ContentType",
59
+ "llmfy_usage_tracker",
60
+ ]