* add endpoints for other languages

* added more languages

* update names

* rename langs
This commit is contained in:
Xiang Yan 2023-09-07 15:07:36 -07:00 коммит произвёл GitHub
Родитель 1d90c40a6d
Коммит 9e3e1ddbb0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 70 добавлений и 45 удалений

Просмотреть файл

@ -1,5 +1,16 @@
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
from src import review_python, review_java, review_cpp, review_go, review_js, review_net, review_c, review_swift, review_typespec from src import (
review_python,
review_java,
review_cpp,
review_golang,
review_typescript,
review_dotnet,
review_clang,
review_ios,
review_rest,
review_android,
)
app = Flask(__name__) app = Flask(__name__)
@ -17,18 +28,18 @@ def java_api_reviewer():
result = review_java(content) result = review_java(content)
return jsonify(result) return jsonify(result)
@app.route('/js', methods=['POST']) @app.route('/typescript', methods=['POST'])
def js_api_reviewer(): def typescript_api_reviewer():
data = request.get_json() data = request.get_json()
content = data['content'] content = data['content']
result = review_js(content) result = review_typescript(content)
return jsonify(result) return jsonify(result)
@app.route('/net', methods=['POST']) @app.route('/dotnet', methods=['POST'])
def net_api_reviewer(): def dotnet_api_reviewer():
data = request.get_json() data = request.get_json()
content = data['content'] content = data['content']
result = review_net(content) result = review_dotnet(content)
return jsonify(result) return jsonify(result)
@app.route('/cpp', methods=['POST']) @app.route('/cpp', methods=['POST'])
@ -38,30 +49,37 @@ def cpp_api_reviewer():
result = review_cpp(content) result = review_cpp(content)
return jsonify(result) return jsonify(result)
@app.route('/go', methods=['POST']) @app.route('/golang', methods=['POST'])
def go_api_reviewer(): def golang_api_reviewer():
data = request.get_json() data = request.get_json()
content = data['content'] content = data['content']
result = review_go(content) result = review_golang(content)
return jsonify(result) return jsonify(result)
@app.route('/c', methods=['POST']) @app.route('/clang', methods=['POST'])
def c_api_reviewer(): def clang_api_reviewer():
data = request.get_json() data = request.get_json()
content = data['content'] content = data['content']
result = review_c(content) result = review_clang(content)
return jsonify(result) return jsonify(result)
@app.route('/swift', methods=['POST']) @app.route('/ios', methods=['POST'])
def swift_api_reviewer(): def ios_api_reviewer():
data = request.get_json() data = request.get_json()
content = data['content'] content = data['content']
result = review_swift(content) result = review_ios(content)
return jsonify(result) return jsonify(result)
@app.route('/typespec', methods=['POST']) @app.route('/rest', methods=['POST'])
def typespec_api_reviewer(): def rest_api_reviewer():
data = request.get_json() data = request.get_json()
content = data['content'] content = data['content']
result = review_typespec(content) result = review_rest(content)
return jsonify(result)
@app.route('/android', methods=['POST'])
def android_api_reviewer():
data = request.get_json()
content = data['content']
result = review_android(content)
return jsonify(result) return jsonify(result)

Просмотреть файл

@ -5,13 +5,14 @@ from ._version import VERSION
from ._gpt_reviewer import GptReviewer from ._gpt_reviewer import GptReviewer
from ._python_api import review_python from ._python_api import review_python
from ._java_api import review_java from ._java_api import review_java
from ._js_api import review_js from ._typescript_api import review_typescript
from ._net_api import review_net from ._dotnet_api import review_dotnet
from ._cpp_api import review_cpp from ._cpp_api import review_cpp
from ._go_api import review_go from ._golang_api import review_golang
from ._c_api import review_c from ._clang_api import review_clang
from ._swift_api import review_swift from ._ios_api import review_ios
from ._typespec_api import review_typespec from ._rest_api import review_rest
from ._android_api import review_android
from ._vector_db import VectorDB from ._vector_db import VectorDB
from ._models import GuidelinesResult, Violation, VectorDocument, VectorSearchResult from ._models import GuidelinesResult, Violation, VectorDocument, VectorSearchResult

Просмотреть файл

@ -0,0 +1,6 @@
from ._gpt_reviewer import GptReviewer
def review_android(code):
reviewer = GptReviewer()
result = reviewer.get_response(code, "android")
return result.json()

Просмотреть файл

@ -1,6 +1,6 @@
from ._gpt_reviewer import GptReviewer from ._gpt_reviewer import GptReviewer
def review_js(code): def review_clang(code):
reviewer = GptReviewer() reviewer = GptReviewer()
result = reviewer.get_response(code, "js") result = reviewer.get_response(code, "clang")
return result.json() return result.json()

Просмотреть файл

@ -1,6 +1,6 @@
from ._gpt_reviewer import GptReviewer from ._gpt_reviewer import GptReviewer
def review_net(code): def review_dotnet(code):
reviewer = GptReviewer() reviewer = GptReviewer()
result = reviewer.get_response(code, "c#") result = reviewer.get_response(code, "dotnet")
return result.json() return result.json()

Просмотреть файл

@ -0,0 +1,6 @@
from ._gpt_reviewer import GptReviewer
def review_golang(code):
reviewer = GptReviewer()
result = reviewer.get_response(code, "golang")
return result.json()

Просмотреть файл

@ -1,6 +1,6 @@
from ._gpt_reviewer import GptReviewer from ._gpt_reviewer import GptReviewer
def review_c(code): def review_ios(code):
reviewer = GptReviewer() reviewer = GptReviewer()
result = reviewer.get_response(code, "c") result = reviewer.get_response(code, "ios")
return result.json() return result.json()

Просмотреть файл

@ -1,6 +1,6 @@
from ._gpt_reviewer import GptReviewer from ._gpt_reviewer import GptReviewer
def review_go(code): def review_rest(code):
reviewer = GptReviewer() reviewer = GptReviewer()
result = reviewer.get_response(code, "go") result = reviewer.get_response(code, "rest")
return result.json() return result.json()

Просмотреть файл

@ -1,6 +0,0 @@
from ._gpt_reviewer import GptReviewer
def review_swift(code):
reviewer = GptReviewer()
result = reviewer.get_response(code, "swift")
return result.json()

Просмотреть файл

@ -0,0 +1,6 @@
from ._gpt_reviewer import GptReviewer
def review_typescript(code):
reviewer = GptReviewer()
result = reviewer.get_response(code, "typescript")
return result.json()

Просмотреть файл

@ -1,6 +0,0 @@
from ._gpt_reviewer import GptReviewer
def review_typespec(code):
reviewer = GptReviewer()
result = reviewer.get_response(code, "typespec")
return result.json()