Skip to content

Instantly share code, notes, and snippets.

"""
pip install lightrag-hku
"""
import os
import asyncio
import numpy as np
from tqdm import tqdm
from lightrag import LightRAG, QueryParam
from lightrag.llm.openai import gpt_4o_mini_complete, gpt_4o_complete, openai_embed, openai_complete_if_cache
@GTimothee
GTimothee / load-and-save-embed-model.ipynb
Created November 14, 2024 17:09
load and save embed model.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GTimothee
GTimothee / streamlit_feedback_app.py
Created June 13, 2024 07:51
basic feedback collection snippet with streamlit_feedback
import streamlit as st
from streamlit_feedback import streamlit_feedback
import logging
import uuid
logging.basicConfig(level=logging.INFO)
def reset_key():
st.session_state['ss_key'] = str(uuid.uuid4())
@GTimothee
GTimothee / chat_app.py
Created June 7, 2024 14:02
encapsulated chat app with streamlit
import streamlit as st
if 'messages' not in st.session_state:
st.session_state['messages'] = [{
'role': 'assistant', 'content': "Do you have a question for me ?"
}]
with st.container(height=500):
@GTimothee
GTimothee / primes.py
Created March 24, 2019 18:37
prime functions
def is_prime_number(x):
''' Function to know if x is a prime number.
'''
for i in range(floor(sqrt(x))):
if x % i == 0:
return False
return True
def sieve_of_eratosthenes(start, end):
''' Brute force method to compute primes.
pillow : img.show()
opencv:
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.imshow('image',croppedImg)
cv2.waitKey(0)
cv2.destroyAllWindows()
https://www.digitalocean.com/community/tutorials/how-to-handle-plain-text-files-in-python-3
#from list of tuples
class Person(object):
def __init__(self, name, profession):
self.name = name
self.profession = profession
people = [Person("Nick", "Programmer"), Person("Alice","Engineer")]
professions = dict([ (p.name, p.profession) for p in people ])
def drawMask(width, height, coordinatesList):
mask = np.zeros((height,width,3), np.uint8)
color = (255,255,255)
for coordinates in coordinatesList:
cv2.fillConvexPoly(mask, np.array(coordinates, 'int32'), color)
return mask
from lxml import etree
def getSifts(xmlFilePath):
doc = etree.parse(xmlFilePath)
pags = doc.xpath('//PAG')
pag = pags[0]
sifts = pag.xpath('SIFTMATCHER')
return sifts
for sift in sifts :
pour faire un clean d'un .sh édité avec un éditeur de texte standard (different de vi)
tr -d '\r' < export.sh > export_clean.sh