Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
feat: script feature
Browse files Browse the repository at this point in the history
  • Loading branch information
eureka320 committed Mar 27, 2024
1 parent a6cf8cc commit 2826b32
Show file tree
Hide file tree
Showing 23 changed files with 351 additions and 15 deletions.
115 changes: 100 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,41 @@ py .\check_api_key.py --payload_dir="./test/regression/regression_testxxx/payloa
"collection_name": "apis"
}

### MongoDB Atlas Setting
- Create Account
Sign up with google signup or email.

- Get the environment data
![Alt text](./images/image-18.png)

![Alt text](./images/image-19.png)

![Alt text](./images/image-20.png)

![Alt text](./images/image-21.png)

![Alt text](./images/image-22.png)

Please save mongodb_username, mongodb_pasword and mongodb_cluster_name to your .env file.

- Update the password
![Alt text](./images/image-23.png)

![Alt text](./images/image-24.png)

![Alt text](./images/image-25.png)

![Alt text](./images/image-26.png)

Please update mongodb_password to your .env file.

- Create new User
![Alt text](./images/image-27.png)

![Alt text](./images/image-28.png)

Please save mongodb_username and mongodb_pasword to your .env file.

### AWS EC2

- Launch Instance
Expand Down Expand Up @@ -127,6 +162,7 @@ py .\check_api_key.py --payload_dir="./test/regression/regression_testxxx/payloa
![Alt text](./images/image-17.png)

### Project Setting
- Set the environment and run the project
```
sudo su
apt update
Expand Down Expand Up @@ -165,57 +201,106 @@ MONGODB_CLUSTER_NAME=
docker-compose up -d
```

- update the project and re-run
```
git pull origin dev
docker ps
docker stop container_id
docker rm container_id
docker-compose up -d
```

### done
host your elastic ip

http://{your elastic ip}:5000/create_api
POST
- Postman
![Alt text](./images/image-29.png)

- curl
```
{
curl -X 'POST' \
'http://18.118.73.220:5000/create_api' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"user": "",
"title": "",
"description": "",
"data_id": ""
}
}'
```

http://{your elastic ip}:5000/delete_api
POST
- Postman
![Alt text](./images/image-30.png)

- curl
```
{
curl -X 'POST' \
'http://18.118.73.220:5000/delete_api' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "",
"user": "",
"data_id": ""
}
}'
```

http://{your elastic ip}:5000/check_api
POST
- postman
![Alt text](./images/image-31.png)

- curl
```
{
curl -X 'POST' \
'http://18.118.73.220:5000/check_api' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "",
"user": "",
"data_id": ""
}
}'
```

http://{your elastic ip}:5000/finetuning
POST
- postman
![Alt text](./images/image-33.png)

- curl
```
{
curl -X 'POST' \
'http://18.118.73.220:5000/finetuning' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "",
"user": "",
"data_id": ""
}
}'
```

http://{your elastic ip}:5000/conversation
POST
- postman
![Alt text](./images/image-32.png)

- curl
```
{
curl -X 'POST' \
'http://18.118.73.220:5000/conversation' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "",
"user": "",
"data_id": "",
"question": "hi"
}
}'
```
Binary file added images/image-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image-33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions script/chatting.py
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)
44 changes: 44 additions & 0 deletions script/check_api_key.py
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)
47 changes: 47 additions & 0 deletions script/create_api_key.py
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)
45 changes: 45 additions & 0 deletions script/delete_api_key.py
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)
Loading

0 comments on commit 2826b32

Please sign in to comment.