abstract-package-test 0.0.1__py3.11.egg
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.
- EGG-INFO/PKG-INFO +18 -0
- EGG-INFO/SOURCES.txt +76 -0
- EGG-INFO/dependency_links.txt +1 -0
- EGG-INFO/entry_points.txt +16 -0
- EGG-INFO/not-zip-safe +1 -0
- EGG-INFO/top_level.txt +15 -0
- abstract_ai_test/__init__.py +0 -0
- abstract_ai_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_ai_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_ai_test/setup.py +37 -0
- abstract_ai_test/src/__init__.py +0 -0
- abstract_ai_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_ai_test/src/__pycache__/api_calls.cpython-311.pyc +0 -0
- abstract_ai_test/src/__pycache__/data_handler.cpython-311.pyc +0 -0
- abstract_ai_test/src/__pycache__/endpoints.cpython-311.pyc +0 -0
- abstract_ai_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_ai_test/src/__pycache__/message_aggregator.cpython-311.pyc +0 -0
- abstract_ai_test/src/__pycache__/prompts.cpython-311.pyc +0 -0
- abstract_ai_test/src/__pycache__/response_handling.cpython-311.pyc +0 -0
- abstract_ai_test/src/__pycache__/tokenization.cpython-311.pyc +0 -0
- abstract_ai_test/src/api_calls.py +72 -0
- abstract_ai_test/src/data_handler.py +80 -0
- abstract_ai_test/src/endpoints.py +110 -0
- abstract_ai_test/src/main.py +35 -0
- abstract_ai_test/src/message_aggregator.py +148 -0
- abstract_ai_test/src/prompts.py +270 -0
- abstract_ai_test/src/response_handling.py +32 -0
- abstract_ai_test/src/tokenization.py +35 -0
- abstract_api_test/__init__.py +0 -0
- abstract_api_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_api_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_api_test/setup.py +37 -0
- abstract_api_test/src/__init__.py +0 -0
- abstract_api_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_api_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_api_test/src/main.py +35 -0
- abstract_audio_test/__init__.py +0 -0
- abstract_audio_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_audio_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_audio_test/setup.py +37 -0
- abstract_audio_test/src/__init__.py +0 -0
- abstract_audio_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_audio_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_audio_test/src/main.py +35 -0
- abstract_authority_replica_test/__init__.py +0 -0
- abstract_authority_replica_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_authority_replica_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_authority_replica_test/setup.py +37 -0
- abstract_authority_replica_test/src/__init__.py +0 -0
- abstract_authority_replica_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_authority_replica_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_authority_replica_test/src/main.py +35 -0
- abstract_authority_test/__init__.py +0 -0
- abstract_authority_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_authority_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_authority_test/setup.py +37 -0
- abstract_authority_test/src/__init__.py +0 -0
- abstract_authority_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_authority_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_authority_test/src/main.py +35 -0
- abstract_crypto_test/__init__.py +0 -0
- abstract_crypto_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_crypto_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_crypto_test/setup.py +37 -0
- abstract_crypto_test/src/__init__.py +0 -0
- abstract_crypto_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_crypto_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_crypto_test/src/main.py +35 -0
- abstract_gui_test/__init__.py +0 -0
- abstract_gui_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_gui_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_gui_test/setup.py +37 -0
- abstract_gui_test/src/__init__.py +0 -0
- abstract_gui_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_gui_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_gui_test/src/main.py +35 -0
- abstract_images_test/__init__.py +0 -0
- abstract_images_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_images_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_images_test/setup.py +37 -0
- abstract_images_test/src/__init__.py +0 -0
- abstract_images_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_images_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_images_test/src/main.py +35 -0
- abstract_modules_test/__init__.py +0 -0
- abstract_modules_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_modules_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_modules_test/setup.py +37 -0
- abstract_modules_test/src/__init__.py +0 -0
- abstract_modules_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_modules_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_modules_test/src/main.py +35 -0
- abstract_paths_test/__init__.py +0 -0
- abstract_paths_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_paths_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_paths_test/setup.py +37 -0
- abstract_paths_test/src/__init__.py +0 -0
- abstract_paths_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_paths_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_paths_test/src/main.py +35 -0
- abstract_security_test/__init__.py +0 -0
- abstract_security_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_security_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_security_test/setup.py +37 -0
- abstract_security_test/src/__init__.py +0 -0
- abstract_security_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_security_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_security_test/src/main.py +35 -0
- abstract_threading_test/__init__.py +0 -0
- abstract_threading_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_threading_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_threading_test/setup.py +37 -0
- abstract_threading_test/src/__init__.py +0 -0
- abstract_threading_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_threading_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_threading_test/src/main.py +35 -0
- abstract_utilities_test/__init__.py +0 -0
- abstract_utilities_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_utilities_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_utilities_test/setup.py +37 -0
- abstract_utilities_test/src/__init__.py +0 -0
- abstract_utilities_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_utilities_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_utilities_test/src/main.py +35 -0
- abstract_web_aggregation_test/__init__.py +0 -0
- abstract_web_aggregation_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_web_aggregation_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_web_aggregation_test/setup.py +37 -0
- abstract_web_aggregation_test/src/__init__.py +0 -0
- abstract_web_aggregation_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_web_aggregation_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_web_aggregation_test/src/main.py +35 -0
- abstract_workstation_test/__init__.py +0 -0
- abstract_workstation_test/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_workstation_test/__pycache__/setup.cpython-311.pyc +0 -0
- abstract_workstation_test/setup.py +37 -0
- abstract_workstation_test/src/__init__.py +0 -0
- abstract_workstation_test/src/__pycache__/__init__.cpython-311.pyc +0 -0
- abstract_workstation_test/src/__pycache__/main.cpython-311.pyc +0 -0
- abstract_workstation_test/src/main.py +35 -0
EGG-INFO/PKG-INFO
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: abstract-package-test
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: abstract_package_test is a Python package.
|
|
5
|
+
Home-page: https://github.com/AbstractEndeavors/abstract_package_test/abstract_package_test
|
|
6
|
+
Author: putkoff
|
|
7
|
+
Author-email: partners@abstractendeavors.com
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.6
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
|
|
18
|
+
# This is the README for project abstract_package_test
|
EGG-INFO/SOURCES.txt
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
src/abstract_ai_test/__init__.py
|
|
6
|
+
src/abstract_ai_test/setup.py
|
|
7
|
+
src/abstract_ai_test/src/__init__.py
|
|
8
|
+
src/abstract_ai_test/src/api_calls.py
|
|
9
|
+
src/abstract_ai_test/src/data_handler.py
|
|
10
|
+
src/abstract_ai_test/src/endpoints.py
|
|
11
|
+
src/abstract_ai_test/src/main.py
|
|
12
|
+
src/abstract_ai_test/src/message_aggregator.py
|
|
13
|
+
src/abstract_ai_test/src/prompts.py
|
|
14
|
+
src/abstract_ai_test/src/response_handling.py
|
|
15
|
+
src/abstract_ai_test/src/tokenization.py
|
|
16
|
+
src/abstract_api_test/__init__.py
|
|
17
|
+
src/abstract_api_test/setup.py
|
|
18
|
+
src/abstract_api_test/src/__init__.py
|
|
19
|
+
src/abstract_api_test/src/main.py
|
|
20
|
+
src/abstract_audio_test/__init__.py
|
|
21
|
+
src/abstract_audio_test/setup.py
|
|
22
|
+
src/abstract_audio_test/src/__init__.py
|
|
23
|
+
src/abstract_audio_test/src/main.py
|
|
24
|
+
src/abstract_authority_replica_test/__init__.py
|
|
25
|
+
src/abstract_authority_replica_test/setup.py
|
|
26
|
+
src/abstract_authority_replica_test/src/__init__.py
|
|
27
|
+
src/abstract_authority_replica_test/src/main.py
|
|
28
|
+
src/abstract_authority_test/__init__.py
|
|
29
|
+
src/abstract_authority_test/setup.py
|
|
30
|
+
src/abstract_authority_test/src/__init__.py
|
|
31
|
+
src/abstract_authority_test/src/main.py
|
|
32
|
+
src/abstract_crypto_test/__init__.py
|
|
33
|
+
src/abstract_crypto_test/setup.py
|
|
34
|
+
src/abstract_crypto_test/src/__init__.py
|
|
35
|
+
src/abstract_crypto_test/src/main.py
|
|
36
|
+
src/abstract_gui_test/__init__.py
|
|
37
|
+
src/abstract_gui_test/setup.py
|
|
38
|
+
src/abstract_gui_test/src/__init__.py
|
|
39
|
+
src/abstract_gui_test/src/main.py
|
|
40
|
+
src/abstract_images_test/__init__.py
|
|
41
|
+
src/abstract_images_test/setup.py
|
|
42
|
+
src/abstract_images_test/src/__init__.py
|
|
43
|
+
src/abstract_images_test/src/main.py
|
|
44
|
+
src/abstract_modules_test/__init__.py
|
|
45
|
+
src/abstract_modules_test/setup.py
|
|
46
|
+
src/abstract_modules_test/src/__init__.py
|
|
47
|
+
src/abstract_modules_test/src/main.py
|
|
48
|
+
src/abstract_package_test.egg-info/PKG-INFO
|
|
49
|
+
src/abstract_package_test.egg-info/SOURCES.txt
|
|
50
|
+
src/abstract_package_test.egg-info/dependency_links.txt
|
|
51
|
+
src/abstract_package_test.egg-info/entry_points.txt
|
|
52
|
+
src/abstract_package_test.egg-info/top_level.txt
|
|
53
|
+
src/abstract_paths_test/__init__.py
|
|
54
|
+
src/abstract_paths_test/setup.py
|
|
55
|
+
src/abstract_paths_test/src/__init__.py
|
|
56
|
+
src/abstract_paths_test/src/main.py
|
|
57
|
+
src/abstract_security_test/__init__.py
|
|
58
|
+
src/abstract_security_test/setup.py
|
|
59
|
+
src/abstract_security_test/src/__init__.py
|
|
60
|
+
src/abstract_security_test/src/main.py
|
|
61
|
+
src/abstract_threading_test/__init__.py
|
|
62
|
+
src/abstract_threading_test/setup.py
|
|
63
|
+
src/abstract_threading_test/src/__init__.py
|
|
64
|
+
src/abstract_threading_test/src/main.py
|
|
65
|
+
src/abstract_utilities_test/__init__.py
|
|
66
|
+
src/abstract_utilities_test/setup.py
|
|
67
|
+
src/abstract_utilities_test/src/__init__.py
|
|
68
|
+
src/abstract_utilities_test/src/main.py
|
|
69
|
+
src/abstract_web_aggregation_test/__init__.py
|
|
70
|
+
src/abstract_web_aggregation_test/setup.py
|
|
71
|
+
src/abstract_web_aggregation_test/src/__init__.py
|
|
72
|
+
src/abstract_web_aggregation_test/src/main.py
|
|
73
|
+
src/abstract_workstation_test/__init__.py
|
|
74
|
+
src/abstract_workstation_test/setup.py
|
|
75
|
+
src/abstract_workstation_test/src/__init__.py
|
|
76
|
+
src/abstract_workstation_test/src/main.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
abstract_ai_test = abstract_ai_test.main:main
|
|
3
|
+
abstract_api_test = abstract_api_test.main:main
|
|
4
|
+
abstract_audio_test = abstract_audio_test.main:main
|
|
5
|
+
abstract_authority_replica_test = abstract_authority_replica_test.main:main
|
|
6
|
+
abstract_authority_test = abstract_authority_test.main:main
|
|
7
|
+
abstract_crypto_test = abstract_crypto_test.main:main
|
|
8
|
+
abstract_gui_test = abstract_gui_test.main:main
|
|
9
|
+
abstract_images_test = abstract_images_test.main:main
|
|
10
|
+
abstract_modules_test = abstract_modules_test.main:main
|
|
11
|
+
abstract_paths_test = abstract_paths_test.main:main
|
|
12
|
+
abstract_security_test = abstract_security_test.main:main
|
|
13
|
+
abstract_threading_test = abstract_threading_test.main:main
|
|
14
|
+
abstract_utilities_test = abstract_utilities_test.main:main
|
|
15
|
+
abstract_web_aggregation_test = abstract_web_aggregation_test.main:main
|
|
16
|
+
abstract_workstation_test = abstract_workstation_test.main:main
|
EGG-INFO/not-zip-safe
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
EGG-INFO/top_level.txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
abstract_ai_test
|
|
2
|
+
abstract_api_test
|
|
3
|
+
abstract_audio_test
|
|
4
|
+
abstract_authority_replica_test
|
|
5
|
+
abstract_authority_test
|
|
6
|
+
abstract_crypto_test
|
|
7
|
+
abstract_gui_test
|
|
8
|
+
abstract_images_test
|
|
9
|
+
abstract_modules_test
|
|
10
|
+
abstract_paths_test
|
|
11
|
+
abstract_security_test
|
|
12
|
+
abstract_threading_test
|
|
13
|
+
abstract_utilities_test
|
|
14
|
+
abstract_web_aggregation_test
|
|
15
|
+
abstract_workstation_test
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This is the setup.py for module abstract_ai_test
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
from time import time
|
|
4
|
+
import setuptools
|
|
5
|
+
|
|
6
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
7
|
+
long_description = fh.read()
|
|
8
|
+
|
|
9
|
+
setuptools.setup(
|
|
10
|
+
name='abstract_ai_test',
|
|
11
|
+
version='0.0.2',
|
|
12
|
+
author='putkoff',
|
|
13
|
+
author_email='partners@abstractendeavors.com',
|
|
14
|
+
description='abstract_ai_test is a Python package.',
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type='text/markdown',
|
|
17
|
+
url='https://github.com/AbstractEndeavors/abstract_package_test/abstract_ai_test',
|
|
18
|
+
packages=find_packages(where="src"),
|
|
19
|
+
classifiers=[
|
|
20
|
+
'Development Status :: 3 - Alpha',
|
|
21
|
+
'Intended Audience :: Developers',
|
|
22
|
+
'License :: OSI Approved :: MIT License',
|
|
23
|
+
'Programming Language :: Python :: 3',
|
|
24
|
+
'Programming Language :: Python :: 3.11',
|
|
25
|
+
"Operating System :: OS Independent",
|
|
26
|
+
],
|
|
27
|
+
package_dir={"": "src"},
|
|
28
|
+
python_requires=">=3.6",
|
|
29
|
+
install_requires=[
|
|
30
|
+
# Add your project's requirements here, e.g.,
|
|
31
|
+
# 'numpy>=1.22.0',
|
|
32
|
+
# 'pandas>=1.3.0',
|
|
33
|
+
],
|
|
34
|
+
entry_points={
|
|
35
|
+
'console_scripts': ["abstract_ai_test=abstract_ai_test.main:main"]
|
|
36
|
+
},
|
|
37
|
+
)
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import requests
|
|
4
|
+
import openai
|
|
5
|
+
from abstract_security.envy_it import get_openai_key, getAPIkey
|
|
6
|
+
from abstract_utilitites.time_utils import time_stamp,get_time_stamp,date
|
|
7
|
+
from .tokenize import count_tokens, check_token_size
|
|
8
|
+
from .prompt import default_prompt,create_prompt,default_tokens
|
|
9
|
+
def headers():
|
|
10
|
+
"""
|
|
11
|
+
Returns the headers for the API request.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
dict: The headers containing the 'Content-Type' and 'Authorization' information.
|
|
15
|
+
"""
|
|
16
|
+
return {'Content-Type': 'application/json', 'Authorization': f'Bearer {getAPIkey()}'}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def hard_request(max_tokens, prompt):
|
|
20
|
+
"""
|
|
21
|
+
Sends a hard request to the OpenAI API using the provided parameters.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
max_tokens (int): The maximum number of tokens for the completion.
|
|
25
|
+
prompt (str): The prompt for the API request.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
dict: The response received from the OpenAI API.
|
|
29
|
+
"""
|
|
30
|
+
response = openai.Completion.create(
|
|
31
|
+
engine="text-davinci-002",
|
|
32
|
+
prompt=prompt,
|
|
33
|
+
max_tokens=max_tokens,
|
|
34
|
+
temperature=0.5,
|
|
35
|
+
top_p=1,
|
|
36
|
+
frequency_penalty=0,
|
|
37
|
+
presence_penalty=0
|
|
38
|
+
)
|
|
39
|
+
return response
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def quick_request(prompt: str = default_prompt(), max_tokens: int = default_tokens()):
|
|
43
|
+
"""
|
|
44
|
+
Sends a quick request to the OpenAI API using the provided parameters and prints the result.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
prompt (str, optional): The prompt for the API request. Defaults to the default_prompt().
|
|
48
|
+
max_tokens (int, optional): The maximum number of tokens for the completion. Defaults to default_tokens().
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
None
|
|
52
|
+
"""
|
|
53
|
+
print(json.dumps(hard_request(max_tokens, prompt).choices[0].text.strip(), indent=4))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def raw_data(prompt: str = default_prompt(), js: dict = {}, endpoint: str = get_default_endpoint()):
|
|
57
|
+
"""
|
|
58
|
+
Sends a raw data request to the specified endpoint with the provided parameters.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
prompt (str, optional): The prompt for the API request. Defaults to default_prompt().
|
|
62
|
+
js (dict, optional): The JSON dictionary containing the request data. Defaults to an empty dictionary.
|
|
63
|
+
endpoint (str, optional): The endpoint for the API request. Defaults to get_default_endpoint().
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
dict: The response received from the API request.
|
|
67
|
+
"""
|
|
68
|
+
if 'prompt' not in js:
|
|
69
|
+
js['prompt'] = prompt
|
|
70
|
+
message_tokens = sum([len(js['prompt']) for message in js['prompt']])
|
|
71
|
+
js['max_tokens'] = get_default_tokens() - 10 - (int(message_tokens) - int(check_token_size(create_prompt(js), int(message_tokens))))
|
|
72
|
+
return save_response(js, requests.post(endpoint, json=create_prompt(js), headers=headers()))
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from endpoints import *
|
|
2
|
+
from prompts import *
|
|
3
|
+
def send_chunks(prompt: str = default_prompt(), content: str = '', model: str = default_model(),
|
|
4
|
+
endpoint: str = default_endpoint(), max_tokens: int = default_tokens(), title: str = 'current'):
|
|
5
|
+
"""
|
|
6
|
+
Sends the content in chunks to the specified endpoint using the specified model and returns the responses.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
prompt (str, optional): The prompt for the API request. Defaults to default_prompt().
|
|
10
|
+
content (str): The content to be sent in chunks.
|
|
11
|
+
model (str, optional): The model to use for the API request. Defaults to default_model().
|
|
12
|
+
endpoint (str, optional): The endpoint for the API request. Defaults to default_endpoint().
|
|
13
|
+
max_tokens (int, optional): The maximum number of tokens for each chunk. Defaults to default_tokens().
|
|
14
|
+
title (str, optional): The title of the data set. Defaults to 'current'.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
list: A list of dictionaries containing the responses for each chunk. Each dictionary has 'notation'
|
|
18
|
+
and 'target_response' keys.
|
|
19
|
+
"""
|
|
20
|
+
content_chunks = re.findall('.{1,%s}' % (max_tokens // 2), content)
|
|
21
|
+
responses = []
|
|
22
|
+
for k, chunk in enumerate(content_chunks):
|
|
23
|
+
chunk_prompt = f"{prompt}, this is part {k + 1} of {len(content_chunks)} for the data set {title}.:\n{chunk}"
|
|
24
|
+
response = requests.post(endpoint, json=create_prompt({}, model=model, prompt=chunk_prompt,
|
|
25
|
+
max_tokens=max_tokens, endpoint=endpoint),
|
|
26
|
+
headers=headers())
|
|
27
|
+
generated_text = response['choices'][0]['text'].strip()
|
|
28
|
+
try:
|
|
29
|
+
response_json = json.loads(generated_text)
|
|
30
|
+
notation = response_json["notation"]
|
|
31
|
+
target_response = response_json["target_response"]
|
|
32
|
+
responses.append({"notation": notation, "target_response": target_response})
|
|
33
|
+
except json.JSONDecodeError:
|
|
34
|
+
print("Error parsing response as JSON")
|
|
35
|
+
return responses
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def create_chunks(content, max_chunk_size):
|
|
39
|
+
"""
|
|
40
|
+
Creates chunks of content based on the specified maximum chunk size.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
content (str): The content to be split into chunks.
|
|
44
|
+
max_chunk_size (int): The maximum size of each chunk.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
list: A list of chunks where each chunk has a size less than or equal to the maximum chunk size.
|
|
48
|
+
"""
|
|
49
|
+
words = content.split()
|
|
50
|
+
chunks = []
|
|
51
|
+
current_chunk = []
|
|
52
|
+
|
|
53
|
+
for word in words:
|
|
54
|
+
if len(' '.join(current_chunk)) + len(word) > max_chunk_size:
|
|
55
|
+
chunks.append(' '.join(current_chunk))
|
|
56
|
+
current_chunk = []
|
|
57
|
+
current_chunk.append(word)
|
|
58
|
+
|
|
59
|
+
chunks.append(' '.join(current_chunk))
|
|
60
|
+
|
|
61
|
+
return chunks
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def chunk_size(user_input=None):
|
|
65
|
+
"""
|
|
66
|
+
Determines the appropriate chunk size for the user input content.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
user_input (str): The user input content.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
int: The calculated maximum chunk size for the content.
|
|
73
|
+
"""
|
|
74
|
+
initial_max_chunk_size = len(user_input)
|
|
75
|
+
content_chunks = create_chunks(user_input, initial_max_chunk_size)
|
|
76
|
+
max_chunk_size = calculate_max_chunk_size(user_input, len(content_chunks), selected_model)
|
|
77
|
+
if max_chunk_size != initial_max_chunk_size:
|
|
78
|
+
content_chunks = create_chunks(content, max_chunk_size)
|
|
79
|
+
|
|
80
|
+
return max_chunk_size
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
from abstract_utilities.json_utils import invert_json
|
|
2
|
+
from abstract_utilities.global_utils import change_glob, get_globes, if_none_default
|
|
3
|
+
def get_token_js():
|
|
4
|
+
"""
|
|
5
|
+
Returns the JSON dictionary containing token information and endpoints.
|
|
6
|
+
|
|
7
|
+
Returns:
|
|
8
|
+
dict: The JSON dictionary containing token information and endpoints.
|
|
9
|
+
"""
|
|
10
|
+
return {
|
|
11
|
+
"token_info": {
|
|
12
|
+
"8192": ['gpt-4', 'gpt-4-0314'],
|
|
13
|
+
"32768": ['gpt-4-32k', 'gpt-4-32k-0314'],
|
|
14
|
+
"4097": ['gpt-3.5-turbo', 'gpt-3.5-turbo-0301', 'text-davinci-003', 'text-davinci-002'],
|
|
15
|
+
"8001": ["code-davinci-002", "code-davinci-001"],
|
|
16
|
+
"2048": ['code-cushman-002', 'code-cushman-001'],
|
|
17
|
+
"2049": ['davinci', 'curie', 'babbage', 'ada', 'text-curie-001', 'text-babbage-001', 'text-ada-001']
|
|
18
|
+
},
|
|
19
|
+
"endpoints": {
|
|
20
|
+
'https://api.openai.com/v1/chat/completions': [
|
|
21
|
+
"gpt-4", "gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314", "gpt-3.5-turbo", "gpt-3.5-turbo-0301"],
|
|
22
|
+
'https://api.openai.com/v1/completions': [
|
|
23
|
+
"text-davinci-003", "text-davinci-002", "text-curie-001", "text-babbage-001", "text-ada-001"],
|
|
24
|
+
'https://api.openai.com/v1/edits': [
|
|
25
|
+
"text-davinci-edit-001", "code-davinci-edit-001"],
|
|
26
|
+
'https://api.openai.com/v1/audio/transcriptions': ['whisper-1'],
|
|
27
|
+
'https://api.openai.com/v1/audio/translations': ['whisper-1'],
|
|
28
|
+
'https://api.openai.com/v1/fine-tunes': [
|
|
29
|
+
"davinci", "curie", "babbage", "ada"],
|
|
30
|
+
'https://api.openai.com/v1/embeddings': [
|
|
31
|
+
"text-embedding-ada-002", "text-search-ada-doc-001"],
|
|
32
|
+
'https://api.openai.com/v1/moderations': [
|
|
33
|
+
"text-moderation-stable", "text-moderation-latest"]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_model_info():
|
|
39
|
+
"""
|
|
40
|
+
Retrieves the inverted JSON dictionary of model information.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
dict: The inverted JSON dictionary where the keys are model names and the values are token numbers.
|
|
44
|
+
"""
|
|
45
|
+
return invert_json(get_token_js()["endpoints"])
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def get_endpoint_info():
|
|
49
|
+
"""
|
|
50
|
+
Retrieves the JSON dictionary containing endpoint information.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
dict: The JSON dictionary where the keys are endpoints and the values are lists of models.
|
|
54
|
+
"""
|
|
55
|
+
return get_token_js()["endpoints"]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def get_token_info():
|
|
59
|
+
"""
|
|
60
|
+
Retrieves the inverted JSON dictionary of token information.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
dict: The inverted JSON dictionary where the keys are token numbers and the values are lists of models.
|
|
64
|
+
"""
|
|
65
|
+
return invert_json(get_token_js()["token_info"])
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def default_endpoint():
|
|
69
|
+
"""
|
|
70
|
+
Returns the default endpoint based on the 'endpoint_selection' setting.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
str: The default endpoint.
|
|
74
|
+
"""
|
|
75
|
+
return if_none_default(st='endpoint_selection', default=list(get_endpoint_info().keys())[0])
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def default_model():
|
|
79
|
+
"""
|
|
80
|
+
Returns the default model based on the 'model_selection' setting.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
str: The default model.
|
|
84
|
+
"""
|
|
85
|
+
return if_none_default(st='model_selection', default=list(get_endpoint_info()[default_endpoint()])[0])
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def default_tokens():
|
|
89
|
+
"""
|
|
90
|
+
Returns the default number of tokens based on the 'token_selection' setting.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
int: The default number of tokens.
|
|
94
|
+
"""
|
|
95
|
+
return if_none_default(st='token_selection', default=get_token_info()[default_model()])
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def get_defaults(endpoint=default_endpoint(), model=default_model(), tokens=default_tokens()):
|
|
99
|
+
"""
|
|
100
|
+
Returns a dictionary containing the default values for endpoint, model, and tokens.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
endpoint (str, optional): The default endpoint. Defaults to default_endpoint().
|
|
104
|
+
model (str, optional): The default model. Defaults to default_model().
|
|
105
|
+
tokens (int, optional): The default number of tokens. Defaults to default_tokens().
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
dict: A dictionary containing the default values for endpoint, model, and tokens.
|
|
109
|
+
"""
|
|
110
|
+
return {"endpoint": endpoint, "model": model, "tokens": tokens}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import importlib.util
|
|
3
|
+
|
|
4
|
+
excluded_files = ['__pycache__', 'main.py', '__init__.py']
|
|
5
|
+
excluded_directories = ['__pycache__']
|
|
6
|
+
|
|
7
|
+
def import_module_from_file(file_path):
|
|
8
|
+
module_name = os.path.splitext(os.path.basename(file_path))[0]
|
|
9
|
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
|
10
|
+
module = importlib.util.module_from_spec(spec)
|
|
11
|
+
spec.loader.exec_module(module)
|
|
12
|
+
return module
|
|
13
|
+
|
|
14
|
+
def get_filtered_files(directory):
|
|
15
|
+
modules = []
|
|
16
|
+
for item in os.listdir(directory):
|
|
17
|
+
item_path = os.path.join(directory, item)
|
|
18
|
+
if os.path.isfile(item_path) and item not in excluded_files:
|
|
19
|
+
if item_path.endswith('.py'):
|
|
20
|
+
modules.append(import_module_from_file(item_path))
|
|
21
|
+
elif os.path.isdir(item_path) and item not in excluded_directories:
|
|
22
|
+
modules.extend(get_filtered_files(item_path))
|
|
23
|
+
return modules
|
|
24
|
+
|
|
25
|
+
def main():
|
|
26
|
+
print("Hello, this is abstract_ai_test.")
|
|
27
|
+
# You can import and use other modules or functions of abstract_ai_test here.
|
|
28
|
+
script_path = os.path.abspath(__file__)
|
|
29
|
+
directory_path = os.path.dirname(script_path)
|
|
30
|
+
|
|
31
|
+
filtered_modules = get_filtered_files(directory_path)
|
|
32
|
+
|
|
33
|
+
if __name__ == "__main__":
|
|
34
|
+
# Get the absolute directory path of the current script file
|
|
35
|
+
main()
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
import PySimpleGUI
|
|
5
|
+
from functions import *
|
|
6
|
+
from simple_gui_templates import *
|
|
7
|
+
import PySimpleGUI as sg
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_timestamp(date_str, military_time_str):
|
|
11
|
+
"""
|
|
12
|
+
Converts a date string and military time string to a timestamp.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
date_str (str): The date string in the format 'YYYY-MM-DD'.
|
|
16
|
+
military_time_str (str): The military time string in the format 'HH:MM'.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
int: The timestamp corresponding to the date and time.
|
|
20
|
+
"""
|
|
21
|
+
date_time_str = f"{date_str} {military_time_str}"
|
|
22
|
+
date_time_obj = datetime.strptime(date_time_str, '%Y-%m-%d %H:%M')
|
|
23
|
+
timestamp = int(date_time_obj.timestamp())
|
|
24
|
+
return timestamp
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def file_creation_time(file_path):
|
|
28
|
+
"""
|
|
29
|
+
Retrieves the creation timestamp of a file.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
file_path (str): The path to the file.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
float: The creation timestamp of the file.
|
|
36
|
+
"""
|
|
37
|
+
creation_timestamp = os.path.getctime(file_path)
|
|
38
|
+
return creation_timestamp
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def find_keys(data, target_keys):
|
|
42
|
+
"""
|
|
43
|
+
Finds the values associated with the specified target keys in a nested dictionary or list.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
data (dict or list): The nested dictionary or list to search within.
|
|
47
|
+
target_keys (list): The list of keys to search for.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
list: A list of values associated with the target keys.
|
|
51
|
+
"""
|
|
52
|
+
values = []
|
|
53
|
+
if isinstance(data, dict):
|
|
54
|
+
for key, value in data.items():
|
|
55
|
+
if key in target_keys:
|
|
56
|
+
values.append(value)
|
|
57
|
+
values.extend(find_keys(value, target_keys))
|
|
58
|
+
elif isinstance(data, list):
|
|
59
|
+
for item in data:
|
|
60
|
+
values.extend(find_keys(item, target_keys))
|
|
61
|
+
return values
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def print_it(st):
|
|
65
|
+
"""
|
|
66
|
+
Prints the input string and returns it.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
st (str): The string to be printed.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
str: The input string.
|
|
73
|
+
"""
|
|
74
|
+
print(st)
|
|
75
|
+
return st
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def aggregate_conversations(directory):
|
|
79
|
+
"""
|
|
80
|
+
Aggregates conversations from JSON files in the specified directory.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
directory (str): The directory containing the JSON files.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
list: A list of aggregated conversations.
|
|
87
|
+
"""
|
|
88
|
+
json_files, lsAll = [], []
|
|
89
|
+
for root, _, files in os.walk(directory):
|
|
90
|
+
for file in files:
|
|
91
|
+
if file.endswith(".json"):
|
|
92
|
+
file = os.path.join(root, file)
|
|
93
|
+
json_files.append((file_creation_time(file), file))
|
|
94
|
+
sorted_json_files = sorted(json_files, key=lambda x: x[0])
|
|
95
|
+
aggregated_conversations = []
|
|
96
|
+
chat_log_file = open("chat_log.txt", "w")
|
|
97
|
+
model = 'gpt'
|
|
98
|
+
for file in sorted_json_files:
|
|
99
|
+
with open(file[1], "r") as f:
|
|
100
|
+
data = json.load(f)
|
|
101
|
+
relevant_values = find_keys(data, ['messages', 'prompt', 'content'])
|
|
102
|
+
for i, value in enumerate(relevant_values):
|
|
103
|
+
while type(value) is list:
|
|
104
|
+
value = value[0]
|
|
105
|
+
if type(value) is dict:
|
|
106
|
+
if 'model' in value:
|
|
107
|
+
model = value['model']
|
|
108
|
+
if 'prompt' in value:
|
|
109
|
+
lsAll.append({print_it("user"): print_it(value["prompt"])})
|
|
110
|
+
if 'content' in value:
|
|
111
|
+
lsAll.append({print_it(model): print_it(value['content'])})
|
|
112
|
+
print(lsAll)
|
|
113
|
+
chat_log_file.close()
|
|
114
|
+
return aggregated_conversations
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def browser():
|
|
118
|
+
"""
|
|
119
|
+
Displays a directory browser window and returns the selected directory.
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
str: The selected directory.
|
|
123
|
+
"""
|
|
124
|
+
window = sg.Window('directory_browser', [
|
|
125
|
+
[sg.Input('', key="selection"), sg.FolderBrowse("Select File", key="-FOLDER_SELECT-", initial_folder="/home/bigrugz/Documents", target="-FOLDER_SELECT-", enable_events=True),
|
|
126
|
+
sg.Button("select", key="-GRAB_FILE-", enable_events=True), sg.Button("EXIT", key="-EXIT-")]], resizable=True, finalize=True)
|
|
127
|
+
while True:
|
|
128
|
+
event, values = window.read()
|
|
129
|
+
if event == '-GRAB_FILE-':
|
|
130
|
+
window.close()
|
|
131
|
+
break
|
|
132
|
+
return values["selection"]
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def get_responses():
|
|
136
|
+
"""
|
|
137
|
+
Retrieves the aggregated conversations from JSON files.
|
|
138
|
+
|
|
139
|
+
If the 'response_data' directory does not exist in the current working directory, prompts the user to select a directory
|
|
140
|
+
containing the JSON files. Otherwise, uses the 'response_data' directory.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
None
|
|
144
|
+
"""
|
|
145
|
+
if "response_data" not in os.listdir(os.getcwd()):
|
|
146
|
+
aggregate_conversations(browser())
|
|
147
|
+
else:
|
|
148
|
+
aggregate_conversations("response_data")
|