Spaces:
Running
on
Zero
Running
on
Zero
te
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- mysite/gradio/gradio_config.py +1 -1
- routers/ai/--junit-xml=report.xml +0 -1
- routers/ai/.clasp.json +0 -4
- routers/ai/.claspignore +0 -1
- routers/ai/.github/workflows/ci.yml +0 -19
- routers/ai/.gitignore +0 -1
- routers/ai/.gpteng/memory/logs/all_output.txt +0 -0
- routers/ai/.gpteng/memory/logs/gen_entrypoint_chat.txt +0 -0
- routers/ai/200 +0 -1
- routers/ai/@enduml +0 -1
- routers/ai/App.gs +0 -7
- routers/ai/Document.txt +0 -33
- routers/ai/Drive.gs +0 -15
- routers/ai/Line.gs +0 -19
- routers/ai/LineAPI.gs +0 -112
- routers/ai/LineData.gs +0 -20
- routers/ai/Main.gs +0 -10
- routers/ai/README.md +0 -22
- routers/ai/Readme.md +0 -5
- routers/ai/S3.gs +0 -26
- routers/ai/Script +0 -1
- routers/ai/Structure +0 -11
- routers/ai/True +0 -1
- routers/ai/admin.py +0 -4
- routers/ai/admin.site.register(Product) +0 -1
- routers/ai/ai_system/__init__.py +0 -1
- routers/ai/ai_system/ai_system.py +0 -10
- routers/ai/app.py +0 -79
- routers/ai/app/Http/Controllers/BookController.php +0 -106
- routers/ai/app/Models/Book.php +0 -14
- routers/ai/app/__init__.py +0 -1
- routers/ai/app/app.py +0 -12
- routers/ai/app/crud.py +0 -35
- routers/ai/app/models.py +0 -14
- routers/ai/app/models/__init__.py +0 -1
- routers/ai/app/models/page.py +0 -6
- routers/ai/app/models/user.py +0 -14
- routers/ai/app/settings.py +0 -10
- routers/ai/app/templates/base.html +0 -14
- routers/ai/app/templates/index.html +0 -9
- routers/ai/app/tests/test_models.py +0 -9
- routers/ai/app/tests/test_views.py +0 -8
- routers/ai/app/views.py +0 -6
- routers/ai/app/wsgi.py +0 -6
- routers/ai/appsscript.json +0 -10
- routers/ai/aws_lambda_sam_template.yaml +0 -1
- routers/ai/backend/fastapi_app.py +0 -13
- routers/ai/clasp.json +0 -4
- routers/ai/command +0 -2
- routers/ai/composer.json +0 -59
mysite/gradio/gradio_config.py
CHANGED
@@ -50,7 +50,7 @@ def setup_gradio_interfaces():
|
|
50 |
)
|
51 |
|
52 |
default_interfaces = [democs]#,demo]
|
53 |
-
default_names = ["仕様書から作成","
|
54 |
|
55 |
gradio_interfaces, gradio_names = include_gradio_interfaces()
|
56 |
|
|
|
50 |
)
|
51 |
|
52 |
default_interfaces = [democs]#,demo]
|
53 |
+
default_names = ["仕様書から作成","Chat","OpenInterpreter","DataBase"]#"demo"]
|
54 |
|
55 |
gradio_interfaces, gradio_names = include_gradio_interfaces()
|
56 |
|
routers/ai/--junit-xml=report.xml
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
**tests/test_gradio_interface.py**
|
|
|
|
routers/ai/.clasp.json
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"scriptId": "YOUR_SCRIPT_ID",
|
3 |
-
"rootDir": "src/"
|
4 |
-
}
|
|
|
|
|
|
|
|
|
|
routers/ai/.claspignore
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
node_modules/
|
|
|
|
routers/ai/.github/workflows/ci.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
name: CI
|
2 |
-
|
3 |
-
on:
|
4 |
-
push:
|
5 |
-
branches:
|
6 |
-
- main
|
7 |
-
|
8 |
-
jobs:
|
9 |
-
build-and-test:
|
10 |
-
runs-on: ubuntu-latest
|
11 |
-
steps:
|
12 |
-
- name: Checkout code
|
13 |
-
uses: actions/checkout@v2
|
14 |
-
- name: Install dependencies
|
15 |
-
run: npm install
|
16 |
-
- name: Run tests
|
17 |
-
run: npm run test
|
18 |
-
- name: Deploy to Google Apps Script
|
19 |
-
run: npm run deploy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
node_modules
|
|
|
|
routers/ai/.gpteng/memory/logs/all_output.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
routers/ai/.gpteng/memory/logs/gen_entrypoint_chat.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
routers/ai/200
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
**aws_lambda/template.yaml**
|
|
|
|
routers/ai/@enduml
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
**gradio_interface.py**
|
|
|
|
routers/ai/App.gs
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* App script entry point
|
3 |
-
*/
|
4 |
-
function doGet() {
|
5 |
-
var app = HtmlService.createHtmlOutputFromFile('index');
|
6 |
-
return app;
|
7 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/Document.txt
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
Project: Google Lens Development with Python
|
2 |
-
|
3 |
-
Overview:
|
4 |
-
The project aims to develop a Google Lens application using Python, Django, and FastAPI. The application will have a frontend built with Gradio and a backend built with FastAPI. The project will also include testing with Pytest and logging with Django models.
|
5 |
-
|
6 |
-
Requirements:
|
7 |
-
|
8 |
-
* Create a Gradio interface for the frontend
|
9 |
-
* Develop a FastAPI backend for data retrieval from Google Lens
|
10 |
-
* Integrate Django for logging and data storage
|
11 |
-
* Create a Django admin interface for data verification
|
12 |
-
* Implement testing with Pytest
|
13 |
-
* Use Mock for testing data
|
14 |
-
* Create a Readme.md file with design documentation
|
15 |
-
* Include a PlantUML sequence diagram in the Readme.md file
|
16 |
-
* Create a settings.py file for Django
|
17 |
-
* Create a migration command for Django
|
18 |
-
* Create an AWS Lambda SAM template for deployment
|
19 |
-
* Create a SAM local command for automatic deployment to AWS
|
20 |
-
|
21 |
-
Files and Folders:
|
22 |
-
|
23 |
-
* frontend/gradio_interface.py
|
24 |
-
* backend/fastapi_app.py
|
25 |
-
* models/django_models.py
|
26 |
-
* tests/test_fastapi.py
|
27 |
-
* tests/test_gradio.py
|
28 |
-
* Readme.md
|
29 |
-
* settings.py
|
30 |
-
* requirements.txt
|
31 |
-
* aws_lambda_sam_template.yaml
|
32 |
-
* sam_local_command.sh
|
33 |
-
* __init__.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/Drive.gs
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Google Drive client
|
3 |
-
*/
|
4 |
-
class Drive {
|
5 |
-
/**
|
6 |
-
* Save image to Google Drive
|
7 |
-
* @param {Blob} image Image blob
|
8 |
-
* @return {string} File ID of the saved image
|
9 |
-
*/
|
10 |
-
static saveImage(image) {
|
11 |
-
var folder = DriveApp.getFolderById(CONFIG.DRIVE_FOLDER_ID);
|
12 |
-
var file = folder.createFile(image);
|
13 |
-
return file.getId();
|
14 |
-
}
|
15 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/Line.gs
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Line API client
|
3 |
-
*/
|
4 |
-
class Line {
|
5 |
-
/**
|
6 |
-
* Get data from Line API
|
7 |
-
* @return {object} Data from Line API
|
8 |
-
*/
|
9 |
-
static getData() {
|
10 |
-
var options = {
|
11 |
-
"method": "GET",
|
12 |
-
"headers": {
|
13 |
-
"Authorization": "Bearer " + CONFIG.LINE_ACCESS_TOKEN
|
14 |
-
}
|
15 |
-
};
|
16 |
-
var response = UrlFetch.fetch("https://api.line.me/v2/profile", options);
|
17 |
-
return JSON.parse(response.getContentText());
|
18 |
-
}
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/LineAPI.gs
DELETED
@@ -1,112 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Line API class
|
3 |
-
*/
|
4 |
-
class LineAPI {
|
5 |
-
/**
|
6 |
-
* Get access token from Line
|
7 |
-
* @return {string} access token
|
8 |
-
*/
|
9 |
-
function getAccessToken() {
|
10 |
-
var clientId = 'YOUR_CLIENT_ID';
|
11 |
-
var clientSecret = 'YOUR_CLIENT_SECRET';
|
12 |
-
var redirectUri = 'YOUR_REDIRECT_URI';
|
13 |
-
var scope = 'profile openid email';
|
14 |
-
var authUrl = 'https://access.line.me/oauth2/v2.1/authorize';
|
15 |
-
var tokenUrl = 'https://api.line.me/oauth2/v2.1/token';
|
16 |
-
|
17 |
-
var authCode = getAuthCode_(authUrl, clientId, redirectUri, scope);
|
18 |
-
var tokenResponse = getToken_(tokenUrl, clientId, clientSecret, authCode);
|
19 |
-
var accessToken = tokenResponse.access_token;
|
20 |
-
return accessToken;
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Get user profile from Line
|
25 |
-
* @param {string} accessToken
|
26 |
-
* @return {object} user profile
|
27 |
-
*/
|
28 |
-
function getUserProfile(accessToken) {
|
29 |
-
var apiUrl = 'https://api.line.me/v2/profile';
|
30 |
-
var headers = {
|
31 |
-
'Authorization': 'Bearer ' + accessToken
|
32 |
-
};
|
33 |
-
var options = {
|
34 |
-
'method': 'GET',
|
35 |
-
'headers': headers
|
36 |
-
};
|
37 |
-
var response = UrlFetchApp.fetch(apiUrl, options);
|
38 |
-
var userProfile = JSON.parse(response.getContentText());
|
39 |
-
return userProfile;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Get auth code from Line
|
44 |
-
* @param {string} authUrl
|
45 |
-
* @param {string} clientId
|
46 |
-
* @param {string} redirectUri
|
47 |
-
* @param {string} scope
|
48 |
-
* @return {string} auth code
|
49 |
-
*/
|
50 |
-
function getAuthCode_(authUrl, clientId, redirectUri, scope) {
|
51 |
-
var authUrlParams = {
|
52 |
-
'response_type': 'code',
|
53 |
-
'client_id': clientId,
|
54 |
-
'redirect_uri': redirectUri,
|
55 |
-
'scope': scope
|
56 |
-
};
|
57 |
-
var authUrlWithParams = authUrl + '?' + encodeURI(serializeParams_(authUrlParams));
|
58 |
-
var authCode = promptUser_(authUrlWithParams);
|
59 |
-
return authCode;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Get token from Line
|
64 |
-
* @param {string} tokenUrl
|
65 |
-
* @param {string} clientId
|
66 |
-
* @param {string} clientSecret
|
67 |
-
* @param {string} authCode
|
68 |
-
* @return {object} token response
|
69 |
-
*/
|
70 |
-
function getToken_(tokenUrl, clientId, clientSecret, authCode) {
|
71 |
-
var tokenUrlParams = {
|
72 |
-
'grant_type': 'authorization_code',
|
73 |
-
'code': authCode,
|
74 |
-
'redirect_uri': 'YOUR_REDIRECT_URI',
|
75 |
-
'client_id': clientId,
|
76 |
-
'client_secret': clientSecret
|
77 |
-
};
|
78 |
-
var options = {
|
79 |
-
'method': 'POST',
|
80 |
-
'headers': {
|
81 |
-
'Content-Type': 'application/x-www-form-urlencoded'
|
82 |
-
},
|
83 |
-
'payload': serializeParams_(tokenUrlParams)
|
84 |
-
};
|
85 |
-
var response = UrlFetchApp.fetch(tokenUrl, options);
|
86 |
-
var tokenResponse = JSON.parse(response.getContentText());
|
87 |
-
return tokenResponse;
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Serialize parameters to URL query string
|
92 |
-
* @param {object} params
|
93 |
-
* @return {string} serialized parameters
|
94 |
-
*/
|
95 |
-
function serializeParams_(params) {
|
96 |
-
var paramsArray = [];
|
97 |
-
for (var key in params) {
|
98 |
-
paramsArray.push(key + '=' + encodeURIComponent(params[key]));
|
99 |
-
}
|
100 |
-
return paramsArray.join('&');
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Prompt user to authorize
|
105 |
-
* @param {string} authUrl
|
106 |
-
* @return {string} auth code
|
107 |
-
*/
|
108 |
-
function promptUser_(authUrl) {
|
109 |
-
var authCode = prompt('Please authorize and enter the auth code:', authUrl);
|
110 |
-
return authCode;
|
111 |
-
}
|
112 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/LineData.gs
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Line data class
|
3 |
-
*/
|
4 |
-
class LineData {
|
5 |
-
/**
|
6 |
-
* Get user data from Line
|
7 |
-
* @param {string} accessToken
|
8 |
-
* @return {object} user data
|
9 |
-
*/
|
10 |
-
function getUserData(accessToken) {
|
11 |
-
var lineAPI = new LineAPI();
|
12 |
-
var userProfile = lineAPI.getUserProfile(accessToken);
|
13 |
-
var userData = {
|
14 |
-
'displayName': userProfile.displayName,
|
15 |
-
'userId': userProfile.userId,
|
16 |
-
'pictureUrl': userProfile.pictureUrl
|
17 |
-
};
|
18 |
-
return userData;
|
19 |
-
}
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/Main.gs
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Main entry point
|
3 |
-
*/
|
4 |
-
function main() {
|
5 |
-
var lineAPI = new LineAPI();
|
6 |
-
var accessToken = lineAPI.getAccessToken();
|
7 |
-
var lineData = new LineData();
|
8 |
-
var userData = lineData.getUserData(accessToken);
|
9 |
-
Logger.log(userData);
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/README.md
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
# Google Apps Script Image Downloader
|
2 |
-
|
3 |
-
This script retrieves data from a Google Sheets line, downloads images, and saves them to Google Drive.
|
4 |
-
|
5 |
-
## Requirements
|
6 |
-
|
7 |
-
* Google Apps Script
|
8 |
-
* Google Sheets
|
9 |
-
* Google Drive
|
10 |
-
|
11 |
-
## Setup
|
12 |
-
|
13 |
-
1. Create a new Google Apps Script project.
|
14 |
-
2. Create a new Google Sheets document and add the data to be retrieved.
|
15 |
-
3. Create a new Google Drive folder to save the images.
|
16 |
-
4. Install the required dependencies using npm.
|
17 |
-
5. Run the script using the `retrieveDataFromLine` function.
|
18 |
-
|
19 |
-
## Testing
|
20 |
-
|
21 |
-
1. Create a new Jupyter Notebook and add the test code.
|
22 |
-
2. Run the test code to verify that the images are saved to Google Drive.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/Readme.md
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
# Google Lens Development with Python
|
2 |
-
|
3 |
-
## Design
|
4 |
-
|
5 |
-
### Sequence Diagram
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/S3.gs
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Amazon S3 client
|
3 |
-
*/
|
4 |
-
class S3 {
|
5 |
-
/**
|
6 |
-
* Upload file to S3
|
7 |
-
* @param {string} fileID File ID of the image in Google Drive
|
8 |
-
* @return {string} URL of the uploaded file
|
9 |
-
*/
|
10 |
-
static uploadFile(fileID) {
|
11 |
-
var file = DriveApp.getFileById(fileID);
|
12 |
-
var blob = file.getBlob();
|
13 |
-
var s3 = Aws.S3({
|
14 |
-
accessKeyId: CONFIG.S3_ACCESS_KEY_ID,
|
15 |
-
secretAccessKey: CONFIG.S3_SECRET_ACCESS_KEY,
|
16 |
-
region: CONFIG.S3_REGION
|
17 |
-
});
|
18 |
-
var params = {
|
19 |
-
Bucket: CONFIG.S3_BUCKET_NAME,
|
20 |
-
Key: file.getName(),
|
21 |
-
Body: blob
|
22 |
-
};
|
23 |
-
var data = s3.upload(params).promise();
|
24 |
-
return data.Location;
|
25 |
-
}
|
26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/Script
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
npm run deploy
|
|
|
|
routers/ai/Structure
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
project/
|
2 |
-
app/
|
3 |
-
__init__.py
|
4 |
-
app.py
|
5 |
-
models/
|
6 |
-
__init__.py
|
7 |
-
page.py
|
8 |
-
templates/
|
9 |
-
base.html
|
10 |
-
index.html
|
11 |
-
requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/True
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
**models.py**
|
|
|
|
routers/ai/admin.py
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
from django.contrib import admin
|
2 |
-
from .models import DataModel
|
3 |
-
|
4 |
-
admin.site.register(DataModel)
|
|
|
|
|
|
|
|
|
|
routers/ai/admin.site.register(Product)
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
**google_lens_api.py**
|
|
|
|
routers/ai/ai_system/__init__.py
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
# empty file
|
|
|
|
routers/ai/ai_system/ai_system.py
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
from dataclasses import dataclass
|
2 |
-
from models.error_model import ErrorModel
|
3 |
-
|
4 |
-
@dataclass
|
5 |
-
class AISystem:
|
6 |
-
error_model: ErrorModel
|
7 |
-
|
8 |
-
def process_error(self, error: Error):
|
9 |
-
# Use the AI model to process the error
|
10 |
-
self.error_model.process_error(error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app.py
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import duckdb
|
3 |
-
|
4 |
-
# Initialize DuckDB connection
|
5 |
-
conn = duckdb.connect(database=':memory:')
|
6 |
-
|
7 |
-
# Create a table for products
|
8 |
-
conn.execute('CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT, price REAL)')
|
9 |
-
|
10 |
-
# Load sample data from a CSV file
|
11 |
-
conn.execute('INSERT INTO products (name, price) VALUES ("Product 1", 10.99), ("Product 2", 9.99), ("Product 3", 12.99)')
|
12 |
-
|
13 |
-
# Define a function to read all products
|
14 |
-
def read_products():
|
15 |
-
cursor = conn.execute('SELECT * FROM products')
|
16 |
-
return cursor.fetchall()
|
17 |
-
|
18 |
-
# Define a function to create a new product
|
19 |
-
def create_product(name, price):
|
20 |
-
conn.execute('INSERT INTO products (name, price) VALUES (?, ?)', (name, price))
|
21 |
-
conn.commit()
|
22 |
-
|
23 |
-
# Define a function to update a product
|
24 |
-
def update_product(id, name, price):
|
25 |
-
conn.execute('UPDATE products SET name = ?, price = ? WHERE id = ?', (name, price, id))
|
26 |
-
conn.commit()
|
27 |
-
|
28 |
-
# Define a function to delete a product
|
29 |
-
def delete_product(id):
|
30 |
-
conn.execute('DELETE FROM products WHERE id = ?', (id,))
|
31 |
-
conn.commit()
|
32 |
-
|
33 |
-
# Create a Gradio interface
|
34 |
-
with gr.Blocks() as demo:
|
35 |
-
gr.Markdown("CRUD Interface for Products")
|
36 |
-
|
37 |
-
# Create a text input for product name
|
38 |
-
name_input = gr.Textbox(label="Product Name")
|
39 |
-
|
40 |
-
# Create a number input for product price
|
41 |
-
price_input = gr.Number(label="Product Price")
|
42 |
-
|
43 |
-
# Create a button to create a new product
|
44 |
-
create_button = gr.Button("Create Product")
|
45 |
-
|
46 |
-
# Create a button to update a product
|
47 |
-
update_button = gr.Button("Update Product")
|
48 |
-
|
49 |
-
# Create a button to delete a product
|
50 |
-
delete_button = gr.Button("Delete Product")
|
51 |
-
|
52 |
-
# Create a data frame to display products
|
53 |
-
products_df = gr.DataFrame(label="Products")
|
54 |
-
|
55 |
-
# Define the create product function
|
56 |
-
def create_product_callback(name, price):
|
57 |
-
create_product(name, price)
|
58 |
-
return read_products()
|
59 |
-
|
60 |
-
# Define the update product function
|
61 |
-
def update_product_callback(id, name, price):
|
62 |
-
update_product(id, name, price)
|
63 |
-
return read_products()
|
64 |
-
|
65 |
-
# Define the delete product function
|
66 |
-
def delete_product_callback(id):
|
67 |
-
delete_product(id)
|
68 |
-
return read_products()
|
69 |
-
|
70 |
-
# Create a Gradio interface
|
71 |
-
create_button.click(fn=create_product_callback, inputs=[name_input, price_input], outputs=products_df)
|
72 |
-
update_button.click(fn=update_product_callback, inputs=[gr.Textbox(label="Product ID"), name_input, price_input], outputs=products_df)
|
73 |
-
delete_button.click(fn=delete_product_callback, inputs=[gr.Textbox(label="Product ID")], outputs=products_df)
|
74 |
-
|
75 |
-
# Display the products data frame
|
76 |
-
products_df.render()
|
77 |
-
|
78 |
-
# Launch the Gradio interface
|
79 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/Http/Controllers/BookController.php
DELETED
@@ -1,106 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace App\Http\Controllers;
|
4 |
-
|
5 |
-
use Illuminate\Http\Request;
|
6 |
-
use App\Models\Book;
|
7 |
-
|
8 |
-
class BookController extends Controller
|
9 |
-
{
|
10 |
-
/**
|
11 |
-
* Display a listing of the resource.
|
12 |
-
*
|
13 |
-
* @return \Illuminate\Http\Response
|
14 |
-
*/
|
15 |
-
public function index()
|
16 |
-
{
|
17 |
-
$books = Book::all();
|
18 |
-
return view('books.index', compact('books'));
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Show the form for creating a new resource.
|
23 |
-
*
|
24 |
-
* @return \Illuminate\Http\Response
|
25 |
-
*/
|
26 |
-
public function create()
|
27 |
-
{
|
28 |
-
return view('books.create');
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Store a newly created resource in storage.
|
33 |
-
*
|
34 |
-
* @param \Illuminate\Http\Request $request
|
35 |
-
* @return \Illuminate\Http\Response
|
36 |
-
*/
|
37 |
-
public function store(Request $request)
|
38 |
-
{
|
39 |
-
$request->validate([
|
40 |
-
'title' => 'required',
|
41 |
-
'author' => 'required',
|
42 |
-
'published_at' => 'required',
|
43 |
-
]);
|
44 |
-
|
45 |
-
Book::create($request->all());
|
46 |
-
|
47 |
-
return redirect()->route('books.index');
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Display the specified resource.
|
52 |
-
*
|
53 |
-
* @param int $id
|
54 |
-
* @return \Illuminate\Http\Response
|
55 |
-
*/
|
56 |
-
public function show($id)
|
57 |
-
{
|
58 |
-
$book = Book::find($id);
|
59 |
-
return view('books.show', compact('book'));
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Show the form for editing the specified resource.
|
64 |
-
*
|
65 |
-
* @param int $id
|
66 |
-
* @return \Illuminate\Http\Response
|
67 |
-
*/
|
68 |
-
public function edit($id)
|
69 |
-
{
|
70 |
-
$book = Book::find($id);
|
71 |
-
return view('books.edit', compact('book'));
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Update the specified resource in storage.
|
76 |
-
*
|
77 |
-
* @param \Illuminate\Http\Request $request
|
78 |
-
* @param int $id
|
79 |
-
* @return \Illuminate\Http\Response
|
80 |
-
*/
|
81 |
-
public function update(Request $request, $id)
|
82 |
-
{
|
83 |
-
$request->validate([
|
84 |
-
'title' => 'required',
|
85 |
-
'author' => 'required',
|
86 |
-
'published_at' => 'required',
|
87 |
-
]);
|
88 |
-
|
89 |
-
$book = Book::find($id);
|
90 |
-
$book->update($request->all());
|
91 |
-
|
92 |
-
return redirect()->route('books.index');
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Remove the specified resource from storage.
|
97 |
-
*
|
98 |
-
* @param int $id
|
99 |
-
* @return \Illuminate\Http\Response
|
100 |
-
*/
|
101 |
-
public function destroy($id)
|
102 |
-
{
|
103 |
-
Book::destroy($id);
|
104 |
-
return redirect()->route('books.index');
|
105 |
-
}
|
106 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/Models/Book.php
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace App\Models;
|
4 |
-
|
5 |
-
use Illuminate\Database\Eloquent\Model;
|
6 |
-
|
7 |
-
class Book extends Model
|
8 |
-
{
|
9 |
-
protected $fillable = [
|
10 |
-
'title',
|
11 |
-
'author',
|
12 |
-
'published_at',
|
13 |
-
];
|
14 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/__init__.py
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
# empty file
|
|
|
|
routers/ai/app/app.py
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
from flask import Flask, render_template
|
2 |
-
from app.models.page import Page
|
3 |
-
|
4 |
-
app = Flask(__name__)
|
5 |
-
|
6 |
-
@app.route("/")
|
7 |
-
def index():
|
8 |
-
page = Page("Sample Page", "This is a sample page.")
|
9 |
-
return render_template("index.html", page=page)
|
10 |
-
|
11 |
-
if __name__ == "__main__":
|
12 |
-
app.run(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/crud.py
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
from sqlalchemy.orm import sessionmaker
|
2 |
-
from .models import Base, User
|
3 |
-
|
4 |
-
class CRUD:
|
5 |
-
def __init__(self, db_url):
|
6 |
-
self.engine = create_engine(db_url)
|
7 |
-
Base.metadata.create_all(self.engine)
|
8 |
-
self.Session = sessionmaker(bind=self.engine)
|
9 |
-
self.session = self.Session()
|
10 |
-
|
11 |
-
def create_user(self, name, email):
|
12 |
-
user = User(name=name, email=email)
|
13 |
-
self.session.add(user)
|
14 |
-
self.session.commit()
|
15 |
-
return user
|
16 |
-
|
17 |
-
def read_user(self, user_id):
|
18 |
-
return self.session.query(User).get(user_id)
|
19 |
-
|
20 |
-
def update_user(self, user_id, name, email):
|
21 |
-
user = self.read_user(user_id)
|
22 |
-
if user:
|
23 |
-
user.name = name
|
24 |
-
user.email = email
|
25 |
-
self.session.commit()
|
26 |
-
return user
|
27 |
-
return None
|
28 |
-
|
29 |
-
def delete_user(self, user_id):
|
30 |
-
user = self.read_user(user_id)
|
31 |
-
if user:
|
32 |
-
self.session.delete(user)
|
33 |
-
self.session.commit()
|
34 |
-
return True
|
35 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/models.py
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
from sqlalchemy import Column, Integer, String
|
2 |
-
from sqlalchemy.ext.declarative import declarative_base
|
3 |
-
from sqlalchemy import create_engine
|
4 |
-
|
5 |
-
Base = declarative_base()
|
6 |
-
|
7 |
-
class User(Base):
|
8 |
-
__tablename__ = 'users'
|
9 |
-
id = Column(Integer, primary_key=True)
|
10 |
-
name = Column(String)
|
11 |
-
email = Column(String)
|
12 |
-
|
13 |
-
def __repr__(self):
|
14 |
-
return f"User(id={self.id}, name='{self.name}', email='{self.email}')"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/models/__init__.py
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
# empty file
|
|
|
|
routers/ai/app/models/page.py
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
from dataclasses import dataclass
|
2 |
-
|
3 |
-
@dataclass
|
4 |
-
class Page:
|
5 |
-
title: str
|
6 |
-
content: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/models/user.py
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
from sqlalchemy import Column, Integer, String
|
2 |
-
from sqlalchemy.ext.declarative import declarative_base
|
3 |
-
|
4 |
-
Base = declarative_base()
|
5 |
-
|
6 |
-
class User(Base):
|
7 |
-
__tablename__ = 'users'
|
8 |
-
|
9 |
-
id = Column(Integer, primary_key=True)
|
10 |
-
name = Column(String)
|
11 |
-
email = Column(String)
|
12 |
-
|
13 |
-
def __repr__(self):
|
14 |
-
return f"User(id={self.id}, name='{self.name}', email='{self.email}')"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/settings.py
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
DATABASES = {
|
2 |
-
'default': {
|
3 |
-
'ENGINE': 'django.db.backends.postgresql',
|
4 |
-
'NAME': 'mydatabase',
|
5 |
-
'USER': 'mydatabaseuser',
|
6 |
-
'PASSWORD': 'mypassword',
|
7 |
-
'HOST': 'localhost',
|
8 |
-
'PORT': '5432',
|
9 |
-
}
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/templates/base.html
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html>
|
3 |
-
<head>
|
4 |
-
<title>{% block title %}{% endblock %}</title>
|
5 |
-
</head>
|
6 |
-
<body>
|
7 |
-
<header>
|
8 |
-
<h1>{% block header %}{% endblock %}</h1>
|
9 |
-
</header>
|
10 |
-
<main>
|
11 |
-
{% block content %}{% endblock %}
|
12 |
-
</main>
|
13 |
-
</body>
|
14 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/templates/index.html
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
{% extends "base.html" %}
|
2 |
-
|
3 |
-
{% block title %}{{ page.title }}{% endblock %}
|
4 |
-
|
5 |
-
{% block header %}{{ page.title }}{% endblock %}
|
6 |
-
|
7 |
-
{% block content %}
|
8 |
-
<p>{{ page.content }}</p>
|
9 |
-
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/tests/test_models.py
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
import pytest
|
2 |
-
from app.models import User
|
3 |
-
|
4 |
-
@pytest.fixture
|
5 |
-
def user():
|
6 |
-
return User(name='John Doe', email='[email protected]')
|
7 |
-
|
8 |
-
def test_user_repr(user):
|
9 |
-
assert user.__repr__() == "User(id=None, name='John Doe', email='[email protected]')"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/tests/test_views.py
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
import pytest
|
2 |
-
from django.test import TestCase
|
3 |
-
from app.views import user_list
|
4 |
-
|
5 |
-
class TestViews(TestCase):
|
6 |
-
def test_user_list(self):
|
7 |
-
response = self.client.get('/users/')
|
8 |
-
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/views.py
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
from django.shortcuts import render
|
2 |
-
from .models import User
|
3 |
-
|
4 |
-
def user_list(request):
|
5 |
-
users = User.query.all()
|
6 |
-
return render(request, 'user_list.html', {'users': users})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/app/wsgi.py
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
from django.core.wsgi import get_wsgi_application
|
3 |
-
|
4 |
-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
|
5 |
-
|
6 |
-
application = get_wsgi_application()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/appsscript.json
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"timeZone": "Asia/Tokyo",
|
3 |
-
"dependencies": {
|
4 |
-
"enabledAdvancedServices": [
|
5 |
-
{
|
6 |
-
"userSymbol": "LineAPI"
|
7 |
-
}
|
8 |
-
]
|
9 |
-
}
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/aws_lambda_sam_template.yaml
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
### SAM Local Command
|
|
|
|
routers/ai/backend/fastapi_app.py
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
from fastapi import FastAPI
|
2 |
-
from pydantic import BaseModel
|
3 |
-
|
4 |
-
app = FastAPI()
|
5 |
-
|
6 |
-
class GoogleLensData(BaseModel):
|
7 |
-
image_url: str
|
8 |
-
data: str
|
9 |
-
|
10 |
-
@app.get("/google-lens-data")
|
11 |
-
async def get_google_lens_data():
|
12 |
-
# Implement data retrieval from Google Lens
|
13 |
-
return {"data": "Google Lens data"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
routers/ai/clasp.json
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"scriptId": "YOUR_SCRIPT_ID",
|
3 |
-
"rootDir": "src/"
|
4 |
-
}
|
|
|
|
|
|
|
|
|
|
routers/ai/command
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
sam build
|
2 |
-
sam deploy --guided
|
|
|
|
|
|
routers/ai/composer.json
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "laravel/laravel",
|
3 |
-
"description": "The Laravel Framework.",
|
4 |
-
"keywords": ["framework", "laravel"],
|
5 |
-
"license": "MIT",
|
6 |
-
"type": "project",
|
7 |
-
"require": {
|
8 |
-
"php": "^7.2.5",
|
9 |
-
"fideloper/proxy": "^4.2",
|
10 |
-
"fruitcake/laravel-cors": "^2.0",
|
11 |
-
"guzzlehttp/guzzle": "^7.0.1",
|
12 |
-
"laravel/framework": "^8.40",
|
13 |
-
"laravel/tinker": "^2.5"
|
14 |
-
},
|
15 |
-
"require-dev": {
|
16 |
-
"facade/ignition": "^2.5",
|
17 |
-
"fakerphp/faker": "^1.9.1",
|
18 |
-
"laravel/sail": "^1.0.1",
|
19 |
-
"mockery/mockery": "^1.4.2",
|
20 |
-
"nunomaduro/collision": "^5.0",
|
21 |
-
"phpunit/phpunit": "^9.3.3"
|
22 |
-
},
|
23 |
-
"config": {
|
24 |
-
"optimize-autoloader": true,
|
25 |
-
"preferred-install": "dist",
|
26 |
-
"sort-packages": true
|
27 |
-
},
|
28 |
-
"extra": {
|
29 |
-
"laravel": {
|
30 |
-
"dont-discover": []
|
31 |
-
}
|
32 |
-
},
|
33 |
-
"autoload": {
|
34 |
-
"psr-4": {
|
35 |
-
"App\\": "app/",
|
36 |
-
"Database\\Factories\\": "database/factories/",
|
37 |
-
"Database\\Seeders\\": "database/seeders/"
|
38 |
-
}
|
39 |
-
},
|
40 |
-
"autoload-dev": {
|
41 |
-
"psr-4": {
|
42 |
-
"Tests\\": "tests/"
|
43 |
-
}
|
44 |
-
},
|
45 |
-
"minimum-stability": "dev",
|
46 |
-
"prefer-stable": true,
|
47 |
-
"scripts": {
|
48 |
-
"post-autoload-dump": [
|
49 |
-
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
50 |
-
"@php artisan package:discover --ansi"
|
51 |
-
],
|
52 |
-
"post-root-package-install": [
|
53 |
-
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
54 |
-
],
|
55 |
-
"post-create-project-cmd": [
|
56 |
-
"@php artisan key:generate --ansi"
|
57 |
-
]
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|