Skip to content

Instantly share code, notes, and snippets.

View ilovelili's full-sized avatar
🏠
Working from home

min ju ilovelili

🏠
Working from home
View GitHub Profile
async function getAIResponse(userSpeech: string): Promise<string> {
const response = await fetch(
`${openAIEndpoint}/openai/deployments/Woodstock-AI/completions?api-version=2024-06-01`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${openAIAPIKey}`,
},
body: JSON.stringify({
from flask import Flask, request, jsonify, render_template
from flask_cors import CORS
from dotenv import load_dotenv
import os
import azure.cognitiveservices.speech as speechsdk
import wave
# Load environment variables from .env file
load_dotenv()
import os
import azure.cognitiveservices.speech as speechsdk
import requests
import json
from dotenv import load_dotenv
load_dotenv()
# Azure OpenAI service credentials
speech_endpoint = os.getenv("SPEECH_ENDPOINT")
// Handle auth route
func authHandler(c echo.Context) error {
// how we can get params sent in the message like this one? => `{"action": "auth", "params", "<<api key>>"}`
// check api key in param and do auth
...
}
// Handle $connect event
func connectHandler(c echo.Context) error {
// Extract connection ID from headers
connectionID := c.Request().Header.Get("Sec-WebSocket-Protocol")
// Perform actions when a client connects
fmt.Printf("Client connected: %s\n", connectionID) // ==========> we didn't get the connectionID, it's empty
// Respond with a 200 status code
{"messages": [{"role": "system", "content": "You are an Xbox customer support agent whose primary goal is to help users with issues they are experiencing with their Xbox devices. You are friendly and concise. You only provide factual answers to queries, and do not provide answers that are not related to Xbox."}, {"role": "user", "content": "Is Xbox better than PlayStation?"}, {"role": "assistant", "content": "I apologize, but I cannot provide personal opinions. My primary job is to assist you with any issues related to your Xbox device. Do you have any Xbox-related issues that need addressing?"}]}
{"messages": [{"role": "system", "content": "You are an Xbox customer support agent whose primary goal is to help users with issues they are experiencing with their Xbox devices. You are friendly and concise. You only provide factual answers to queries, and do not provide answers that are not related to Xbox."}, {"role": "user", "content": "Can I play PC games on my Xbox?"}, {"role": "assistant", "content": "While X
@ilovelili
ilovelili / secrets-manager.go
Created October 24, 2022 07:18
load aws secrets manager
// Use this code snippet in your app.
// If you need more information about configurations or implementing the sample code, visit the AWS docs:
// https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/setting-up.html
import (
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"encoding/base64"
@ilovelili
ilovelili / api.go
Created October 15, 2022 10:59 — forked from vdparikh/api.go
Wrap GoLang Echo server in Lambda handler for API Gateway
package main
import(
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func main() {

Hosting IPFS from behind NAT/Firewall using a free reverse proxy (ngrok)

  1. Expose localhost's port 4001 to public internet using ngrok: ngrok tcp 4001. Tip: Use -region= flag for lower latency.
  2. Note the hostname and port returned by ngrok in the form: tcp://hostname:port -> localhost:4001
  3. Open the ipfs config json file ~/.ipfs/config
  4. Edit as follows: Addresses.Announce=["/dns4/put-the-hostname-here/tcp/put-the-port-here"]
  5. Save the config file
  6. ipfs daemon
package wsclient
import (
"fmt"
"github.com/gorilla/websocket"
pubsub "github.com/woodstock-tokyo/simple-pubsub"
"github.com/woodstock-tokyo/woodstock-alpaca/server/util"
)