'일상다반사 > 이런저런 생각들' 카테고리의 다른 글

2024-05 삶이 지칠 때  (1) 2024.05.07
힘들 때 함 읽어보자  (0) 2023.12.17
힘들때 읽자! 듣자!  (0) 2023.04.03
금주  (0) 2021.07.17
우물안 개구리  (0) 2021.07.14

for i in $(cat file.txt); do
    if rpm -qa | grep -qw $i; then
        echo "$i is installed."
    else
        echo "$i is not installed."
    fi
done

'나는 노동자 > LINUX' 카테고리의 다른 글

ansible extra vars  (0) 2023.02.13
ansible 물리서버, 가성서버 확인  (0) 2023.02.07
ansible facts device check  (0) 2023.02.04
리눅스 임시 포트 오픈  (0) 2023.01.12
xfs volume extend  (0) 2020.07.10

api = azure function (included chatgpt)

yo office 

 

 

taskpane.js

 

export async function run() {
  /**
   * Insert your Outlook code here
   *
   */
  let body = ''

  async function outputResult(body){
    console.log(body)
    let response = await runAzure(body)
    console.log(response.output)
  }
  async function getBody(){
    Office.context.mailbox.item.body.getAsync("text", function(result) {
      if (result.status == Office.AsyncResultStatus.Succeeded) {
        body = result.value
        outputResult(body)
      }
    })

  }

  async function runAzure(body) {
  const Url = 'your api site address';
  const otherParam = {
    body: '{"model":"text-davinci-003","prompt":"summarize the following in 50 words or less: ' + body.replace(/['"]+/g, '').trim().replace(/(\r\n|\n|\n)/gm, "") + '","max_tokens":200,"temperature":0}',
    method: 'POST'
  };
  const response = await fetch(Url,otherParam);
  var output = await response.text()
  return {output}

  }

  await getBody()
}
 
 
위 내용을 조금 다르게...  로그내용 출력
 
export async function run() {
  /**
   * Insert your Outlook code here
   *
   */
  let body = ''

  async function outputResult(body){
    console.log(body)
    let response = await runAzure(body)
    console.log(response.output)
  }
  async function getBody(){
    Office.context.mailbox.item.body.getAsync("text", function(result) {
      if (result.status == Office.AsyncResultStatus.Succeeded) {
        body = result.value
        outputResult(body)
      }
    })

  }

  async function runAzure(body) {
  const Url = 'your api address';
  const bodyjson = '{"model":"text-davinci-003","prompt":"summarize the following in 50 words or less: ' + body.replace(/['"]+/g, '').trim().replace(/(\r\n|\n|\n)/gm, "") + '","max_tokens":200,"temperature":0}'
  console.log(bodyjson)
  const otherParam = {
    body: bodyjson,
    method: 'POST'
  };
  const response = await fetch(Url,otherParam);
  var output = await response.text()
  return {output}

  }

  await getBody()
}

your api address = azure function [for chatgpt api : post]

 

메일 내용을 요약해서 보여줌

 

/*
 * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
 * See LICENSE in the project root for license information.
 */

/* global document, Office */

Office.onReady((info) => {
  if (info.host === Office.HostType.Outlook) {
    document.getElementById("sideload-msg").style.display = "none";
    document.getElementById("app-body").style.display = "flex";
    document.getElementById("run").onclick = run;
  }
});

export async function run() {
  /**
   * Insert your Outlook code here
   *
   */
  let body = ''

  async function outputResult(body){
    console.log(body)
    let response = await runAzure(body)
    console.log(response.output)
    document.getElementById('app-body').innerHTML = "<b>Summary: </b><br/>" + response.output
  }
  async function getBody(){
    Office.context.mailbox.item.body.getAsync("text", function(result) {
      if (result.status == Office.AsyncResultStatus.Succeeded) {
        body = result.value
        outputResult(body)
      }
    })

  }

  async function runAzure(body) {
  const Url = 'your ajpi site address';
  const bodyjson = '{"model":"text-davinci-003","prompt":"summarize the following in 50 words or less: ' + body.replace(/['"]+/g, '').trim().replace(/(\r\n|\n|\n)/gm, "") + '","max_tokens":200,"temperature":0}'
  console.log(bodyjson)
  const otherParam = {
    body: bodyjson,
    method: 'POST'
  };
  const response = await fetch(Url,otherParam);
  var output = await response.text()
  return {output}

  }

  await getBody()
}

 

Summarize This Email 선택시 기존에서는 콘솔(개발자모드)에서 내용이 보였으나 이젠 그냥 화면에 보임

 

 

Full+code+in+task_pane.js.txt
0.00MB
Fake+email.txt
0.00MB
CORS+policy.txt
0.00MB

 

회신기능

 

export async function run() {
  /**
   * Insert your Outlook code here
   */

  const item = Office.context.mailbox.item
  async function getBody(){
    Office.context.mailbox.item.body.getAsync("text",function(result){
      if (result.status == Office.AsyncResultStatus.Succeeded){
        let body =  result.value
       
        PutItAllTogether(body)
     
      }
    })
  }
async function RunAPI(body){
  const Url = 'https://~'
  const bodyJson ='{"model":"text-davinci-003","prompt":"Reply to the following email and  politely and professionally manner while saying no '+  body.replace(/['"]+/g, '').trim().replace(/(\r\n|\n|\r)/gm, "") +'","max_tokens":400,"temperature":0}'
  console.log(bodyJson)
  const otherParam = {
    body: bodyJson,
    method: 'POST'
  }
  const response = await fetch(Url, otherParam)
  var output = await response.text()

  return {output}

}

async function PutItAllTogether(body){

  console.log(body)
  let response = await RunAPI(body)
  console.log(response)
  item.displayReplyForm(response.output)
}

await getBody()
}

 

Generate Reply 클릭시 - 자동회신 양식을 띄우고 회신 내용을 자동으로 채워줌 

 

+ Recent posts