vector-vault 5.2.0__tar.gz → 5.2.2__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.
- {vector_vault-5.2.0 → vector_vault-5.2.2}/PKG-INFO +1 -1
- {vector_vault-5.2.0 → vector_vault-5.2.2}/setup.py +1 -1
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vector_vault.egg-info/PKG-INFO +1 -1
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/tools_gpt.py +89 -106
- {vector_vault-5.2.0 → vector_vault-5.2.2}/LICENSE +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/README.md +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/setup.cfg +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vector_vault.egg-info/SOURCES.txt +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vector_vault.egg-info/dependency_links.txt +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vector_vault.egg-info/requires.txt +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vector_vault.egg-info/top_level.txt +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/__init__.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/ai.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/cloud_api.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/cloudmanager.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/creds.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/download.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/groq_api.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/itemize.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/vault.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/vecreq.py +0 -0
- {vector_vault-5.2.0 → vector_vault-5.2.2}/vectorvault/wrap.py +0 -0
|
@@ -3,22 +3,22 @@ import queue
|
|
|
3
3
|
import threading
|
|
4
4
|
|
|
5
5
|
'''
|
|
6
|
-
ToolsGPT is a set of tools special to large language models.
|
|
6
|
+
ToolsGPT is a set of tools special to large language models.
|
|
7
7
|
Every tool turns unstructured data into structured data.
|
|
8
|
-
|
|
9
|
-
Structure data is required to run programs.
|
|
8
|
+
|
|
9
|
+
Structure data is required to run programs.
|
|
10
10
|
Unstructured data is the primary human output.
|
|
11
|
-
AI tools convert unstructured data into structured data,
|
|
12
|
-
bridging the gap between humans and programs.
|
|
11
|
+
AI tools convert unstructured data into structured data,
|
|
12
|
+
bridging the gap between humans and programs.
|
|
13
13
|
Therefore, in the future, everything will be programmable.
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
ToolsGPT allows you to get the following for any input:
|
|
16
16
|
1. `get_rating` - returns a rating out of 10 for any input
|
|
17
17
|
2. `get_yes_no` - returns a 'yes' or a 'no' to any question
|
|
18
18
|
3. `get_number` - returns an integer based on your instructions
|
|
19
19
|
4. `get_match` - returns a match to a list options - (single choice)
|
|
20
20
|
5. `get_multi_match` - returns one or many matches to a list of options - (multiple choice)
|
|
21
|
-
6. `get_topic` - returns the topic subject matter of any input
|
|
21
|
+
6. `get_topic` - returns the topic subject matter of any input
|
|
22
22
|
|
|
23
23
|
1. `get_rating`:
|
|
24
24
|
Get a numeric rating out of 10 for anything
|
|
@@ -28,15 +28,15 @@ import threading
|
|
|
28
28
|
|
|
29
29
|
3. `get_number`:
|
|
30
30
|
Get an integer output for any input
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
4. `get_match`:
|
|
33
|
-
Get an exact match to a single item within a list
|
|
34
|
-
-> in: (text and list of strings)
|
|
33
|
+
Get an exact match to a single item within a list
|
|
34
|
+
-> in: (text and list of strings)
|
|
35
35
|
-> out: (one exact match to an answer in list -> string type)
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
5. `get_multi_match`:
|
|
38
|
-
Get many matches to items within a list
|
|
39
|
-
-> in: (text and list of answers)
|
|
38
|
+
Get many matches to items within a list
|
|
39
|
+
-> in: (text and list of answers)
|
|
40
40
|
-> out: (list of exact matches -> list type)
|
|
41
41
|
|
|
42
42
|
6. `get_topic`:
|
|
@@ -71,7 +71,7 @@ that this number has been carefully considered given your content. My rating out
|
|
|
71
71
|
Concept to rate out of ten for: {concept_to_rate_for} \n\n Reponse: Since I am not allowed to give any explination before or after my rating, I'd like to say
|
|
72
72
|
that this number has been carefully considered given your concept. My rating out of 10 integer is: """
|
|
73
73
|
prompt = prompt_template.format(concept_to_rate_for=concept_to_rate_for)
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
answer = self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
76
76
|
if self.verbose == True:
|
|
77
77
|
print(f"'Rating Initial Answer: {answer}")
|
|
@@ -80,18 +80,18 @@ that this number has been carefully considered given your concept. My rating out
|
|
|
80
80
|
return int(answer) # try to return an int zero shot
|
|
81
81
|
except:
|
|
82
82
|
return self.retry_until_its_a_number(answer, model=model, loop_limit=loop_limit, timeout=timeout) # force the integer if zero shot fails
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
|
|
84
|
+
|
|
85
85
|
def get_number(self, concept, content: str, model=None, loop_limit=5, timeout=None, temperature=None) -> int:
|
|
86
86
|
'''
|
|
87
|
-
param: `concept` - is the idea used to generate a number with - i.e. "How many students are in the professor's class?"
|
|
88
|
-
param: `content` - is the content to generate a number for - i.e. "I had 400 students in my class last year, but this year, I have 10% more."
|
|
87
|
+
param: `concept` - is the idea used to generate a number with - i.e. "How many students are in the professor's class?"
|
|
88
|
+
param: `content` - is the content to generate a number for - i.e. "I had 400 students in my class last year, but this year, I have 10% more."
|
|
89
89
|
'''
|
|
90
90
|
response = self.retry_llm(f'{concept} \n\n{content}', model=model, loop_limit=loop_limit, timeout=timeout)
|
|
91
91
|
print("Initial number extraction response:", response) if self.verbose else 0
|
|
92
92
|
return response if type(response) is int else self.retry_until_its_a_number(response, model=model, loop_limit=loop_limit)
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
|
|
94
|
+
|
|
95
95
|
def retry_until_its_a_number(self, content: str, model=None, loop_limit=5, timeout=None, temperature=None) -> int:
|
|
96
96
|
'''
|
|
97
97
|
param: `content` - the AI will return an integer based on the content you input
|
|
@@ -113,35 +113,35 @@ User: The following content should be a number - Content: "{content}"
|
|
|
113
113
|
print("Initial number extraction response:", response) if self.verbose else 0
|
|
114
114
|
|
|
115
115
|
if type(response) is int:
|
|
116
|
-
return response
|
|
117
|
-
|
|
116
|
+
return response
|
|
117
|
+
|
|
118
118
|
else: # loop until its a number
|
|
119
119
|
loops = 0
|
|
120
120
|
answer = content
|
|
121
121
|
|
|
122
|
-
while True:
|
|
122
|
+
while True:
|
|
123
123
|
if loops >= loop_limit:
|
|
124
124
|
break
|
|
125
125
|
|
|
126
126
|
prompt = prompt_template.format(content=answer)
|
|
127
127
|
answer = self.retry_llm(custom_prompt=prompt, model=model, loop_limit=loop_limit, timeout=timeout, temperature=temperature)
|
|
128
128
|
print(f"Loops: {loops} | Number: {answer}") if self.verbose else 0
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
try:
|
|
131
131
|
answer = int(answer)
|
|
132
132
|
return answer # exit loop and return the integer
|
|
133
133
|
except:
|
|
134
134
|
loops += 1
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
def get_yes_no(self, text: str, question: str = None, model=None, loop_limit=20, timeout=None, temperature=None) -> str:
|
|
138
138
|
'''
|
|
139
|
-
Get an exact "yes" or "no" to any question, given an input.
|
|
139
|
+
Get an exact "yes" or "no" to any question, given an input.
|
|
140
140
|
Be sure to input text to get a yes or no to, then ask the question to answer
|
|
141
141
|
'''
|
|
142
|
-
answer = self.yay_or_nay(text, question, model=model, timeout=timeout) if question else self.yay_or_nay_question_in_content(text, model=model, timeout=timeout, temperature=temperature)
|
|
142
|
+
answer = self.yay_or_nay(text, question, model=model, timeout=timeout) if question else self.yay_or_nay_question_in_content(text, model=model, timeout=timeout, temperature=temperature)
|
|
143
143
|
print(f"Y/N Initial Answer: {answer}") if self.verbose == True else 0
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
loops = 0
|
|
146
146
|
while loops < loop_limit and answer not in ['yes', 'no']:
|
|
147
147
|
answer = self.isolate_yes_no(answer, timeout=timeout)
|
|
@@ -153,7 +153,7 @@ User: The following content should be a number - Content: "{content}"
|
|
|
153
153
|
|
|
154
154
|
def get_match(self, text: str, list_of_options: list, model=None, loop_limit=4, timeout=None, temperature=None) -> str:
|
|
155
155
|
'''
|
|
156
|
-
This function can be used in a variety of Natural Language Processing (NLP) tasks,
|
|
156
|
+
This function can be used in a variety of Natural Language Processing (NLP) tasks,
|
|
157
157
|
such as text classification or intent recognition.
|
|
158
158
|
|
|
159
159
|
Classify any text input to a single option contained in a list of options. - Returns exact match to one of items on list.
|
|
@@ -163,7 +163,7 @@ User: The following content should be a number - Content: "{content}"
|
|
|
163
163
|
list_copy = []
|
|
164
164
|
for option in list_of_options:
|
|
165
165
|
list_copy.append(str(option).strip().replace('.', '').lower().strip('"').strip("'"))
|
|
166
|
-
prompt = f"""Respond with one of the options on this list: {list_copy}
|
|
166
|
+
prompt = f"""Respond with one of the options on this list: {list_copy}
|
|
167
167
|
Content to classify: "{text}" \n\nDo not respond with anything other than the option on the list. Do not add any additional spaces or characters other than the label: {list_copy}"""
|
|
168
168
|
|
|
169
169
|
answer = self.retry_llm(prompt, model, loop_limit, timeout=timeout, temperature=temperature)
|
|
@@ -188,45 +188,28 @@ Content to classify: "{text}" \n\nDo not respond with anything other than the o
|
|
|
188
188
|
return new_answer
|
|
189
189
|
|
|
190
190
|
|
|
191
|
-
def get_multi_match(self, text: str, list_of_options: list, model=None, loop_limit=4, timeout=None, temperature=None) ->
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
such as text classification or intent recognition.
|
|
191
|
+
def get_multi_match(self, text: str, list_of_options: list, model=None, loop_limit=4, timeout=None, temperature=None) -> list:
|
|
192
|
+
prompt = f"""Respond with a list of items from this list: {list_of_options}
|
|
193
|
+
Content to classify: "{text}"
|
|
195
194
|
|
|
196
|
-
|
|
197
|
-
Input text, and list of options: ["list of options", "is a list of strings", "do not forget"]
|
|
198
|
-
'''
|
|
199
|
-
prompt = f"""Respond with a list of items from this list: {list_of_options}
|
|
200
|
-
Content to classify: "{text}" \n\n Respond with a subset list that matches the content: {list_of_options}"""
|
|
195
|
+
Respond with a subset of matches from the list above. Each match should be on a new line, without any additional formatting or punctuation."""
|
|
201
196
|
|
|
202
|
-
# Simulate a call to a function that retries a language model query
|
|
203
197
|
answer = self.retry_llm(prompt, model, loop_limit, timeout=timeout, temperature=temperature)
|
|
198
|
+
print(f'Get Answer: {answer}') if self.verbose else None
|
|
204
199
|
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
answer = answer.replace(',', '\n').replace(';', '\n')
|
|
201
|
+
candidates = [line.strip() for line in answer.split('\n') if line.strip()]
|
|
207
202
|
|
|
208
|
-
|
|
209
|
-
literally = ast.literal_eval(answer) if type(answer) is not list else answer
|
|
210
|
-
except:
|
|
211
|
-
print('answer 1:', answer)
|
|
212
|
-
answer = self.retry_llm(f"""Convert this into a Python list: {answer}""",
|
|
213
|
-
model, loop_limit, timeout=timeout, temperature=temperature)
|
|
214
|
-
print('answer 2:', answer)
|
|
215
|
-
try:
|
|
216
|
-
literally = ast.literal_eval(answer) if type(answer) is not list else answer
|
|
217
|
-
except:
|
|
218
|
-
literally = answer.split(',')
|
|
219
|
-
|
|
220
|
-
print(literally) if self.verbose else None
|
|
221
|
-
|
|
222
|
-
# Process the answer, directly adding matches, and using get_match for others
|
|
203
|
+
# Process the candidates, directly adding matches, and using get_match for others
|
|
223
204
|
processed_results = []
|
|
224
|
-
for
|
|
225
|
-
if
|
|
226
|
-
processed_results.append(
|
|
205
|
+
for candidate in candidates:
|
|
206
|
+
if candidate in list_of_options:
|
|
207
|
+
processed_results.append(candidate)
|
|
227
208
|
else:
|
|
228
|
-
|
|
229
|
-
|
|
209
|
+
match = self.get_match(candidate, list_of_options, model, loop_limit, timeout, temperature)
|
|
210
|
+
if match:
|
|
211
|
+
processed_results.append(match)
|
|
212
|
+
|
|
230
213
|
return processed_results
|
|
231
214
|
|
|
232
215
|
|
|
@@ -238,13 +221,13 @@ Content to classify: "{text}" \n\nDo not respond with anything other than the o
|
|
|
238
221
|
list_copy = []
|
|
239
222
|
for option in list_of_options:
|
|
240
223
|
list_copy.append(option.strip().replace('.', '').lower().strip('"').strip("'"))
|
|
241
|
-
prompt_template = """Respond with one of the options on this list: {list_of_options}
|
|
224
|
+
prompt_template = """Respond with one of the options on this list: {list_of_options}
|
|
242
225
|
Content to classify: "{content}" \n\nClassifiy the content above based on which topic it is mostly related to one topic: {list_of_options}"""
|
|
243
|
-
|
|
226
|
+
|
|
244
227
|
prompt = prompt_template.format(content=text, list_of_options=list_copy)
|
|
245
228
|
topic = self.retry_llm(prompt, model, loop_limit, timeout=timeout, temperature=temperature)
|
|
246
229
|
print(f"Topic Answer: {topic}") if self.verbose else 0
|
|
247
|
-
|
|
230
|
+
|
|
248
231
|
if topic is not None:
|
|
249
232
|
topic = list_of_options[list_copy.index(topic)] # return original topic
|
|
250
233
|
|
|
@@ -252,25 +235,25 @@ Content to classify: "{content}" \n\nClassifiy the content above based on which
|
|
|
252
235
|
|
|
253
236
|
|
|
254
237
|
def match_or_make(self, text, list_of_options: list = [], model=None, loop_limit=20) -> str:
|
|
255
|
-
'''
|
|
256
|
-
"M&M" Returns exact match or new option. Input text and list_of_options.
|
|
238
|
+
'''
|
|
239
|
+
"M&M" Returns exact match or new option. Input text and list_of_options.
|
|
257
240
|
If no list is input, then one will be made and be output
|
|
258
241
|
|
|
259
|
-
Internally, decides whether or not to make a new option.
|
|
242
|
+
Internally, decides whether or not to make a new option.
|
|
260
243
|
Then decides on match is no new option.
|
|
261
244
|
If new option, create it, then finalize it
|
|
262
245
|
'''
|
|
263
246
|
if not list_of_options:
|
|
264
247
|
answer = self.make_option_from_zero(text, list_of_options)
|
|
265
248
|
else:
|
|
266
|
-
yn_prompt = f'''Is this content able to be categorized in one of the provided categories? Categories: {list_of_options}
|
|
267
|
-
Respond "No" if a new category should be made.
|
|
249
|
+
yn_prompt = f'''Is this content able to be categorized in one of the provided categories? Categories: {list_of_options}
|
|
250
|
+
Respond "No" if a new category should be made.
|
|
268
251
|
Respond "Yes" if the right category already exists in the list'''
|
|
269
252
|
binary = self.get_yes_no(text, yn_prompt, model=model)
|
|
270
|
-
|
|
253
|
+
|
|
271
254
|
if binary == 'yes':
|
|
272
255
|
answer = self.get_match(text, list_of_options)
|
|
273
|
-
|
|
256
|
+
|
|
274
257
|
if binary == 'no':
|
|
275
258
|
answer = self.make_option(text, list_of_options)
|
|
276
259
|
|
|
@@ -290,11 +273,11 @@ Respond "Yes" if the right category already exists in the list'''
|
|
|
290
273
|
loops += 1
|
|
291
274
|
if (len(answer.split())) <= 2:
|
|
292
275
|
break
|
|
293
|
-
|
|
276
|
+
|
|
294
277
|
return answer
|
|
295
|
-
|
|
296
278
|
|
|
297
|
-
|
|
279
|
+
|
|
280
|
+
# internal function
|
|
298
281
|
def make_option(self, text, list_of_options: list, model=None, timeout=None, temperature=None) -> str:
|
|
299
282
|
prompt_template = """Content to classify: "{content}" \n\n
|
|
300
283
|
Create a new category for the content based on these other categories in this list: {list_of_options}"""
|
|
@@ -304,35 +287,35 @@ Create a new category for the content based on these other categories in this li
|
|
|
304
287
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
305
288
|
|
|
306
289
|
|
|
307
|
-
# internal function
|
|
290
|
+
# internal function
|
|
308
291
|
def make_option_from_zero(self, text, model=None, timeout=None, temperature=None):
|
|
309
292
|
'''
|
|
310
293
|
Option without anything to go off of but the text input
|
|
311
294
|
'''
|
|
312
|
-
prompt_template = """Given the following content: {content}
|
|
313
|
-
Make a simple and general category to classify content like this. Respond only with the category, and
|
|
295
|
+
prompt_template = """Given the following content: {content}
|
|
296
|
+
Make a simple and general category to classify content like this. Respond only with the category, and
|
|
314
297
|
no explination before or after, just the name of the catagory. \n\nThe name of the category is: """
|
|
315
|
-
|
|
298
|
+
|
|
316
299
|
prompt = prompt_template.format(content=text)
|
|
317
300
|
|
|
318
301
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
319
|
-
|
|
320
302
|
|
|
321
|
-
|
|
303
|
+
|
|
304
|
+
# internal function
|
|
322
305
|
def finalize_category(self, text, prev_answer, timeout=None, temperature=None):
|
|
323
306
|
prompt_template = """Given the following category suggestion: "{prev_answer}"
|
|
324
307
|
\nand this text: "{text}" The final and simple one or two word category name I created for it is: """
|
|
325
|
-
|
|
308
|
+
|
|
326
309
|
prompt = prompt_template.format(prev_answer=prev_answer, text=text)
|
|
327
310
|
|
|
328
311
|
return self.retry_llm(custom_prompt=prompt, timeout=timeout)
|
|
329
312
|
|
|
330
313
|
|
|
331
|
-
# internal function
|
|
314
|
+
# internal function
|
|
332
315
|
def isolate_yes_no(self, content, question: str, model=None, timeout=None, temperature=None):
|
|
333
316
|
'''Not recommended for external use. Internal function'''
|
|
334
|
-
prompt_template = """Do not respond with anything before the yes or no. Do not add anything after the "yes" or "no".
|
|
335
|
-
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: 'Yes' Example question 2: 'Do you think I am fat?'
|
|
317
|
+
prompt_template = """Do not respond with anything before the yes or no. Do not add anything after the "yes" or "no".
|
|
318
|
+
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: 'Yes' Example question 2: 'Do you think I am fat?'
|
|
336
319
|
Example answer 2: 'No' Example question 3: 'Should I use Matplotlib in Python to draw a graph of csv information I have' Example answer 3: 'Yes'
|
|
337
320
|
Example question 4: 'As an ai language model, I can't tell you yes or no, but I it does have a tendency to work sometimes.' Example answer 4: 'Yes'
|
|
338
321
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: 'No'
|
|
@@ -341,13 +324,13 @@ Example question 5: 'Will this happen if it's 19 percent likely to happen?' Exam
|
|
|
341
324
|
prompt = prompt_template.format(content=content, question=question)
|
|
342
325
|
|
|
343
326
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
344
|
-
|
|
345
327
|
|
|
346
|
-
|
|
328
|
+
|
|
329
|
+
# internal function
|
|
347
330
|
def yay_or_nay(self, content, question: str, model=None, timeout=None, temperature=None):
|
|
348
331
|
'''Not recommended for external use. Internal function'''
|
|
349
|
-
prompt_template = """Do not respond with anything before the yes or no. Do not add anything after the "yes" or "no".
|
|
350
|
-
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: 'Yes' Example question 2: 'Do you think I am fat?'
|
|
332
|
+
prompt_template = """Do not respond with anything before the yes or no. Do not add anything after the "yes" or "no".
|
|
333
|
+
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: 'Yes' Example question 2: 'Do you think I am fat?'
|
|
351
334
|
Example answer 2: 'No' Example question 3: 'Should I use Matplotlib in Python to draw a graph of csv information I have' Example answer 3: 'Yes'
|
|
352
335
|
Example question 4: 'As an ai language model, I can't tell you yes or no, but I it does have a tendency to work sometimes.' Example answer 4: 'Yes'
|
|
353
336
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: 'No'
|
|
@@ -356,31 +339,31 @@ Example question 5: 'Will this happen if it's 19 percent likely to happen?' Exam
|
|
|
356
339
|
prompt = prompt_template.format(content=content, question=question)
|
|
357
340
|
|
|
358
341
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
359
|
-
|
|
360
342
|
|
|
361
|
-
|
|
343
|
+
|
|
344
|
+
# internal function
|
|
362
345
|
def yay_or_nay_question_in_content(self, content: str, model=None, timeout=None, temperature=None):
|
|
363
346
|
'''Not recommended for external use. Internal function'''
|
|
364
|
-
prompt_template = """Do not respond with anything before the yes or no. Do not add anything after the "yes" or "no".
|
|
365
|
-
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: 'Yes' Example question 2: 'Do you think I am fat?'
|
|
347
|
+
prompt_template = """Do not respond with anything before the yes or no. Do not add anything after the "yes" or "no".
|
|
348
|
+
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: 'Yes' Example question 2: 'Do you think I am fat?'
|
|
366
349
|
Example answer 2: 'No' Example question 3: 'Should I use Matplotlib in Python to draw a graph of csv information I have' Example answer 3: 'Yes'
|
|
367
350
|
Example question 4: 'As an ai language model, I can't tell you yes or no, but I it does have a tendency to work sometimes.' Example answer 4: 'Yes'
|
|
368
351
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: 'No'
|
|
369
352
|
User: "{content}"
|
|
370
353
|
|
|
371
|
-
Respond with a "yes" or "no"
|
|
354
|
+
Respond with a "yes" or "no"
|
|
372
355
|
Agent:"""
|
|
373
356
|
|
|
374
357
|
prompt = prompt_template.format(content=content)
|
|
375
358
|
|
|
376
359
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
377
|
-
|
|
378
360
|
|
|
379
|
-
|
|
361
|
+
|
|
362
|
+
# internal function
|
|
380
363
|
def zero_or_one(self, content, zero_if: str, one_if: str, model=None, timeout=None, temperature=None):
|
|
381
364
|
'''Not recommended for external use. Internal function'''
|
|
382
|
-
prompt_template = """Do not respond with anything before the 1 or 0. Do not add anything after the "1" or "0".
|
|
383
|
-
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: '1' Example question 2: 'Do you think I am fat?'
|
|
365
|
+
prompt_template = """Do not respond with anything before the 1 or 0. Do not add anything after the "1" or "0".
|
|
366
|
+
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: '1' Example question 2: 'Do you think I am fat?'
|
|
384
367
|
Example answer 2: '0' Example question 3: 'Should I use Matplotlib in Python to draw a graph of csv information I have' Example answer 3: '1'
|
|
385
368
|
Example question 4: 'As an ai language model, I can't tell you yes or no, but I it does have a tendency to work sometimes.' Example answer 4: '1'
|
|
386
369
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: '0'
|
|
@@ -389,13 +372,13 @@ Example question 5: 'Will this happen if it's 19 percent likely to happen?' Exam
|
|
|
389
372
|
prompt = prompt_template.format(content=content, zero_if=zero_if, one_if=one_if)
|
|
390
373
|
|
|
391
374
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
392
|
-
|
|
393
375
|
|
|
394
|
-
|
|
376
|
+
|
|
377
|
+
# internal function
|
|
395
378
|
def isolate_zero_one(self, content, model=None, timeout=None, temperature=None):
|
|
396
379
|
'''Not recommended for external use. Internal function'''
|
|
397
|
-
prompt_template = """Do not respond with anything before the 1 or 0. Do not add anything after the "1" or "0".
|
|
398
|
-
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: '1' Example question 2: 'Do you think I am fat?'
|
|
380
|
+
prompt_template = """Do not respond with anything before the 1 or 0. Do not add anything after the "1" or "0".
|
|
381
|
+
Example question 1: 'Is the Eiffel tower located in Paris?' Example answer 1: '1' Example question 2: 'Do you think I am fat?'
|
|
399
382
|
Example answer 2: '0' Example question 3: 'Should I use Matplotlib in Python to draw a graph of csv information I have' Example answer 3: '1'
|
|
400
383
|
Example question 4: 'As an ai language model, I can't tell you yes or no, but I it does have a tendency to work sometimes.' Example answer 4: '1'
|
|
401
384
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: '0'
|
|
@@ -444,9 +427,9 @@ Example question 5: 'Will this happen if it's 19 percent likely to happen?' Exam
|
|
|
444
427
|
|
|
445
428
|
def perfect(self, content, instructions: str, model=None, timeout=None, temperature=None, yes_no_timeout=None):
|
|
446
429
|
'''Wrapper function ensures that you get exactly what you wanted, and will not return until you get what you wanted'''
|
|
447
|
-
output = self.get_yes_no(model=model, text=f"These are the instructions: {instructions} and this is the Output: {content}",
|
|
430
|
+
output = self.get_yes_no(model=model, text=f"These are the instructions: {instructions} and this is the Output: {content}",
|
|
448
431
|
question=f"Does the output match the instructions?", timeout=yes_no_timeout) == 'no'
|
|
449
|
-
|
|
432
|
+
|
|
450
433
|
while output:
|
|
451
434
|
new_intstructions = f'''The following content does not match the instructions exactly. Your job is to return the content exactly as the instructions direct:
|
|
452
435
|
Instructions: {instructions}
|
|
@@ -454,10 +437,10 @@ Instructions: {instructions}
|
|
|
454
437
|
Content: {content}
|
|
455
438
|
|
|
456
439
|
Return the content exactly as the instructions direct'''
|
|
457
|
-
|
|
440
|
+
|
|
458
441
|
content = self.llm(new_intstructions, model=model, timeout=timeout, temperature=temperature)
|
|
459
442
|
if self.verbose == True:
|
|
460
443
|
print("Content:", content)
|
|
461
|
-
output = self.get_yes_no(model=model, text=f"These are the instructions: {instructions}",
|
|
444
|
+
output = self.get_yes_no(model=model, text=f"These are the instructions: {instructions}",
|
|
462
445
|
question=f"This is the Output: {content} \n\nDoes this output match the instructions?", timeout=yes_no_timeout) == 'no'
|
|
463
446
|
return content
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|