Skip to content

Commit

Permalink
Formated
Browse files Browse the repository at this point in the history
  • Loading branch information
Code7G committed Dec 28, 2023
1 parent d0fd844 commit 9a4af7d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
20 changes: 11 additions & 9 deletions Versions/DAIA_GPT4V_PreProgrammed/Components/Thinker/thinking.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from random import randint

print


class Think:
"""
The main class for operations involving the GPT for the DAIA
Expand Down Expand Up @@ -428,23 +430,23 @@ def explanation_to_suggestions(self, explanation: str, prev_data: bool):
return suggestions

def explanation_is_suggestions(self, explanation):
'''
"""
Is the explanation already made out of suggestions?
For example:
If explanation = "1. Go to the website, 2. Download the app, 3. Install it ....", then explanation_is_suggestion = true
If explanation = "You need to go to the website than download and install the app....", then explanation_is_suggestion = false
'''
prompt = f'''
"""

prompt = f"""
Given the explanation string, determine if it is composed of suggestions or not.
Consider an explanation to be a suggestion if it follows the format of numbered steps starting with digits followed by a period, e.g., "1. Do something, 2. Do another thing, 3. Complete the process."
explanatin string = {explanation}
If the explanation string is a suggestion (or made out of suggestions) then type "is_suggestion"
If the explanation string is NOT a suggestion (or made out of suggestions) then type "not_suggestion"
'''
"""
is_suggestions = self.client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
Expand All @@ -455,13 +457,13 @@ def explanation_is_suggestions(self, explanation):
],
)
is_suggestions = is_suggestions.choices[0].message.content

if is_suggestions.lower() == "is_suggestion":
return True

if is_suggestions.lower() == "not_suggestion":
return False

def short_remember(self, need: str):
"""
Remember a short period of history in detail from the DAIA MemoryDB,
Expand Down
16 changes: 12 additions & 4 deletions Versions/DAIA_GPT4V_PreProgrammed/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,13 @@ def run(api_key):
corrected_suggestions_response.choices[0].message.content
)

is_suggestions = think.explanation_is_suggestions(corrected_suggestions_response)
is_suggestions = think.explanation_is_suggestions(
corrected_suggestions_response
)
if not is_suggestions:
suggestions = think.explanation_to_suggestions(corrected_suggestions_response, prev_data=False)
suggestions = think.explanation_to_suggestions(
corrected_suggestions_response, prev_data=False
)
else:
suggestions = corrected_suggestions_response
print(
Expand Down Expand Up @@ -175,9 +179,13 @@ def run(api_key):
corrected_suggestions_response.choices[0].message.content
)

is_suggestions = think.explanation_is_suggestions(corrected_suggestions_response)
is_suggestions = think.explanation_is_suggestions(
corrected_suggestions_response
)
if not is_suggestions:
suggestions = think.explanation_to_suggestions(corrected_suggestions_response, prev_data=False)
suggestions = think.explanation_to_suggestions(
corrected_suggestions_response, prev_data=False
)
else:
suggestions = corrected_suggestions_response
print(
Expand Down

0 comments on commit 9a4af7d

Please sign in to comment.