Skip to content

Commit

Permalink
Merge pull request #321 from Project-Coda/dev
Browse files Browse the repository at this point in the history
3.4.0
  • Loading branch information
ikifar2012 authored Feb 17, 2024
2 parents 9f1d25d + cd27164 commit 2f3f83a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
ARG VARIANT=16-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
ARG VARIANT=20-bookworm
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"extensions": [
"dbaeumer.vscode-eslint",
"GitHub.copilot",
"VisualStudioExptTeam.vscodeintellicode"
"VisualStudioExptTeam.vscodeintellicode",
"ms-azuretools.vscode-docker"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
# Update 'VARIANT' to pick an LTS version of Node.js: 18, 16, 14.
# Append -bullseye or -buster to pin to an OS version.
# Use -bullseye variants on local arm64/Apple Silicon.
VARIANT: 16-bullseye
VARIANT: 20-bookworm

volumes:
- ..:/workspace:cached
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/library-scripts/docker-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ USE_MOBY=${5:-"true"}
DOCKER_VERSION=${6:-"latest"}
DOCKER_DASH_COMPOSE_VERSION=${7:-"v1"} # v1 or v2
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal jammy"
DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal hirsute impish jammy"
DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal jammy bookworm"
DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal hirsute impish jammy bookworm"

set -e

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "coda-utilities",
"version": "3.3.0",
"version": "3.4.0",
"description": "A general utilities bot for Coda",
"main": "index.js",
"scripts": {
"test": "nodemon .",
"dev": "nodemon .",
"start": "node index.js"
},
"author": "Matheson Steplock (ikifar2012)",
Expand Down
28 changes: 9 additions & 19 deletions utilities/openai.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
const { Configuration, OpenAIApi } = require('openai');
const { OpenAI } = require('openai');
const env = require('../env.js');
const embedcreator = require('../embed.js');
async function getOpenAI() {
try {
const configuratuion = new Configuration({
apiKey: env.utilities.openai,
});
const openai = new OpenAIApi(configuratuion);
return openai;
}
catch (err) {
console.log(err);
embedcreator.sendError(err);
}
}

const openai = new OpenAI({
apiKey: env.utilities.openai,
});

async function createCompletion(prompt) {
try {
openai = await getOpenAI();
response = await openai.createChatCompletion({
response = await openai.chat.completions.create({
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: String(prompt) }],
max_tokens: 300,
},
)
.then((response) => {
return response.data.choices[0].message.content;
return response.choices[0].message.content;
},
)
.catch((err) => {
Expand All @@ -44,7 +35,6 @@ async function createCompletion(prompt) {

async function GenerateImage(prompt) {
try {
openai = await getOpenAI();
response = await openai.createImage({
prompt: String(prompt),
n: 1,
Expand All @@ -69,4 +59,4 @@ async function GenerateImage(prompt) {
}
}

module.exports = { getOpenAI, createCompletion, GenerateImage };
module.exports = { createCompletion, GenerateImage };

0 comments on commit 2f3f83a

Please sign in to comment.