Commit 40ab3265 authored by 2017030228's avatar 2017030228

a

parents
Pipeline #666 pending with stages

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="InstalledPackageInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ReferenceExistsInspection" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="UnusedInspection" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (comcomcom)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/comcomcom.iml" filepath="$PROJECT_DIR$/.idea/comcomcom.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
FROM python:3.8-slim
COPY . /app
RUN pip install -r requirements.txt
WORKDIR /app
CMD ["python3", "-m", "flask", "run", "--host=0.0.0.0"]
import random
import requests
from flask import request, Flask
app = Flask(__name__)
url = "https://main-gpt2-large-jeong-hyun-su.endpoint.ainize.ai/gpt2-large/long"
data = {
"text": "Hi my name is hyeonwoong and",
"num_samples": 5,
"length": 20
}
models = {
"gpt2-large": "http://main-gpt2-large-jeong-hyun-su.endpoint.ainize.ai/gpt2-large/long",
"gpt2-cover-letter": "http://main-gpt2-cover-letter-jeong-hyun-su.endpoint.ainize.ai/gpt2-cover-letter/long",
"gpt2-reddit": "http://master-gpt2-reddit-woomurf.endpoint.ainize.ai/gpt2-reddit/long",
"gpt2-story": "http://main-gpt2-story-gmlee329.endpoint.ainize.ai/gpt2-story/long",
"gpt2-ads": "http://main-gpt2-ads-psi1104.endpoint.ainize.ai/gpt2-ads/long",
"gpt2-business": "http://main-gpt2-business-leesangha.endpoint.ainize.ai/gpt2-business/long",
"gpt2-film": "http://main-gpt2-film-gmlee329.endpoint.ainize.ai/gpt2-film/long",
"gpt2-trump": "http://main-gpt2-trump-gmlee329.endpoint.ainize.ai/gpt2-trump/long"
}
@app.route("/gpt2", methods=["POST"])
def gpt2():
context = request.form['context']
model = request.form['model']
length = request.form['length']
url = models[model]
if length == "short":
length = random.randrange(2, 6)
else:
length = 20
data = {
"text": context,
"num_samples": 5,
"length": length
}
response = requests.post(url, data=data)
res = response.json()
return res
def main():
response = requests.post(url, data=data)
if response.status_code == 200:
res = response.json()
print(res)
else:
print("Failed Request")
@app.route('/')
def index():
return '''<html>
<head>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="../static/index.js"></script>
<style>
.item:hover {
color: blue;
}
</style>
</head>
<body>
<div class="container">
<div class="jumbotron mt-3">
<h1>TabTab Mini</h1>
<p>Write your context!</p>
<!-- Model list -->
<select id="model" style="margin-bottom: 10px;">
<option value="gpt2-large">gpt2-large</option>
<option value="gpt2-cover-letter">CoverLetter</option>
<option value="gpt2-reddit">Reddit</option>
<option value="gpt2-story">Story</option>
<option value="gpt2-film">Film</option>
<option value="gpt2-ads">Ads</option>
</select>
<input type="radio" name="length" checked="checked" value="short">short</input>
<input type="radio" name="length" value="long">long</input>
<textarea id="context" style="width:70%; height:40%; display: block; margin-bottom: 10px;"></textarea>
<b>Result</b>
<div id="select_box">
<ul style="width:100%">
<li class="item" onclick="concat(this.innerHTML)"></li>
<li class="item" onclick="concat(this.innerHTML)"></li>
<li class="item" onclick="concat(this.innerHTML)"></li>
<li class="item" onclick="concat(this.innerHTML)"></li>
<li class="item" onclick="concat(this.innerHTML)"></li>
</ul>
</div>
<button id="btn_autocomplete" class="btn btn-primary" onclick="suggestion()">Auto Complete!</button>
</div>
</div>
</body>
</html>
<script>
// when click "Auto Complete!" button
function suggestion() {
var textarea = document.getElementById("context");
var context = textarea.value;
var models = document.getElementById("model");
var model = models.options[models.selectedIndex].value;
var lengths = document.getElementsByName("length");
var length = '';