This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from loyal812/feat/script
Feat/script
- Loading branch information
Showing
32 changed files
with
371 additions
and
18 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import gc | ||
import argparse | ||
|
||
from send_request import send_request | ||
|
||
def chatting(args): | ||
""" | ||
main entry point | ||
""" | ||
|
||
data = { | ||
"api_key": str(args.api_key), | ||
"user": str(args.user), | ||
"data_id": str(args.data_id), | ||
"question": str(args.question) | ||
} | ||
|
||
result = send_request(args.api_url, data) | ||
|
||
gc.collect() | ||
|
||
print(result) | ||
|
||
if __name__ == "__main__": | ||
""" | ||
Form command lines | ||
""" | ||
# Clean up buffer memory | ||
gc.collect() | ||
|
||
user = "user@gmail.com" | ||
api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" | ||
data_id = "" | ||
api_url = "http://localhost:8000/conversation" | ||
question = "hi" | ||
|
||
# Add options | ||
p = argparse.ArgumentParser() | ||
p = argparse.ArgumentParser(description="Translate text within an image.") | ||
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="payload directory to the test example") | ||
p.add_argument("--user", type=str, default=user, help="user") | ||
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() | ||
|
||
|
||
chatting(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import gc | ||
import argparse | ||
|
||
from send_request import send_request | ||
|
||
def check_api_key(args): | ||
""" | ||
main entry point | ||
""" | ||
|
||
data = { | ||
"api_key": str(args.api_key), | ||
"user": str(args.user), | ||
"data_id": str(args.data_id) | ||
} | ||
|
||
result = send_request(args.api_url, data) | ||
|
||
gc.collect() | ||
|
||
print(result) | ||
|
||
if __name__ == "__main__": | ||
""" | ||
Form command lines | ||
""" | ||
# Clean up buffer memory | ||
gc.collect() | ||
|
||
user = "user@gmail.com" | ||
api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" | ||
data_id = "" | ||
api_url = "http://localhost:8000/check_api" | ||
|
||
# Add options | ||
p = argparse.ArgumentParser() | ||
p = argparse.ArgumentParser(description="Translate text within an image.") | ||
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="payload directory to the test example") | ||
p.add_argument("--user", type=str, default=user, help="user") | ||
p.add_argument("--api_key", type=str, default=api_key, help="api key") | ||
args = p.parse_args() | ||
|
||
check_api_key(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import gc | ||
import argparse | ||
|
||
from send_request import send_request | ||
|
||
def create_api_key(args): | ||
""" | ||
main entry point | ||
""" | ||
|
||
data = { | ||
"user": str(args.user), | ||
"title": str(args.title), | ||
"description": str(args.description), | ||
"data_id": str(args.data_id) | ||
} | ||
|
||
result = send_request(args.api_url, data) | ||
|
||
gc.collect() | ||
|
||
print(result) | ||
|
||
if __name__ == "__main__": | ||
""" | ||
Form command lines | ||
""" | ||
# Clean up buffer memory | ||
gc.collect() | ||
|
||
user = "user@gmail.com" | ||
title = "title" | ||
description = "description" | ||
data_id = "" | ||
api_url = "http://localhost:8000/create_api" | ||
|
||
# Add options | ||
p = argparse.ArgumentParser() | ||
p = argparse.ArgumentParser(description="Translate text within an image.") | ||
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="payload directory to the test example") | ||
p.add_argument("--user", type=str, default=user, help="user") | ||
p.add_argument("--title", type=str, default=title, help="title") | ||
p.add_argument("--description", type=str, default=description, help="title") | ||
args = p.parse_args() | ||
|
||
create_api_key(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import gc | ||
import argparse | ||
|
||
from send_request import send_request | ||
|
||
def delete_api_key(args): | ||
""" | ||
main entry point | ||
""" | ||
|
||
data = { | ||
"api_key": str(args.api_key), | ||
"user": str(args.user), | ||
"data_id": str(args.data_id) | ||
} | ||
|
||
result = send_request(args.api_url, data) | ||
|
||
gc.collect() | ||
|
||
print(result) | ||
|
||
if __name__ == "__main__": | ||
""" | ||
Form command lines | ||
""" | ||
# Clean up buffer memory | ||
gc.collect() | ||
|
||
user = "user@gmail.com" | ||
api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" | ||
data_id = "" | ||
api_url = "http://localhost:8000/delete_api" | ||
|
||
# Add options | ||
p = argparse.ArgumentParser() | ||
p = argparse.ArgumentParser(description="Translate text within an image.") | ||
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="payload directory to the test example") | ||
p.add_argument("--user", type=str, default=user, help="user") | ||
p.add_argument("--api_key", type=str, default=api_key, help="api key") | ||
args = p.parse_args() | ||
|
||
|
||
delete_api_key(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import gc | ||
import argparse | ||
|
||
from send_request import send_request | ||
|
||
def run_fine_tuning(args): | ||
""" | ||
main entry point | ||
""" | ||
|
||
data = { | ||
"api_key": str(args.api_key), | ||
"user": str(args.user), | ||
"data_id": str(args.data_id) | ||
} | ||
|
||
result = send_request(args.api_url, data) | ||
|
||
gc.collect() | ||
|
||
print(result) | ||
|
||
if __name__ == "__main__": | ||
""" | ||
Form command lines | ||
""" | ||
# Clean up buffer memory | ||
gc.collect() | ||
|
||
user = "user@gmail.com" | ||
api_key = "AMEYbpdcmrUxNu_Fb80qutukUZdlsmYiH4g7As5LzNA" | ||
data_id = "" | ||
api_url = "http://localhost:8000/finetuning" | ||
|
||
# Add options | ||
p = argparse.ArgumentParser() | ||
p = argparse.ArgumentParser(description="Translate text within an image.") | ||
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="payload directory to the test example") | ||
p.add_argument("--user", type=str, default=user, help="user") | ||
p.add_argument("--api_key", type=str, default=api_key, help="api key") | ||
args = p.parse_args() | ||
|
||
run_fine_tuning(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import requests | ||
import json | ||
import os | ||
|
||
def send_request(api_url, data): | ||
"""Sends a POST request to the specified URL with the provided data.""" | ||
headers = { | ||
'accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
} | ||
|
||
try: | ||
# Convert WindowsPath to string in the data dictionary | ||
data = {key: str(val) if isinstance(val, os.PathLike) else val for key, val in data.items()} | ||
|
||
response = requests.post(api_url, headers=headers, data=json.dumps(data)) | ||
if response.status_code == 200: | ||
return response.json() | ||
else: | ||
raise Exception(f"Request failed with status code: {response.status_code}") | ||
except Exception as e: | ||
raise Exception(f"An error occurred while sending the request: {e}") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.