-
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.
- Loading branch information
Mark Chen
authored and
Mark Chen
committed
Jan 25, 2024
0 parents
commit e8ef197
Showing
35 changed files
with
4,466 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,51 @@ | ||
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | ||
# More GitHub Actions for Azure: https://github.com/Azure/actions | ||
|
||
name: Build and deploy container app to Azure Web App - LLM API | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: 'ubuntu-latest' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: https://tokai.azurecr.io/ | ||
username: ${{ secrets.AzureAppService_ContainerUsername_364d2e64e7814f26a9445137567bb970 }} | ||
password: ${{ secrets.AzureAppService_ContainerPassword_390b2ce9c9214043b13a02d9015a88da }} | ||
|
||
- name: Build and push container image to registry | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: tokai.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_364d2e64e7814f26a9445137567bb970 }}/tokai/tokai-alpha-github:${{ github.sha }} | ||
file: ./Dockerfile | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
environment: | ||
name: 'production' | ||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
|
||
steps: | ||
- name: Deploy to Azure Web App | ||
id: deploy-to-webapp | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: 'LLM-API' | ||
slot-name: 'production' | ||
publish-profile: ${{ secrets.AzureAppService_PublishProfile_9955fc8889664611b43ce1438ad9e487 }} | ||
images: 'tokai.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_364d2e64e7814f26a9445137567bb970 }}/tokai/tokai-alpha-github:${{ github.sha }}' |
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,12 @@ | ||
name: LLM API CI/CD - Unit Tests | ||
on: [push, pull_request] | ||
jobs: | ||
# Run Unit Tests | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Unit Tests | ||
run: | | ||
docker build -t fastapi-ci-cd . | ||
docker run --rm fastapi-ci-cd pytest |
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,6 @@ | ||
.space | ||
.env | ||
config.py | ||
config | ||
__pycache__ | ||
.pytest_cache |
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,82 @@ | ||
disable= | ||
too-many-instance-attributes, | ||
len-as-condition, | ||
too-few-public-methods, | ||
anomalous-backslash-in-string, | ||
no-else-return, | ||
simplifiable-if-statement, | ||
too-many-arguments, | ||
duplicate-code, | ||
no-name-in-module, | ||
no-member, | ||
print-statement, | ||
parameter-unpacking, | ||
unpacking-in-except, | ||
old-raise-syntax, | ||
backtick, | ||
long-suffix, | ||
old-ne-operator, | ||
old-octal-literal, | ||
import-star-module-level, | ||
raw-checker-failed, | ||
bad-inline-option, | ||
locally-disabled, | ||
locally-enabled, | ||
file-ignored, | ||
suppressed-message, | ||
useless-suppression, | ||
deprecated-pragma, | ||
apply-builtin, | ||
basestring-builtin, | ||
buffer-builtin, | ||
cmp-builtin, | ||
coerce-builtin, | ||
execfile-builtin, | ||
file-builtin, | ||
long-builtin, | ||
raw_input-builtin, | ||
reduce-builtin, | ||
standarderror-builtin, | ||
unicode-builtin, | ||
xrange-builtin, | ||
coerce-method, | ||
delslice-method, | ||
getslice-method, | ||
setslice-method, | ||
no-absolute-import, | ||
old-division, | ||
dict-iter-method, | ||
dict-view-method, | ||
next-method-called, | ||
metaclass-assignment, | ||
indexing-exception, | ||
raising-string, | ||
reload-builtin, | ||
oct-method, | ||
hex-method, | ||
nonzero-method, | ||
cmp-method, | ||
input-builtin, | ||
round-builtin, | ||
intern-builtin, | ||
unichr-builtin, | ||
map-builtin-not-iterating, | ||
zip-builtin-not-iterating, | ||
range-builtin-not-iterating, | ||
filter-builtin-not-iterating, | ||
using-cmp-argument, | ||
eq-without-hash, | ||
div-method, | ||
idiv-method, | ||
rdiv-method, | ||
exception-message-attribute, | ||
invalid-str-codec, | ||
sys-max-int, | ||
bad-python3-import, | ||
deprecated-string-function, | ||
deprecated-str-translate-call, | ||
import-error, | ||
missing-docstring, | ||
invalid-name, | ||
bad-whitespace, | ||
consider-using-enumerate |
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,7 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"src" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
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,9 @@ | ||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9 | ||
|
||
COPY ./requirements.txt /code/requirements.txt | ||
|
||
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | ||
|
||
COPY ./src /app | ||
|
||
CMD ["uvicorn", "index.main:app", "--host", "0.0.0.0", "--port", "80"] |
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,25 @@ | ||
""" | ||
|
||
# Read the API key from the WSL environment variable | ||
dev = False | ||
if dev: | ||
openai.api_key = os.environ["OPENAI_API_KEY"] | ||
else: | ||
openai.api_key = settings.OPENAI_API_KEY | ||
|
||
@app.post("/api/docs") | ||
async def generateDocs(request: Request, aiReq: str = Form(...)): | ||
response = openai.Completion.create( | ||
model="text-davinci-003", | ||
prompt="class Log:\n"+aiReq+"Here's what the above class is doing, explained in a concise way:\n1.", | ||
temperature=0, | ||
max_tokens=300, | ||
top_p=1.0, | ||
frequency_penalty=0.0, | ||
presence_penalty=0.0, | ||
stop=["\"\"\""] | ||
) | ||
result = response.choices[0].text | ||
|
||
return {"result": result, "request": aiReq} | ||
""" |
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,25 @@ | ||
# FastAPI | ||
|
||
<img src = 'https://github.com/jayita13/FastAPI/blob/main/Screenshot%20(323).png'> | ||
|
||
I've implemented entity extraction code from spacy library's pretrained model - 'en_core_web_sm' | ||
|
||
<img src ='https://github.com/jayita13/FastAPI/blob/main/Screenshot%20(322).png'> | ||
|
||
## Software dependencies: | ||
|
||
->FastAPI | ||
|
||
->Pydantic | ||
|
||
->Uvicorn or hypercorn | ||
|
||
->spacy | ||
|
||
### Run file with command : | ||
|
||
uvicorn fastapp:app --reload | ||
|
||
Redirect to 127.0.0.1:8000/docs or 127.0.0.1:8000/redoc | ||
|
||
<img src ='https://github.com/jayita13/FastAPI/blob/main/Screenshot%20(316).png'> |
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,137 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>flake8 violations: ai/__init__.py</title> | ||
<meta http-equiv="Content-Type" value="text/html; charset=UTF-8"> | ||
<link rel="stylesheet" href="styles.css"> | ||
<script> | ||
function bindHandler(link) { | ||
var code = link.getAttribute('data-code'); | ||
var key = location.pathname + '#' + code; | ||
|
||
var ul = link.parentNode.querySelector('.details'); | ||
if (sessionStorage[key] != 'open') { | ||
ul.style.display = 'none'; | ||
} | ||
link.addEventListener('click', function (event) { | ||
if (!ul.style.display || ul.style.display == 'none') { | ||
ul.style.display = 'block'; | ||
sessionStorage[key] = 'open'; | ||
} else { | ||
ul.style.display = 'none'; | ||
sessionStorage[key] = 'closed'; | ||
} | ||
}); | ||
} | ||
|
||
window.addEventListener('DOMContentLoaded', function () { | ||
var links = document.querySelectorAll('#index > li > a'); | ||
for (var i = 0; i < links.length; i++) { | ||
bindHandler(links[i]); | ||
} | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div id="masthead" class="sev-2"></div> | ||
<div id="page"> | ||
<p id="srclink"> | ||
<a title="View full annotated source" | ||
href="ai.__init__.source.html"> | ||
<img src="file.svg" alt="≡"> | ||
</a></p> | ||
<h1> | ||
<a href="index.html"> | ||
<img src="back.svg" alt="⬅"> | ||
ai/__init__.py | ||
</a> | ||
</h1> | ||
|
||
<ul id="index"> | ||
|
||
<li> | ||
<a data-code="W293"> | ||
<span class="count sev-2"> | ||
3 | ||
</span> | ||
<strong>W293:</strong> blank line contains whitespace | ||
|
||
</a> | ||
<ul class="details"> | ||
<li> | ||
|
||
<a href="ai.__init__.source.html#l11"> | ||
<tt><i>11</i> </tt> | ||
</a> | ||
</li><li> | ||
|
||
<a href="ai.__init__.source.html#l21"> | ||
<tt><i>21</i> </tt> | ||
</a> | ||
</li><li> | ||
|
||
<a href="ai.__init__.source.html#l34"> | ||
<tt><i>34</i> </tt> | ||
</a> | ||
</li> | ||
</ul> | ||
</li> | ||
|
||
<li> | ||
<a data-code="E302"> | ||
<span class="count sev-2"> | ||
1 | ||
</span> | ||
<strong>E302:</strong> expected 2 blank lines, found 1 | ||
|
||
</a> | ||
<ul class="details"> | ||
<li> | ||
|
||
<a href="ai.__init__.source.html#l12"> | ||
<tt><i>12</i> <span class="k">class</span> <span class="nc">AI</span><span class="p">:</span></tt> | ||
</a> | ||
</li> | ||
</ul> | ||
</li> | ||
|
||
<li> | ||
<a data-code="E501"> | ||
<span class="count sev-2"> | ||
1 | ||
</span> | ||
<strong>E501:</strong> line too long (122 > 79 characters) | ||
|
||
</a> | ||
<ul class="details"> | ||
<li> | ||
|
||
<a href="ai.__init__.source.html#l38"> | ||
<tt><i>38</i> <span class="n">prompt</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">prompt</span><span class="o">+</span><span class="n">user_request</span><span class="o">+</span><span class="s2">"Here's what the above code commit is doing, explained in a concise way:</span><span class="se">\n</span><span class="s2">1."</span><span class="p">,</span></tt> | ||
</a> | ||
</li> | ||
</ul> | ||
</li> | ||
|
||
<li> | ||
<a data-code="W292"> | ||
<span class="count sev-2"> | ||
1 | ||
</span> | ||
<strong>W292:</strong> no newline at end of file | ||
|
||
</a> | ||
<ul class="details"> | ||
<li> | ||
|
||
<a href="ai.__init__.source.html#l46"> | ||
<tt><i>46</i> <span class="k">return</span> <span class="n">response</span><span class="o">.</span><span class="n">choices</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">text</span></tt> | ||
</a> | ||
</li> | ||
</ul> | ||
</li> | ||
|
||
</ul> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.