vector-vault 5.2.1__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.1 → vector_vault-5.2.2}/PKG-INFO +1 -1
- {vector_vault-5.2.1 → vector_vault-5.2.2}/setup.py +1 -1
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vector_vault.egg-info/PKG-INFO +1 -1
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/tools_gpt.py +78 -78
- {vector_vault-5.2.1 → vector_vault-5.2.2}/LICENSE +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/README.md +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/setup.cfg +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vector_vault.egg-info/SOURCES.txt +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vector_vault.egg-info/dependency_links.txt +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vector_vault.egg-info/requires.txt +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vector_vault.egg-info/top_level.txt +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/__init__.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/ai.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/cloud_api.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/cloudmanager.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/creds.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/download.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/groq_api.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/itemize.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/vault.py +0 -0
- {vector_vault-5.2.1 → vector_vault-5.2.2}/vectorvault/vecreq.py +0 -0
- {vector_vault-5.2.1 → 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)
|
|
@@ -186,18 +186,18 @@ Content to classify: "{text}" \n\nDo not respond with anything other than the o
|
|
|
186
186
|
pass
|
|
187
187
|
|
|
188
188
|
return new_answer
|
|
189
|
-
|
|
189
|
+
|
|
190
190
|
|
|
191
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}
|
|
192
|
+
prompt = f"""Respond with a list of items from this list: {list_of_options}
|
|
193
193
|
Content to classify: "{text}"
|
|
194
|
-
|
|
194
|
+
|
|
195
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."""
|
|
196
196
|
|
|
197
197
|
answer = self.retry_llm(prompt, model, loop_limit, timeout=timeout, temperature=temperature)
|
|
198
198
|
print(f'Get Answer: {answer}') if self.verbose else None
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
answer = answer.replace(',', '\n').replace(';', '\n')
|
|
201
201
|
candidates = [line.strip() for line in answer.split('\n') if line.strip()]
|
|
202
202
|
|
|
203
203
|
# Process the candidates, directly adding matches, and using get_match for others
|
|
@@ -221,13 +221,13 @@ Content to classify: "{text}" \n\nDo not respond with anything other than the o
|
|
|
221
221
|
list_copy = []
|
|
222
222
|
for option in list_of_options:
|
|
223
223
|
list_copy.append(option.strip().replace('.', '').lower().strip('"').strip("'"))
|
|
224
|
-
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}
|
|
225
225
|
Content to classify: "{content}" \n\nClassifiy the content above based on which topic it is mostly related to one topic: {list_of_options}"""
|
|
226
|
-
|
|
226
|
+
|
|
227
227
|
prompt = prompt_template.format(content=text, list_of_options=list_copy)
|
|
228
228
|
topic = self.retry_llm(prompt, model, loop_limit, timeout=timeout, temperature=temperature)
|
|
229
229
|
print(f"Topic Answer: {topic}") if self.verbose else 0
|
|
230
|
-
|
|
230
|
+
|
|
231
231
|
if topic is not None:
|
|
232
232
|
topic = list_of_options[list_copy.index(topic)] # return original topic
|
|
233
233
|
|
|
@@ -235,25 +235,25 @@ Content to classify: "{content}" \n\nClassifiy the content above based on which
|
|
|
235
235
|
|
|
236
236
|
|
|
237
237
|
def match_or_make(self, text, list_of_options: list = [], model=None, loop_limit=20) -> str:
|
|
238
|
-
'''
|
|
239
|
-
"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.
|
|
240
240
|
If no list is input, then one will be made and be output
|
|
241
241
|
|
|
242
|
-
Internally, decides whether or not to make a new option.
|
|
242
|
+
Internally, decides whether or not to make a new option.
|
|
243
243
|
Then decides on match is no new option.
|
|
244
244
|
If new option, create it, then finalize it
|
|
245
245
|
'''
|
|
246
246
|
if not list_of_options:
|
|
247
247
|
answer = self.make_option_from_zero(text, list_of_options)
|
|
248
248
|
else:
|
|
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.
|
|
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.
|
|
251
251
|
Respond "Yes" if the right category already exists in the list'''
|
|
252
252
|
binary = self.get_yes_no(text, yn_prompt, model=model)
|
|
253
|
-
|
|
253
|
+
|
|
254
254
|
if binary == 'yes':
|
|
255
255
|
answer = self.get_match(text, list_of_options)
|
|
256
|
-
|
|
256
|
+
|
|
257
257
|
if binary == 'no':
|
|
258
258
|
answer = self.make_option(text, list_of_options)
|
|
259
259
|
|
|
@@ -273,11 +273,11 @@ Respond "Yes" if the right category already exists in the list'''
|
|
|
273
273
|
loops += 1
|
|
274
274
|
if (len(answer.split())) <= 2:
|
|
275
275
|
break
|
|
276
|
-
|
|
276
|
+
|
|
277
277
|
return answer
|
|
278
|
-
|
|
279
278
|
|
|
280
|
-
|
|
279
|
+
|
|
280
|
+
# internal function
|
|
281
281
|
def make_option(self, text, list_of_options: list, model=None, timeout=None, temperature=None) -> str:
|
|
282
282
|
prompt_template = """Content to classify: "{content}" \n\n
|
|
283
283
|
Create a new category for the content based on these other categories in this list: {list_of_options}"""
|
|
@@ -287,35 +287,35 @@ Create a new category for the content based on these other categories in this li
|
|
|
287
287
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
288
288
|
|
|
289
289
|
|
|
290
|
-
# internal function
|
|
290
|
+
# internal function
|
|
291
291
|
def make_option_from_zero(self, text, model=None, timeout=None, temperature=None):
|
|
292
292
|
'''
|
|
293
293
|
Option without anything to go off of but the text input
|
|
294
294
|
'''
|
|
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
|
|
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
|
|
297
297
|
no explination before or after, just the name of the catagory. \n\nThe name of the category is: """
|
|
298
|
-
|
|
298
|
+
|
|
299
299
|
prompt = prompt_template.format(content=text)
|
|
300
300
|
|
|
301
301
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
302
|
-
|
|
303
302
|
|
|
304
|
-
|
|
303
|
+
|
|
304
|
+
# internal function
|
|
305
305
|
def finalize_category(self, text, prev_answer, timeout=None, temperature=None):
|
|
306
306
|
prompt_template = """Given the following category suggestion: "{prev_answer}"
|
|
307
307
|
\nand this text: "{text}" The final and simple one or two word category name I created for it is: """
|
|
308
|
-
|
|
308
|
+
|
|
309
309
|
prompt = prompt_template.format(prev_answer=prev_answer, text=text)
|
|
310
310
|
|
|
311
311
|
return self.retry_llm(custom_prompt=prompt, timeout=timeout)
|
|
312
312
|
|
|
313
313
|
|
|
314
|
-
# internal function
|
|
314
|
+
# internal function
|
|
315
315
|
def isolate_yes_no(self, content, question: str, model=None, timeout=None, temperature=None):
|
|
316
316
|
'''Not recommended for external use. Internal function'''
|
|
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?'
|
|
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?'
|
|
319
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'
|
|
320
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'
|
|
321
321
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: 'No'
|
|
@@ -324,13 +324,13 @@ Example question 5: 'Will this happen if it's 19 percent likely to happen?' Exam
|
|
|
324
324
|
prompt = prompt_template.format(content=content, question=question)
|
|
325
325
|
|
|
326
326
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
327
|
-
|
|
328
327
|
|
|
329
|
-
|
|
328
|
+
|
|
329
|
+
# internal function
|
|
330
330
|
def yay_or_nay(self, content, question: str, model=None, timeout=None, temperature=None):
|
|
331
331
|
'''Not recommended for external use. Internal function'''
|
|
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?'
|
|
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?'
|
|
334
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'
|
|
335
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'
|
|
336
336
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: 'No'
|
|
@@ -339,31 +339,31 @@ Example question 5: 'Will this happen if it's 19 percent likely to happen?' Exam
|
|
|
339
339
|
prompt = prompt_template.format(content=content, question=question)
|
|
340
340
|
|
|
341
341
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
342
|
-
|
|
343
342
|
|
|
344
|
-
|
|
343
|
+
|
|
344
|
+
# internal function
|
|
345
345
|
def yay_or_nay_question_in_content(self, content: str, model=None, timeout=None, temperature=None):
|
|
346
346
|
'''Not recommended for external use. Internal function'''
|
|
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?'
|
|
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?'
|
|
349
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'
|
|
350
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'
|
|
351
351
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: 'No'
|
|
352
352
|
User: "{content}"
|
|
353
353
|
|
|
354
|
-
Respond with a "yes" or "no"
|
|
354
|
+
Respond with a "yes" or "no"
|
|
355
355
|
Agent:"""
|
|
356
356
|
|
|
357
357
|
prompt = prompt_template.format(content=content)
|
|
358
358
|
|
|
359
359
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
360
|
-
|
|
361
360
|
|
|
362
|
-
|
|
361
|
+
|
|
362
|
+
# internal function
|
|
363
363
|
def zero_or_one(self, content, zero_if: str, one_if: str, model=None, timeout=None, temperature=None):
|
|
364
364
|
'''Not recommended for external use. Internal function'''
|
|
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?'
|
|
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?'
|
|
367
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'
|
|
368
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'
|
|
369
369
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: '0'
|
|
@@ -372,13 +372,13 @@ Example question 5: 'Will this happen if it's 19 percent likely to happen?' Exam
|
|
|
372
372
|
prompt = prompt_template.format(content=content, zero_if=zero_if, one_if=one_if)
|
|
373
373
|
|
|
374
374
|
return self.retry_llm(custom_prompt=prompt, model=model, timeout=timeout, temperature=temperature)
|
|
375
|
-
|
|
376
375
|
|
|
377
|
-
|
|
376
|
+
|
|
377
|
+
# internal function
|
|
378
378
|
def isolate_zero_one(self, content, model=None, timeout=None, temperature=None):
|
|
379
379
|
'''Not recommended for external use. Internal function'''
|
|
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?'
|
|
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?'
|
|
382
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'
|
|
383
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'
|
|
384
384
|
Example question 5: 'Will this happen if it's 19 percent likely to happen?' Example answer 5: '0'
|
|
@@ -427,9 +427,9 @@ Example question 5: 'Will this happen if it's 19 percent likely to happen?' Exam
|
|
|
427
427
|
|
|
428
428
|
def perfect(self, content, instructions: str, model=None, timeout=None, temperature=None, yes_no_timeout=None):
|
|
429
429
|
'''Wrapper function ensures that you get exactly what you wanted, and will not return until you get what you wanted'''
|
|
430
|
-
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}",
|
|
431
431
|
question=f"Does the output match the instructions?", timeout=yes_no_timeout) == 'no'
|
|
432
|
-
|
|
432
|
+
|
|
433
433
|
while output:
|
|
434
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:
|
|
435
435
|
Instructions: {instructions}
|
|
@@ -437,10 +437,10 @@ Instructions: {instructions}
|
|
|
437
437
|
Content: {content}
|
|
438
438
|
|
|
439
439
|
Return the content exactly as the instructions direct'''
|
|
440
|
-
|
|
440
|
+
|
|
441
441
|
content = self.llm(new_intstructions, model=model, timeout=timeout, temperature=temperature)
|
|
442
442
|
if self.verbose == True:
|
|
443
443
|
print("Content:", content)
|
|
444
|
-
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}",
|
|
445
445
|
question=f"This is the Output: {content} \n\nDoes this output match the instructions?", timeout=yes_no_timeout) == 'no'
|
|
446
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
|