Skip to content

Instantly share code, notes, and snippets.

View ugai's full-sized avatar

ugai

View GitHub Profile
import os
import random
from pathlib import Path
from typing import AsyncGenerator
import gradio as gr
from strands import Agent, tool
from strands.models.anthropic import AnthropicModel
from strands.session.file_session_manager import SESSION_PREFIX, FileSessionManager
from strands_tools import calculator, current_time
@ugai
ugai / conversation_retrieval_chain.py
Created March 17, 2024 01:08
Conversation Retrieval Chain Example
"""
Conversation Retrieval Chain
https://python.langchain.com/docs/get_started/quickstart#conversation-retrieval-chain
"""
from langchain.chains import create_history_aware_retriever, create_retrieval_chain
from langchain.chains.combine_documents import create_stuff_documents_chain
from langchain_community.document_loaders import WebBaseLoader
from langchain_community.vectorstores import FAISS
from langchain_core.messages import AIMessage, HumanMessage
import os
import shutil
from argparse import ArgumentParser, Namespace
import numpy as np
from loguru import logger
def print_args(args: Namespace):
for arg in vars(args):
@ugai
ugai / propdpng.snippet
Last active July 9, 2022 04:18
my propdp snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a DependencyProperty</Title>
<Shortcut>propdpng</Shortcut>
<Description>Code snippet for a property using DependencyProperty as the backing store</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
@ugai
ugai / gist:82d9e84dda0c2edfa059a5c9d922269c
Last active November 11, 2021 02:42
glslViewer export png sequence
glslViewer.exe .\square_2_alter.frag -w 1920 -h 1920 --nocursor --headless -E sequence,0,11,60
ffmpeg -framerate 60 -start_number 1 -i %05d.png -c:v libx264 -preset placebo -crf 16 -pix_fmt yuv420p _output.mp4
@ugai
ugai / pin_myobjkt.py
Last active October 17, 2021 16:30
Tezos Account Addres -> Get account OBJKT list -> Get IPFS addresses -> IPFS Pinning
# Tezos Account Addres ("tz...") -> Get account OBJKT list
# -> Get IPFS addresses -> IPFS Pinning
#
# Requirements
# ------------
#
# - IPFS Desktop (https://docs.ipfs.io/install/ipfs-desktop/) or CLI tool
#
# - python package
#
@ugai
ugai / rotate_desktop.sh
Last active October 6, 2018 07:05 — forked from mildmojo/rotate_desktop.sh
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
#!/bin/bash
#
# rotate_desktop.sh
#
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#
# Using transformation matrix bits taken from:
# https://wiki.ubuntu.com/X/InputCoordinateTransformation
global_config {
default_context {
array_class: "CudaCachedArray"
device_id: "0"
backends: "cudnn:float"
backends: "cuda:float"
backends: "cpu:float"
}
}
training_config {
@ugai
ugai / MyDowStartup.bat
Last active February 8, 2017 11:13
DoW鯖用
@echo off
echo Start
call "C:\dow\MyDowUpdate.bat"
call "C:\dow\MyLaunchServer.bat"
echo end
@ugai
ugai / .swlg_scripts.md
Last active October 6, 2018 06:44
Blenderで動画作った際の副産物置き場

Blenderで動画作った際の副産物置き場。

  • EC2向けのネットワークレンダ用サービススクリプト
  • Blenderマクロ(Python)
  • OpenEXR連番から動画作成