mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-09 21:27:53 -05:00
Merge branch 'main' of github.com:Pythagora-io/copilot
This commit is contained in:
@@ -93,15 +93,20 @@ def save_app(user_id, app_id, app_type):
|
|||||||
cursor.execute("INSERT INTO users (id, username, email, password) VALUES (%s, 'username', 'email', 'password')",
|
cursor.execute("INSERT INTO users (id, username, email, password) VALUES (%s, 'username', 'email', 'password')",
|
||||||
(str(user_id),))
|
(str(user_id),))
|
||||||
|
|
||||||
# Now save the app
|
# Now save or update the app
|
||||||
cursor.execute("INSERT INTO apps (user_id, app_id, app_type, status) VALUES (%s, %s, %s, 'started') RETURNING id",
|
cursor.execute("""
|
||||||
(str(user_id), (str(app_id)), app_type))
|
INSERT INTO apps (user_id, app_id, app_type, status)
|
||||||
|
VALUES (%s, %s, %s, 'started')
|
||||||
|
ON CONFLICT (app_id) DO UPDATE SET
|
||||||
|
user_id = EXCLUDED.user_id, app_type = EXCLUDED.app_type, status = EXCLUDED.status
|
||||||
|
RETURNING id
|
||||||
|
""", (str(user_id), str(app_id), app_type))
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
logger.info('User saved')
|
logger.info('App saved')
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
# prompts/prompts.py
|
# prompts/prompts.py
|
||||||
import inquirer
|
|
||||||
from inquirer.themes import GreenPassion
|
|
||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
import questionary
|
import questionary
|
||||||
|
|
||||||
@@ -8,58 +7,55 @@ from const import common
|
|||||||
from const.llm import MAX_QUESTIONS, END_RESPONSE
|
from const.llm import MAX_QUESTIONS, END_RESPONSE
|
||||||
from utils.llm_connection import create_gpt_chat_completion, get_prompt
|
from utils.llm_connection import create_gpt_chat_completion, get_prompt
|
||||||
from utils.utils import capitalize_first_word_with_underscores, get_sys_message, find_role_from_step
|
from utils.utils import capitalize_first_word_with_underscores, get_sys_message, find_role_from_step
|
||||||
|
from utils.questionary import styled_select, styled_text
|
||||||
from logger.logger import logger
|
from logger.logger import logger
|
||||||
|
|
||||||
|
|
||||||
def ask_for_app_type():
|
def ask_for_app_type():
|
||||||
questions = [
|
answer = styled_select(
|
||||||
inquirer.List('type',
|
"What type of app do you want to build?",
|
||||||
message="What type of app do you want to build?",
|
choices=common.APP_TYPES
|
||||||
choices=common.APP_TYPES,
|
)
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
answers = inquirer.prompt(questions, theme=GreenPassion())
|
if answer is None:
|
||||||
if answers is None:
|
|
||||||
print("Exiting application.")
|
print("Exiting application.")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
while 'unavailable' in answers['type']:
|
while 'unavailable' in answer:
|
||||||
print("Sorry, that option is not available.")
|
print("Sorry, that option is not available.")
|
||||||
answers = inquirer.prompt(questions, theme=GreenPassion())
|
answer = styled_select(
|
||||||
if answers is None:
|
"What type of app do you want to build?",
|
||||||
|
choices=common.APP_TYPES
|
||||||
|
)
|
||||||
|
if answer is None:
|
||||||
print("Exiting application.")
|
print("Exiting application.")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
print("You chose: " + answers['type'])
|
print("You chose: " + answer)
|
||||||
logger.info(f"You chose: {answers['type']}")
|
logger.info(f"You chose: {answer}")
|
||||||
return answers['type']
|
return answer
|
||||||
|
|
||||||
|
|
||||||
def ask_for_main_app_definition():
|
def ask_for_main_app_definition():
|
||||||
questions = [
|
description = styled_text(
|
||||||
inquirer.Text('description', message="Describe your app in as many details as possible.")
|
"Describe your app in as many details as possible."
|
||||||
]
|
)
|
||||||
|
|
||||||
answers = inquirer.prompt(questions, theme=GreenPassion())
|
if description is None:
|
||||||
if answers is None:
|
|
||||||
print("No input provided!")
|
print("No input provided!")
|
||||||
return
|
return
|
||||||
|
|
||||||
description = answers['description']
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
questions = [
|
confirmation = styled_text(
|
||||||
inquirer.Text('confirmation', message="Do you want to add anything else? If not, just press ENTER.")
|
"Do you want to add anything else? If not, just press ENTER."
|
||||||
]
|
)
|
||||||
|
|
||||||
answers = inquirer.prompt(questions, theme=GreenPassion())
|
if confirmation is None or confirmation == '':
|
||||||
if answers is None or answers['confirmation'] == '':
|
|
||||||
break
|
break
|
||||||
elif description[-1] not in ['.', '!', '?', ';']:
|
elif description[-1] not in ['.', '!', '?', ';']:
|
||||||
description += '.'
|
description += '.'
|
||||||
|
|
||||||
description += ' ' + answers['confirmation']
|
description += ' ' + confirmation
|
||||||
|
|
||||||
logger.info(f"Initial App description done: {description}")
|
logger.info(f"Initial App description done: {description}")
|
||||||
|
|
||||||
@@ -68,7 +64,7 @@ def ask_for_main_app_definition():
|
|||||||
|
|
||||||
def ask_user(question):
|
def ask_user(question):
|
||||||
while True:
|
while True:
|
||||||
answer = questionary.text(question).ask()
|
answer = styled_text(question)
|
||||||
|
|
||||||
if answer is None:
|
if answer is None:
|
||||||
print("Exiting application.")
|
print("Exiting application.")
|
||||||
|
|||||||
20
euclid/utils/questionary.py
Normal file
20
euclid/utils/questionary.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from prompt_toolkit.styles import Style
|
||||||
|
import questionary
|
||||||
|
|
||||||
|
custom_style = Style.from_dict({
|
||||||
|
'question': '#FFFFFF bold', # the color and style of the question
|
||||||
|
'answer': '#FF910A bold', # the color and style of the answer
|
||||||
|
'pointer': '#FF4500 bold', # the color and style of the selection pointer
|
||||||
|
'highlighted': '#63CD91 bold', # the color and style of the highlighted choice
|
||||||
|
'instruction': '#FFFF00 bold' # the color and style of the question mark
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def styled_select(*args, **kwargs):
|
||||||
|
kwargs["style"] = custom_style # Set style here
|
||||||
|
return questionary.select(*args, **kwargs).ask() # .ask() is included here
|
||||||
|
|
||||||
|
|
||||||
|
def styled_text(*args, **kwargs):
|
||||||
|
kwargs["style"] = custom_style # Set style here
|
||||||
|
return questionary.text(*args, **kwargs).ask() # .ask() is included here
|
||||||
@@ -3,7 +3,6 @@ certifi==2023.5.7
|
|||||||
charset-normalizer==3.2.0
|
charset-normalizer==3.2.0
|
||||||
distro==1.8.0
|
distro==1.8.0
|
||||||
idna==3.4
|
idna==3.4
|
||||||
inquirer==3.1.3
|
|
||||||
Jinja2==3.1.2
|
Jinja2==3.1.2
|
||||||
MarkupSafe==2.1.3
|
MarkupSafe==2.1.3
|
||||||
prompt-toolkit==3.0.39
|
prompt-toolkit==3.0.39
|
||||||
|
|||||||
Reference in New Issue
Block a user