Skip to content

Instantly share code, notes, and snippets.

View amn41's full-sized avatar

Alan Nichol amn41

View GitHub Profile
@amn41
amn41 / gpt.sh
Created March 2, 2023 08:40
chatGPT on the command line - add to your bashrc/zshrc
function gpt() {
local url="https://api.openai.com/v1/chat/completions"
local model="gpt-3.5-turbo"
local body="{\"model\":\"$model\", \"messages\":[{\"role\": \"user\", \"content\": \"$1\"}]}"
local headers="Content-Type: application/json"
local auth="Authorization: Bearer ${OPENAI_API_KEY}"
curl -s -H "$headers" -H "$auth" -d "$body" "$url" \
| jq -r '.choices[0].message.content'
}
import streamlit as st
import numpy as np
import pandas as pd
import json
import requests
@st.cache
def get_auth_token(host, user, pw):
st.write("cache miss token!")
url = f"{host}/api/auth"
import json
import requests
def get_auth_token(host, user, pw):
url = f"{host}/api/auth"
payload = {"username": user, "password": pw}
response = requests.post(url, json=payload)
try:
token = response.json()["access_token"]
return token
@amn41
amn41 / README.md
Last active May 28, 2020 13:33
Github Actions Workflow to comment on a Rasa repo PR with cross-validation results

Comment on a GitHub PR with Rasa NLU cross-validation results

image

Instructions

Save the yaml file at .github/workflows/comment_crossval_results.yml

Add the format_results.py script at the root of your repo.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import logging
from flask import Blueprint, request, jsonify
import requests
from rasa_dm.channels.channel import UserMessage, OutputChannel
from rasa_dm.actions import Action
import requests
class ActionHTTPRequest(Action):
def name(self):
return "make_request"
def run(self, dispatcher, tracker, domain):
url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json'
result = requests.get(url).json()
@amn41
amn41 / process_logs.py
Created July 31, 2017 14:20
read rasa nlu logs, optionally reprocess, and dump to file
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from builtins import str as text
import argparse
import io
import json
"""Implements the long-short term memory character model.
This version vectorizes over multiple examples, but each string
has a fixed length."""
from __future__ import absolute_import
from __future__ import print_function
from builtins import range
from os.path import dirname, join
import numpy as np
import numpy.random as npr
import rinocloud as rino
import shutil, os
import subprocess
import hashlib
"""
persist = Persistor(config.rino_token,config.rino_dir)
def save_model_new(persist,model_file,score):
temp_file="tmp_{0:06d}.txt".format(random.choice(range(10000)))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.