dmddl 0.2.4__tar.gz → 0.2.6__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.
- {dmddl-0.2.4 → dmddl-0.2.6}/PKG-INFO +2 -2
- {dmddl-0.2.4 → dmddl-0.2.6}/pyproject.toml +2 -2
- {dmddl-0.2.4 → dmddl-0.2.6}/src/dmddl/cli.py +29 -25
- {dmddl-0.2.4 → dmddl-0.2.6}/src/dmddl/config/settings.py +1 -1
- {dmddl-0.2.4 → dmddl-0.2.6}/src/dmddl/models/llm.py +7 -5
- {dmddl-0.2.4 → dmddl-0.2.6}/LICENSE +0 -0
- {dmddl-0.2.4 → dmddl-0.2.6}/README.md +0 -0
- {dmddl-0.2.4 → dmddl-0.2.6}/src/dmddl/__init__.py +0 -0
- {dmddl-0.2.4 → dmddl-0.2.6}/src/dmddl/config/__init__.py +0 -0
- {dmddl-0.2.4 → dmddl-0.2.6}/src/dmddl/models/__init__.py +0 -0
- {dmddl-0.2.4 → dmddl-0.2.6}/src/dmddl/models/prompt.py +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: dmddl
|
3
|
-
Version: 0.2.
|
4
|
-
Summary: cli tool for creating insert
|
3
|
+
Version: 0.2.6
|
4
|
+
Summary: cli tool for creating insert script from ddl script
|
5
5
|
License: MIT
|
6
6
|
Author: HoJLter
|
7
7
|
Author-email: hojlter.work@gmail.com
|
@@ -1,7 +1,7 @@
|
|
1
1
|
[project]
|
2
2
|
name = "dmddl"
|
3
|
-
version = "0.2.
|
4
|
-
description = "cli tool for creating insert
|
3
|
+
version = "0.2.6"
|
4
|
+
description = "cli tool for creating insert script from ddl script"
|
5
5
|
authors = [
|
6
6
|
{name = "HoJLter",email = "hojlter.work@gmail.com"}
|
7
7
|
]
|
@@ -6,33 +6,26 @@ from rich.console import Console
|
|
6
6
|
from dmddl.models.llm import openai_request
|
7
7
|
from dmddl.models.prompt import prompt as base_prompt
|
8
8
|
import argparse
|
9
|
-
import sys
|
10
9
|
|
11
10
|
|
12
11
|
AVAILABLE_PROVIDERS = ["OpenAI"]
|
13
|
-
sys.tracebacklimit = 10 # it makes errors more user-friendly (turn off for dev)
|
14
12
|
|
15
13
|
|
16
14
|
def choose_provider(providers):
|
17
|
-
|
15
|
+
provider = questionary.select("Choose your LLM provider:",
|
18
16
|
choices=providers).ask()
|
19
|
-
|
17
|
+
if provider:
|
18
|
+
return provider
|
19
|
+
else:
|
20
|
+
raise Exception("LLM Provider isn't found")
|
20
21
|
|
21
22
|
|
22
23
|
def ask_api_key():
|
23
24
|
api_key = questionary.password("Enter your api key:").ask()
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
console = Console()
|
29
|
-
with console.status("[bold blue]Making test query"):
|
30
|
-
if provider == "OpenAI":
|
31
|
-
try:
|
32
|
-
response = openai_request("Hello! Its a test query :)", api_key)
|
33
|
-
print(f"\n[green bold]{response} \nAll done! Your api key is correct!")
|
34
|
-
except KeyError:
|
35
|
-
print("Your api key is incorrect! Use -c (--config) to set another api key")
|
25
|
+
if api_key:
|
26
|
+
return api_key
|
27
|
+
else:
|
28
|
+
raise Exception("API key isn't provided")
|
36
29
|
|
37
30
|
|
38
31
|
def make_query(provider, api_key, prompt):
|
@@ -41,7 +34,8 @@ def make_query(provider, api_key, prompt):
|
|
41
34
|
if provider == "OpenAI":
|
42
35
|
response = openai_request(base_prompt+prompt, api_key)
|
43
36
|
return response
|
44
|
-
|
37
|
+
|
38
|
+
raise Exception("LLM Provider not found")
|
45
39
|
|
46
40
|
|
47
41
|
def write_output_file(data):
|
@@ -75,25 +69,35 @@ def main():
|
|
75
69
|
llm_provider = settings['DMDDL_CUR_PROVIDER']
|
76
70
|
api_key = settings['DMDDL_LLM_KEY']
|
77
71
|
|
78
|
-
if not api_key or args.config:
|
79
|
-
set_parameters()
|
80
72
|
|
73
|
+
if not args.source and not args.config:
|
74
|
+
print("[red bold]You must provide any arguments:\n"
|
75
|
+
"-c (--config): opens settings menu\n"
|
76
|
+
"-s (--source): specify the input file")
|
77
|
+
|
78
|
+
|
79
|
+
if args.config:
|
80
|
+
set_parameters()
|
81
81
|
if args.source:
|
82
82
|
with open(args.source, "r", encoding='utf-8') as file:
|
83
83
|
user_prompt = file.read()
|
84
84
|
syntax = Syntax(user_prompt, 'sql', line_numbers=True)
|
85
|
+
print(f"\n[yellow bold]{args.source.upper()}\n", )
|
85
86
|
console.print(syntax)
|
86
|
-
|
87
|
-
confirmation = questionary.confirm("Do you wanna use this DDL script?").ask()
|
87
|
+
confirmation = questionary.confirm("Do you want to use this DDL script to generate the insert?").ask()
|
88
88
|
|
89
89
|
if confirmation:
|
90
|
-
response = make_query(provider=llm_provider,
|
91
|
-
|
92
|
-
|
90
|
+
success, response = make_query(provider=llm_provider,
|
91
|
+
api_key=api_key,
|
92
|
+
prompt=user_prompt)
|
93
93
|
write_output_file(response)
|
94
94
|
syntax = Syntax(response, 'sql', line_numbers=True)
|
95
|
+
print("\n\n[yellow bold]OUTPUT.TXT\n",)
|
95
96
|
console.print(syntax)
|
96
|
-
|
97
|
+
if success:
|
98
|
+
print("[green bold] Your DML script is ready! Check output.txt")
|
99
|
+
if not success:
|
100
|
+
print("[red bold] Error has occurred... Check output.txt")
|
97
101
|
|
98
102
|
|
99
103
|
if __name__ == '__main__':
|
@@ -16,10 +16,12 @@ def openai_request(prompt, api_key):
|
|
16
16
|
]
|
17
17
|
}
|
18
18
|
response = requests.post(url=url, headers=headers, json=data)
|
19
|
-
|
20
|
-
return response.json()['choices'][0]['message']['content']
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
if response.status_code == 200:
|
20
|
+
return True, response.json()['choices'][0]['message']['content']
|
21
|
+
elif response.status_code == 401:
|
22
|
+
return False, ("Your api key is incorrect. \n"
|
23
|
+
"Use -c (--config) to configurate app and set new API key.")
|
24
|
+
else:
|
25
|
+
return False, response.json()['error']['message']
|
24
26
|
|
25
27
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|