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
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
from endpoints import default_model, default_tokens
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def call_functions_hard(instance, function_name, varis):
|
|
5
|
+
"""
|
|
6
|
+
Calls the specified function name with the provided arguments on the given instance.
|
|
7
|
+
|
|
8
|
+
If the instance is not None, the function is called using `getattr(instance, function_name)(*varis)`.
|
|
9
|
+
If the instance is None, the function is called using `globals()[function_name](*varis)`.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
instance (object or None): The instance on which the function is called.
|
|
13
|
+
function_name (str): The name of the function to call.
|
|
14
|
+
varis (tuple): The arguments to pass to the function.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
The result of the function call.
|
|
18
|
+
"""
|
|
19
|
+
if instance is not None:
|
|
20
|
+
return getattr(instance, function_name)(*varis)
|
|
21
|
+
else:
|
|
22
|
+
return globals()[function_name](*varis)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def default_prompt():
|
|
26
|
+
"""
|
|
27
|
+
Returns the default prompt string.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
str: The default prompt.
|
|
31
|
+
"""
|
|
32
|
+
return "I haven't sent anything. How's your day though?"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def create_prompt(js: dict = None, model: str = default_model(), prompt: str = default_prompt(),
|
|
36
|
+
max_tokens: int = default_tokens()) -> dict:
|
|
37
|
+
"""
|
|
38
|
+
Creates a prompt dictionary with the specified values.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
js (dict, optional): The input JSON dictionary. Defaults to None.
|
|
42
|
+
model (str, optional): The model name. Defaults to default_model().
|
|
43
|
+
prompt (str, optional): The prompt string. Defaults to default_prompt().
|
|
44
|
+
max_tokens (int, optional): The maximum number of tokens. Defaults to default_tokens().
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
dict: The prompt dictionary.
|
|
48
|
+
"""
|
|
49
|
+
if js is None or not isinstance(js, dict):
|
|
50
|
+
js = {"model": model, "prompt": prompt, "max_tokens": max_tokens}
|
|
51
|
+
else:
|
|
52
|
+
js.setdefault("model", model)
|
|
53
|
+
js.setdefault("prompt", prompt)
|
|
54
|
+
js.setdefault("max_tokens", max_tokens)
|
|
55
|
+
prompt_data = {"model": js['model'], "messages": [{"role": "user", "content": f'{js["prompt"]}'}],
|
|
56
|
+
"max_tokens": js['max_tokens']}
|
|
57
|
+
prompt_data["max_tokens"] = check_token_size(prompt_data, prompt_data['max_tokens'])
|
|
58
|
+
return prompt_data
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def get_json_response():
|
|
62
|
+
"""
|
|
63
|
+
Returns the description for the 'response' key in JSON format.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
str: The description for the 'response' key.
|
|
67
|
+
"""
|
|
68
|
+
return "the following will need to be in JSON format, your response will be described in the following descriptions:\n"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def assign_keys(st):
|
|
72
|
+
"""
|
|
73
|
+
Returns the description for assigning a value to the specified key.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
st (str): The name of the key.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
str: The description for assigning a value to the key.
|
|
80
|
+
"""
|
|
81
|
+
return f"as a value for the '{st}' key: "
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def get_key_desc(st, text):
|
|
85
|
+
"""
|
|
86
|
+
Returns the description for the specified key with the provided text.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
st (str): The name of the key.
|
|
90
|
+
text (str): The description text.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
str: The complete description for the key.
|
|
94
|
+
"""
|
|
95
|
+
return f"{assign_keys(st)}{text}\n"
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def get_notation():
|
|
99
|
+
"""
|
|
100
|
+
Returns the description for the 'notation' key.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
str: The description for the 'notation' key.
|
|
104
|
+
"""
|
|
105
|
+
return get_key_desc("notation", "place here any notes for you to maintain context of this prompt going into the next")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def get_title():
|
|
109
|
+
"""
|
|
110
|
+
Returns the description for the 'title' key.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
str: The description for the 'title' key.
|
|
114
|
+
"""
|
|
115
|
+
return get_key_desc("title", "place here any notes for you to maintain context of this prompt going into the next")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def get_instruction():
|
|
119
|
+
"""
|
|
120
|
+
Returns the description for the 'instruction' key.
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
str: The description for the 'instruction' key.
|
|
124
|
+
"""
|
|
125
|
+
return get_key_desc("instruction", "should containing a textual description")
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def get_inputs():
|
|
129
|
+
"""
|
|
130
|
+
Returns the description for the 'inputs' key.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
str: The description for the 'inputs' key.
|
|
134
|
+
"""
|
|
135
|
+
return get_key_desc("inputs", """key containing a list of command line inputs, with each input represented as an object with "type" and "input" keys. For example:\n'{str(return_instruction())}'\n'""")
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def get_text():
|
|
139
|
+
"""
|
|
140
|
+
Returns the description for the 'text' key.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
str: The description for the 'text' key.
|
|
144
|
+
"""
|
|
145
|
+
return get_key_desc("text", "please respond with text only")
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def get_bash():
|
|
149
|
+
"""
|
|
150
|
+
Returns the description for the 'bash' key.
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
str: The description for the 'bash' key.
|
|
154
|
+
"""
|
|
155
|
+
return get_key_desc("bash", "please respond in the form of a bash script")
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def get_response():
|
|
159
|
+
"""
|
|
160
|
+
Returns the description for the 'response' key.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
str: The description for the 'response' key.
|
|
164
|
+
"""
|
|
165
|
+
return get_key_desc("response", "place your query response here")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def get_context():
|
|
169
|
+
"""
|
|
170
|
+
Returns the description for the 'context' key.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
str: The description for the 'context' key.
|
|
174
|
+
"""
|
|
175
|
+
return get_key_desc("context", "provide any relevant context or dependencies for the task")
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def get_security():
|
|
179
|
+
"""
|
|
180
|
+
Returns the description for the 'security' key.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
str: The description for the 'security' key.
|
|
184
|
+
"""
|
|
185
|
+
return get_key_desc("security", "describe any necessary security measures or precautions for the task")
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def get_formatting():
|
|
189
|
+
"""
|
|
190
|
+
Returns the description for the 'formatting' key.
|
|
191
|
+
|
|
192
|
+
Returns:
|
|
193
|
+
str: The description for the 'formatting' key.
|
|
194
|
+
"""
|
|
195
|
+
return get_key_desc("formatting", "provide instructions on how the output data should be formatted")
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def get_validation():
|
|
199
|
+
"""
|
|
200
|
+
Returns the description for the 'validation' key.
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
str: The description for the 'validation' key.
|
|
204
|
+
"""
|
|
205
|
+
return get_key_desc("validation", "describe the validation process or rules for the input data")
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def get_error_handling():
|
|
209
|
+
"""
|
|
210
|
+
Returns the description for the 'error_handling' key.
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
str: The description for the 'error_handling' key.
|
|
214
|
+
"""
|
|
215
|
+
return get_key_desc("error_handling", "describe how the AI should handle potential errors during this task")
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def get_revision():
|
|
219
|
+
"""
|
|
220
|
+
Returns the description for the 'revision' key.
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
str: The description for the 'revision' key.
|
|
224
|
+
"""
|
|
225
|
+
return get_key_desc("revision", """provide revisions according to line number, for example: [{'lines':[20,25],'revision':'this text goes in place of lines [20:25]'},{...}]""")
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def return_instruction():
|
|
229
|
+
"""
|
|
230
|
+
Returns the instruction dictionary for creating a basic react forum.
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
dict: The instruction dictionary.
|
|
234
|
+
"""
|
|
235
|
+
return {'instruction': ''''Creating a basic react forum requires you to use the create-react-app command line tool. First, install the tool globally to your machine with the command `npm install -g create-react-app`. Then navigate to the folder you want to create the project in, and use the command `create-react-app project-name` to create the project. Next, you'll need to install the required dependencies to build the forum. This can be done with the command `npm install --save react-router react-router-dom` to install the routing library. Finally, you will need to configure the routes and components in the `src/index.js` file.''',
|
|
236
|
+
'inputs': [{'type': 'module', "path": '', 'instruction': 'install react-app global module with npm',
|
|
237
|
+
"commands": [{"description": "install react-app", "command": 'npm install -g create-react-app'}]},
|
|
238
|
+
{'type': 'file', 'path': 'src', 'instruction': 'create the app component for the project', 'name': 'App.js',
|
|
239
|
+
'commands': [{'description': 'make directory', "command": 'mkdir {home_folder}/src/',
|
|
240
|
+
'user_input': {'description': 'Please provide the folder path where you want to create the project',
|
|
241
|
+
'item': 'folder', 'name': 'home_folder'}},
|
|
242
|
+
{'description': 'create the App.js component',
|
|
243
|
+
'command': 'echo -e "import { render, screen } from \'@testing-library/react\';test(\'renders learn react link\', () => {render(<App />);const linkElement = screen.getByText(/learn react/i);expect(linkElement).toBeInTheDocument();});" > App.js'}]},
|
|
244
|
+
{'type': 'module', 'path': 'src', 'instruction': 'install libraries to build the forum',
|
|
245
|
+
'commands': [{"description": "install react-router-dom", "command": 'npm install --save react-router react-router-dom'}]},
|
|
246
|
+
{'type': 'file', 'path': 'src', 'instruction': 'configure the routes and components in the index.js file', 'name': 'index.js',
|
|
247
|
+
'commands': [{'description': 'create the index.js file', 'command': 'echo -e "import React from \'react\';\nimport { render } from \'react-dom\'"'}]}]}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def create_prompt_keys(values):
|
|
251
|
+
"""
|
|
252
|
+
Creates the output text based on the selected keys.
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
values (dict): The selected key-value pairs.
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
str: The output text.
|
|
259
|
+
"""
|
|
260
|
+
cou = 0
|
|
261
|
+
output_text = ''
|
|
262
|
+
val = "get_json_response,get_notation,get_title,get_instruction,get_inputs,get_text,get_bash,get_context,get_context,get_security,get_formatting,get_validation,get_error_handling,get_revision".split(',')
|
|
263
|
+
for key in val:
|
|
264
|
+
|
|
265
|
+
if values[key] == True:
|
|
266
|
+
if cou == 0:
|
|
267
|
+
output_text = get_json_response()
|
|
268
|
+
cou += 1
|
|
269
|
+
output_text += call_functions_hard(None, key, [])
|
|
270
|
+
return output_text
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from .abstract_utilities.time_utils import get_time_stamp, date
|
|
2
|
+
from .abstract_utilities.path_utils import join_paths, mkdirs
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def save_response(js: dict, response: dict, title: str = str(get_time_stamp())):
|
|
8
|
+
"""
|
|
9
|
+
Saves the response JSON and generated text to a file.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
js (dict): The input JSON dictionary.
|
|
13
|
+
response (dict): The response dictionary.
|
|
14
|
+
title (str, optional): The title for the file. Defaults to the current timestamp.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
str: The generated text.
|
|
18
|
+
"""
|
|
19
|
+
generated_text = response.text
|
|
20
|
+
try:
|
|
21
|
+
js['response'] = response.json()
|
|
22
|
+
except:
|
|
23
|
+
print()
|
|
24
|
+
try:
|
|
25
|
+
generated_text = json.loads(js['response']['choices'][0]['message']['content'])
|
|
26
|
+
if 'title' in generated_text:
|
|
27
|
+
title = generated_text['title']
|
|
28
|
+
except:
|
|
29
|
+
print()
|
|
30
|
+
path = mkdirs(join_paths(mkdirs(join_paths(mkdirs('response_data'), date())), js['model']))
|
|
31
|
+
pen(join_paths(path, title + '.json'), json.dumps(js))
|
|
32
|
+
return generated_text
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from nltk.tokenize import word_tokenize
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def check_token_size(prompt_data: dict, max_tokens: int) -> int:
|
|
5
|
+
"""
|
|
6
|
+
Checks the token size of the prompt data and adjusts the maximum tokens.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
prompt_data (dict): The prompt data dictionary.
|
|
10
|
+
max_tokens (int): The maximum number of tokens.
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
int: The adjusted maximum tokens.
|
|
14
|
+
|
|
15
|
+
Raises:
|
|
16
|
+
Exception: If the adjusted maximum tokens are less than 1.
|
|
17
|
+
"""
|
|
18
|
+
message_tokens = sum([count_tokens(message["content"]) for message in prompt_data["messages"]])
|
|
19
|
+
max_tokens = max_tokens - message_tokens
|
|
20
|
+
if max_tokens < 1:
|
|
21
|
+
raise Exception("Max tokens reduced to less than 1, please adjust your messages or max tokens.")
|
|
22
|
+
return max_tokens
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def count_tokens(text):
|
|
26
|
+
"""
|
|
27
|
+
Counts the number of tokens in the given text.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
text (str): The input text.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
int: The number of tokens.
|
|
34
|
+
"""
|
|
35
|
+
return len(word_tokenize(text))
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This is the setup.py for module abstract_api_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_api_test',
|
|
11
|
+
version='0.0.1',
|
|
12
|
+
author='putkoff',
|
|
13
|
+
author_email='partners@abstractendeavors.com',
|
|
14
|
+
description='abstract_api_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_api_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_api_test=abstract_api_test.main:main"]
|
|
36
|
+
},
|
|
37
|
+
)
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -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_api_test.")
|
|
27
|
+
# You can import and use other modules or functions of abstract_api_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()
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This is the setup.py for module abstract_audio_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_audio_test',
|
|
11
|
+
version='0.0.1',
|
|
12
|
+
author='putkoff',
|
|
13
|
+
author_email='partners@abstractendeavors.com',
|
|
14
|
+
description='abstract_audio_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_audio_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_audio_test=abstract_audio_test.main:main"]
|
|
36
|
+
},
|
|
37
|
+
)
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -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_audio_test.")
|
|
27
|
+
# You can import and use other modules or functions of abstract_audio_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()
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This is the setup.py for module abstract_authority_replica_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_authority_replica_test',
|
|
11
|
+
version='0.0.1',
|
|
12
|
+
author='putkoff',
|
|
13
|
+
author_email='partners@abstractendeavors.com',
|
|
14
|
+
description='abstract_authority_replica_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_authority_replica_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_authority_replica_test=abstract_authority_replica_test.main:main"]
|
|
36
|
+
},
|
|
37
|
+
)
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -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_authority_replica_test.")
|
|
27
|
+
# You can import and use other modules or functions of abstract_authority_replica_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()
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This is the setup.py for module abstract_authority_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_authority_test',
|
|
11
|
+
version='0.0.1',
|
|
12
|
+
author='putkoff',
|
|
13
|
+
author_email='partners@abstractendeavors.com',
|
|
14
|
+
description='abstract_authority_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_authority_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_authority_test=abstract_authority_test.main:main"]
|
|
36
|
+
},
|
|
37
|
+
)
|
|
File without changes
|
|
Binary file
|
|
Binary file
|