diff --git a/README.md b/README.md index 6212e87..b75c59f 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ http://{your elastic ip}:5000/total create_api + finetuning + chatting ``` -py .\script\total_process.py --api_url "api_url" --data_id "regression013" --user "user email" --title "title" --description "description" --question "hi" +py .\script\process.py --step "all" --api_url "api_url" --data_id "regression013" --user "user email" --title "title" --description "description" --question "hi" ``` - Postman ![Alt text](./images/image-34.png) @@ -265,7 +265,7 @@ curl -X 'POST' \ http://{your elastic ip}:5000/create_api ``` -py .\script\create_api_key.py --api_url "api_url" --data_id "regression013" --user "user email" --title "title" --description "description" +py .\script\process.py --step "create_api" --api_url "api_url" --data_id "regression013" --user "user email" --title "title" --description "description" ``` - Postman ![Alt text](./images/image-29.png) @@ -286,7 +286,7 @@ curl -X 'POST' \ http://{your elastic ip}:5000/delete_api ``` -py .\script\delete_api_key.py --api_url "api_url" --data_id "regression013" --user "user email" --api_key "api key" +py .\script\process.py --step "delete_api" --api_url "api_url" --data_id "regression013" --user "user email" --api_key "api key" ``` - Postman ![Alt text](./images/image-30.png) @@ -306,7 +306,7 @@ curl -X 'POST' \ http://{your elastic ip}:5000/check_api ``` -py .\script\check_api_key.py --api_url "api_url" --data_id "regression013" --user "user email" --api_key "api key" +py .\script\process.py --step "check_api" --api_url "api_url" --data_id "regression013" --user "user email" --api_key "api key" ``` - postman ![Alt text](./images/image-31.png) @@ -327,7 +327,7 @@ curl -X 'POST' \ http://{your elastic ip}:5000/finetuning ``` -py .\script\finetuning.py --api_url "api_url" --data_id "regression013" --user "user email" --api_key "api key" +py .\script\process.py --step "finetuning" --api_url "api_url" --data_id "regression013" --user "user email" --api_key "api key" ``` - postman ![Alt text](./images/image-33.png) @@ -347,7 +347,7 @@ curl -X 'POST' \ http://{your elastic ip}:5000/conversation ``` -py .\script\conversation.py --api_url "api_url" --data_id "regression013" --user "user email" --api_key "api key" --question "hi" +py .\script\process.py --step "chatting" --api_url "api_url" --data_id "regression013" --user "user email" --api_key "api key" --question "hi" ``` - postman ![Alt text](./images/image-32.png) diff --git a/script/chatting.py b/script/chatting.py deleted file mode 100644 index 9c0bf87..0000000 --- a/script/chatting.py +++ /dev/null @@ -1,50 +0,0 @@ -import gc -import argparse - -from send_request import send_request - -def chatting(args): - """ - Main entry point for the chat application - Args: - args: Command line arguments - """ - # Prepare the data to be sent in the request - data = { - "api_key": str(args.api_key), - "user": str(args.user), - "data_id": str(args.data_id), - "question": str(args.question) - } - - # Send the request and get the result - result = send_request(args.api_url, data) - - # Clean up and free memory - gc.collect() - - # Print the result - print(result) - -if __name__ == "__main__": - # Clean up buffer memory before starting the program - gc.collect() - - # Default values for command line arguments - user = "user@gmail.com" - api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" - data_id = "" - api_url = "http://localhost:8000/conversation" - question = "hi" - - # Set up command line argument parser - p = argparse.ArgumentParser(description="Chatting") - p.add_argument("--api_url", type=str, default=api_url, help="URL to send the POST request to") - p.add_argument("--data_id", type=str, default=data_id, help="Data directory") - p.add_argument("--user", type=str, default=user, help="User Email") - p.add_argument("--question", type=str, default=question, help="User's question") - p.add_argument("--api_key", type=str, default=api_key, help="API key") - args = p.parse_args() - - # Call the chatting function with the parsed arguments - chatting(args) diff --git a/script/check_api_key.py b/script/check_api_key.py deleted file mode 100644 index 4f4a28e..0000000 --- a/script/check_api_key.py +++ /dev/null @@ -1,47 +0,0 @@ -import gc -import argparse - -from send_request import send_request - -def check_api_key(args): - """ - Function to check the validity of an API key - Args: - args: Command line arguments - """ - # Prepare the data to be sent in the request - data = { - "api_key": str(args.api_key), - "user": str(args.user), - "data_id": str(args.data_id) - } - - # Send the request and get the result - result = send_request(args.api_url, data) - - # Clean up and free memory - gc.collect() - - # Print the result - print(result) - -if __name__ == "__main__": - # Clean up buffer memory before starting the program - gc.collect() - - # Default values for command line arguments - user = "user@gmail.com" - api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" - data_id = "" - api_url = "http://localhost:8000/check_api" - - # Set up command line argument parser - p = argparse.ArgumentParser(description="Check API key.") - p.add_argument("--api_url", type=str, default=api_url, help="URL to send the POST request to") - p.add_argument("--data_id", type=str, default=data_id, help="Data directory") - p.add_argument("--user", type=str, default=user, help="User Email") - p.add_argument("--api_key", type=str, default=api_key, help="API key") - args = p.parse_args() - - # Call the check_api_key function with the parsed arguments - check_api_key(args) \ No newline at end of file diff --git a/script/create_api_key.py b/script/create_api_key.py deleted file mode 100644 index 997dced..0000000 --- a/script/create_api_key.py +++ /dev/null @@ -1,50 +0,0 @@ -import gc -import argparse - -from send_request import send_request - -def create_api_key(args): - """ - Function to create a new API key - Args: - args: Command line arguments - """ - # Prepare the data to be sent in the request - data = { - "user": str(args.user), - "title": str(args.title), - "description": str(args.description), - "data_id": str(args.data_id) - } - - # Send the request and get the result - result = send_request(args.api_url, data) - - # Clean up and free memory - gc.collect() - - # Print the result - print(result) - -if __name__ == "__main__": - # Clean up buffer memory before starting the program - gc.collect() - - # Default values for command line arguments - user = "user@gmail.com" - title = "title" - description = "description" - data_id = "" - api_url = "http://localhost:8000/create_api" - - # Set up command line argument parser - p = argparse.ArgumentParser(description="Create API key.") - p.add_argument("--api_url", type=str, default=api_url, help="URL to send the POST request to") - p.add_argument("--data_id", type=str, default=data_id, help="Data directory") - p.add_argument("--user", type=str, default=user, help="User Email") - p.add_argument("--title", type=str, default=title, help="Title") - p.add_argument("--description", type=str, default=description, help="Description") - args = p.parse_args() - - # Call the create_api_key function with the parsed arguments - create_api_key(args) \ No newline at end of file diff --git a/script/delete_api_key.py b/script/delete_api_key.py deleted file mode 100644 index ec335ef..0000000 --- a/script/delete_api_key.py +++ /dev/null @@ -1,47 +0,0 @@ -import gc -import argparse - -from send_request import send_request - -def delete_api_key(args): - """ - Function to delete an API key - Args: - args: Command line arguments - """ - # Prepare the data to be sent in the request - data = { - "api_key": str(args.api_key), - "user": str(args.user), - "data_id": str(args.data_id) - } - - # Send the request and get the result - result = send_request(args.api_url, data) - - # Clean up and free memory - gc.collect() - - # Print the result - print(result) - -if __name__ == "__main__": - # Clean up buffer memory before starting the program - gc.collect() - - # Default values for command line arguments - user = "user@gmail.com" - api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" - data_id = "" - api_url = "http://localhost:8000/delete_api" - - # Set up command line argument parser - p = argparse.ArgumentParser(description="Delete API key.") - p.add_argument("--api_url", type=str, default=api_url, help="URL to send the POST request to") - p.add_argument("--data_id", type=str, default=data_id, help="Data directory") - p.add_argument("--user", type=str, default=user, help="User Email") - p.add_argument("--api_key", type=str, default=api_key, help="API key") - args = p.parse_args() - - # Call the delete_api_key function with the parsed arguments - delete_api_key(args) \ No newline at end of file diff --git a/script/finetuning.py b/script/finetuning.py deleted file mode 100644 index 7d37d36..0000000 --- a/script/finetuning.py +++ /dev/null @@ -1,47 +0,0 @@ -import gc -import argparse - -from send_request import send_request - -def run_fine_tuning(args): - """ - Function to initiate fine-tuning of a model - Args: - args: Command line arguments - """ - # Prepare the data to be sent in the request - data = { - "api_key": str(args.api_key), - "user": str(args.user), - "data_id": str(args.data_id) - } - - # Send the request and get the result - result = send_request(args.api_url, data) - - # Clean up and free memory - gc.collect() - - # Print the result - print(result) - -if __name__ == "__main__": - # Clean up buffer memory before starting the program - gc.collect() - - # Default values for command line arguments - user = "user@gmail.com" - api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" - data_id = "" - api_url = "http://localhost:8000/finetuning" - - # Set up command line argument parser - p = argparse.ArgumentParser(description="Fine-Tuning a model.") - p.add_argument("--api_url", type=str, default=api_url, help="URL to send the POST request to") - p.add_argument("--data_id", type=str, default=data_id, help="Data directory") - p.add_argument("--user", type=str, default=user, help="User Email") - p.add_argument("--api_key", type=str, default=api_key, help="API key") - args = p.parse_args() - - # Call the run_fine_tuning function with the parsed arguments - run_fine_tuning(args) diff --git a/script/process.py b/script/process.py new file mode 100644 index 0000000..69de422 --- /dev/null +++ b/script/process.py @@ -0,0 +1,195 @@ +import gc +import argparse + +from send_request import send_request + +def create_api_key(args): + """ + Function to create a new API key + Args: + args: Command line arguments + """ + # Prepare the data to be sent in the request + data = { + "user": str(args.user), + "title": str(args.title), + "description": str(args.description), + "data_id": str(args.data_id) + } + + url = f'{args.api_url}/create_api' + + # Send the request and get the result + result = send_request(url, data) + + # Clean up and free memory + gc.collect() + + # Print the result + print(result) + +def delete_api_key(args): + """ + Function to delete an API key + Args: + args: Command line arguments + """ + # Prepare the data to be sent in the request + data = { + "api_key": str(args.api_key), + "user": str(args.user), + "data_id": str(args.data_id) + } + + url = f'{args.api_url}/delete_api' + # Send the request and get the result + result = send_request(url, data) + + # Clean up and free memory + gc.collect() + + # Print the result + print(result) + +def check_api_key(args): + """ + Function to check the validity of an API key + Args: + args: Command line arguments + """ + # Prepare the data to be sent in the request + data = { + "api_key": str(args.api_key), + "user": str(args.user), + "data_id": str(args.data_id) + } + + url = f'{args.api_url}/check_api' + # Send the request and get the result + result = send_request(url, data) + + # Clean up and free memory + gc.collect() + + # Print the result + print(result) + +def run_fine_tuning(args): + """ + Function to initiate fine-tuning of a model + Args: + args: Command line arguments + """ + # Prepare the data to be sent in the request + data = { + "api_key": str(args.api_key), + "user": str(args.user), + "data_id": str(args.data_id) + } + + url = f'{args.api_url}/finetuning' + # Send the request and get the result + result = send_request(url, data) + + # Clean up and free memory + gc.collect() + + # Print the result + print(result) + +def chatting(args): + """ + Main entry point for the chat application + Args: + args: Command line arguments + """ + # Prepare the data to be sent in the request + data = { + "api_key": str(args.api_key), + "user": str(args.user), + "data_id": str(args.data_id), + "question": str(args.question) + } + + url = f'{args.api_url}/conversation' + # Send the request and get the result + result = send_request(url, data) + + # Clean up and free memory + gc.collect() + + # Print the result + print(result) + +def total_process(args): + """ + Posts data to a specified API URL and prints the result + Args: + args: Command line arguments + """ + # Prepare the data to be sent in the request + data = { + "user": str(args.user), + "title": str(args.title), + "description": str(args.description), + "data_id": str(args.data_id), + "question": str(args.question) + } + + url = f'{args.api_url}/total' + # Send the request and get the result + result = send_request(url, data) + + # Clean up and free memory + gc.collect() + + # Print the result + print(result) + +if __name__ == "__main__": + # Clean up buffer memory before starting the program + gc.collect() + + # Default values for command line arguments + step = "create_api" + user = "user@gmail.com" + title = "title" + description = "description" + data_id = "" + api_url = "http://localhost:8000" + api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" + question = 'hi' + + # Set up command line argument parser + p = argparse.ArgumentParser(description="Oridos AI Process.") + p.add_argument("--step", type=str, default=step, help="Select the process step.") + p.add_argument("--api_url", type=str, default=api_url, help="URL to send the POST request to") + p.add_argument("--data_id", type=str, default=data_id, help="Data directory") + p.add_argument("--user", type=str, default=user, help="User Email") + p.add_argument("--title", type=str, default=title, help="Title") + p.add_argument("--description", type=str, default=description, help="Description") + p.add_argument("--api_key", type=str, default=api_key, help="API key") + p.add_argument("--question", type=str, default=question, help="User's question") + args = p.parse_args() + + if args.step == "create_api": + # Call the create_api_key function with the parsed arguments + create_api_key(args) + elif args.step == "delete_api": + # Call the delete_api_key function with the parsed arguments + delete_api_key(args) + elif args.step == "check_api": + # Call the check_api_key function with the parsed arguments + check_api_key(args) + elif args.step == "finetuning": + # Call the run_fine_tuning function with the parsed arguments + run_fine_tuning(args) + elif args.step == "chatting": + # Call the chatting function with the parsed arguments + chatting(args) + elif args.step == "all": + # Call the total_process function with the parsed arguments + total_process(args) + else: + print("The API doesn't exist!!!") + \ No newline at end of file diff --git a/script/total_process.py b/script/total_process.py deleted file mode 100644 index 2d5151d..0000000 --- a/script/total_process.py +++ /dev/null @@ -1,53 +0,0 @@ -import gc -import argparse - -from send_request import send_request - -def total_process(args): - """ - Posts data to a specified API URL and prints the result - Args: - args: Command line arguments - """ - # Prepare the data to be sent in the request - data = { - "user": str(args.user), - "title": str(args.title), - "description": str(args.description), - "data_id": str(args.data_id), - "question": str(args.question) - } - - # Send the request and get the result - result = send_request(args.api_url, data) - - # Clean up and free memory - gc.collect() - - # Print the result - print(result) - -if __name__ == "__main__": - # Clean up buffer memory before starting the program - gc.collect() - - # Default values for command line arguments - user = "user@gmail.com" - title = "title" - description = "description" - data_id = "" - api_url = "http://localhost:5000/total" - question = "hi" - - # Set up command line argument parser - p = argparse.ArgumentParser(description="Total Process: Create API key, Fine Tuning, Chatting.") - p.add_argument("--api_url", type=str, default=api_url, help="URL to send the POST request to") - p.add_argument("--data_id", type=str, default=data_id, help="Data directory") - p.add_argument("--user", type=str, default=user, help="User Email") - p.add_argument("--title", type=str, default=title, help="Title") - p.add_argument("--description", type=str, default=description, help="Description") - p.add_argument("--question", type=str, default=question, help="User's question") - args = p.parse_args() - - # Call the total_process function with the parsed arguments - total_process(args) \ No newline at end of file