Skip to content

Instantly share code, notes, and snippets.

@djacobs7
djacobs7 / gist:a9e75da29160888cb4aef14cbc8ead73
Created February 23, 2023 19:09
langchain self critique example
# Example of a bad LLM
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.chains.llm import LLMChain
story_prompt = PromptTemplate(
template="""Write a story about: {story}""",
input_variables=["story"]
)
@acmerfight
acmerfight / lru.py
Last active August 29, 2015 13:59
lru cache
#coding=utf-8
import time
from threading import RLock
from collections import OrderedDict
class LruCache(object):
cache = OrderedDict()
lock = RLock()
args = {
'_id': 'xxx',
'group': 123
}
cursor = db.table.find(args)
args.pop('_id')
data = list(cursor)
# 这样得到的data是没有_id = 'xxx'这个条件的查询结果