Skip to content

Instantly share code, notes, and snippets.

View amn41's full-sized avatar

Alan Nichol amn41

View GitHub Profile
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()
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
@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.

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
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"
@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'
}