Skip to content

Instantly share code, notes, and snippets.

View t41372's full-sized avatar

Yi-Ting Chiu t41372

View GitHub Profile
@t41372
t41372 / ollama.py
Last active June 8, 2024 16:34
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.
'''
@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)