Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hdddhdd committed Nov 12, 2023
2 parents 4e65785 + 93d295a commit 0fe5002
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ jobs:
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/src" # App source code path
api_location: "" # Api source code path - optional
api_location: "/api" # Api source code path - optional
output_location: "/src" # Built app content directory - optional
###### End of Repository/Build Configurations ######
- name: Install Python dependencies
run: python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Install node-fetch
run: npm install node-fetch
npm run build --if-present


close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/main_quatergirit-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js project to Azure Function App - quatergirit-api

on:
push:
branches:
- main
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '18.x' # set this to the node version to use (supports 8.x, 10.x, 12.x)

jobs:
build-and-deploy:
runs-on: windows-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: Setup Node ${{ env.NODE_VERSION }} Environment
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: 'Resolve Project Dependencies Using Npm'
shell: pwsh
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
npm install
npm run build --if-present
npm run test --if-present
popd
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'quatergirit-api'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_9970B2D7920C44409B733A2F378F0148 }}
2 changes: 2 additions & 0 deletions api/ktx_schedule/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const axios = require('axios');

module.exports = async function (context, req) {

const dep = "동대구";
Expand Down
36 changes: 36 additions & 0 deletions api/onecall_script/chat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# ChatGPT turbo 3.5 이용하여 챗봇 구현

"""
pip install requests
"""
import os
import requests
import openai

MODEL = "gpt-3.5-turbo"

# 출발역, 도착역, 출발 날짜, 열차 번호, 이름, 발권 매수

departure = "물금역"
arrival = "대전역"
time = "12/11 12:23"
ticket_num = "3"
name = "홍길동"

CONTENT = departure + "에서 " + arrival + "으로 " + time + " 에 가는 기차 승차권을 " + ticket_num + "매 예매하는 말을 1줄로 해줘"

response = openai.ChatCompletion.create(
model=MODEL,
messages=[
{"role": "user", "content": "동대구역에서 서울역으로 11/15 16:24 에 가는 기차 승차권을 2매 예매하는 말을 1줄로 해줘."},
{"role": "assistant", "content": "동대구역에서 서울역으로 11월 15일 오후 4시 24분에 출발하는 기차 승차권 2매를 예매하고 싶어요."},
{"role": "user", "content": CONTENT},
],
temperature=0,
)

result = "안녕하세요, 원콜 서비스를 이용하려 합니다. "
result += response['choices'][0]['message']['content']
result += " 제 이름은 " + name + "입니다."

print(result)
19 changes: 19 additions & 0 deletions api/onecall_script/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}
13 changes: 13 additions & 0 deletions api/onecall_script/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');

const name = (req.query.name || (req.body && req.body.name));
const responseMessage = name
? "Hello, " + name + ". This HTTP triggered function executed successfully."
: "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";

context.res = {
// status: 200, /* Defaults to 200 */
body: responseMessage
};
}
3 changes: 3 additions & 0 deletions api/onecall_script/sample.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "Azure"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"axios": "^1.6.1",
"node-fetch": "^2.7.0",
"swa": "^0.0.1"
}
},
"type":"module"
}
17 changes: 0 additions & 17 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,24 +280,7 @@ <h1>Vanilla JavaScript App</h1>
}
</script>

<script>
async function callTMapAPI(address) {
const url = `https://apis.openapi.sk.com/tmap/geo/convertAddress?version=1&searchTypCd=NtoO&reqAdd=${address}&reqMulti=S&resCoordType=WGS84GEO&appKey=e8wHh2tya84M88aReEpXCa5XTQf3xgo01aZG39k5`;

const response = await fetch(url);

if (!response.ok) {
throw new Error(`API request failed with status code ${response.status}`);
}

const responseData = await response.json();

const latitude = responseData.ConvertAdd.newAddressList.newAddress[0].newLat;
const longitude = responseData.ConvertAdd.newAddressList.newAddress[0].newLon;

return { latitude, longitude };
}
</script>



Expand Down

0 comments on commit 0fe5002

Please sign in to comment.