Skip to content

Instantly share code, notes, and snippets.

View t41372's full-sized avatar

Yi-Ting Chiu t41372

View GitHub Profile
@t41372
t41372 / rand_number_llm.py
Last active December 21, 2024 01:00
LLM Random number generator
"""
Experiment: The LLM is asked to generate a number, but it can only generate 0 or 1.
The probability of generating 0 is 90%, and the probability of generating 1 is 10%.
The LLM is asked to generate 100 numbers, and the number of 0s generated is counted.
The actual probability of generating 0 is then calculated.
"""
from openai import OpenAI
@t41372
t41372 / install_piper_tts.py
Last active September 22, 2024 11:45
Piper TTS Binary installation script with model download script. This script was a modification from the https://github.com/DissonanceTK/MacReddy fork and was once used in my Open-LLM-VTuber project.
# this code file is from https://github.com/DissonanceTK/MacReddy fork and is licensed under the MIT License.
"""
MIT License
Copyright (c) 2024 ILikeAI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@t41372
t41372 / async_test.py
Last active July 15, 2024 07:11
Producer-consumer model in python with asyncio
import asyncio
import random
import time
# emulate a time consuming task
async def task_A(char):
time_to_sleep = random.randint(1, 3)
id = f'Product_{char}[{time.strftime("%M:%S", time.localtime())}, {time_to_sleep}s]'
print("Producing: " + id)
@t41372
t41372 / ollama.py
Last active November 28, 2024 01:10
Using Ollama API in Python with memory and system prompt
# This file is responsible for the communicating with the Ollama Server
import json
import requests
class Ollama:
'''
This class is responsible for communicating with the Ollama Server.
The conversation memory is stored inside this class.
'''