Skip to content

Instantly share code, notes, and snippets.

@elchappo
elchappo / js-and-bat.bat
Created October 23, 2022 18:11 — forked from hasegawayosuke/js-and-bat.bat
Polyglot of node.js / window bat file
if(""==0) {/*
@echo off
echo "BAT"
node "%~f0" %*
goto :eof
*/
console.log( "js" );
}
const API_URL = "https://api.openai.com/v1/chat/completions";
const MAX_TOKENS = 1500;
const TEMPERATURE = 0.5;
const SYSTEM_PROMPT = 'Act as assistant';
const MESSAGES = ["hello", "hi!", "how are you?"];
async function openAICompletion(msg) {
const options = {
method: "POST",
headers: {
@elchappo
elchappo / encoder.js
Created April 28, 2023 17:38 — forked from iceener/encoder.js
gpt-3-encoder-netlify-function.js
const { encode } = require('@nem035/gpt-3-encoder')
exports.handler = async (event, context) => {
if (event.httpMethod === 'POST') {
try {
const payload = JSON.parse(event.body);
const text = payload.text;
return {
@elchappo
elchappo / openai_call.json
Created November 7, 2023 19:32 — forked from iceener/openai_call.json
OpenAI Function Calling (parameters)
{
"model": "gpt-3.5-turbo-0613",
"function_call": {
"name": "query_enrichment"
},
"messages": [
{
"role": "user",
"content": "Write a newsletter."
}
@elchappo
elchappo / .tmux.conf
Created November 11, 2023 16:10 — forked from wenijinew/.tmux.conf
Tmux Configuration
set -g TMUX_PLUGIN_MANAGER_PATH "$GITHUB_REPO_ROOT"
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'wenijinew/glamour.tmux'
@elchappo
elchappo / Dockerfile
Created February 9, 2024 21:35 — forked from adtac/Dockerfile
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3