Spaces:
Runtime error
Runtime error
File size: 772 Bytes
91e0a96 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import langchain
import time
from langchain.llms import OpenAI
from langchain.cache import InMemoryCache
from langchain.cache import SQLiteCache
from redis import Redis
from langchain.cache import RedisCache
# InMemoryCache or SQLiteCache or RedisCache
# use 'rm .langchain.db' to delete db when use SQLiteCache。
# langchain.llm_cache = InMemoryCache()
# langchain.llm_cache = SQLiteCache()
# langchain.llm_cache = RedisCache(redis_=Redis())
llm = OpenAI(model_name="text-davinci-002", n=2, best_of=2)
start = time.perf_counter()
print(llm("今日中国新闻有哪些"))
print("first suspend:", time.perf_counter() - start)
start = time.perf_counter()
print(llm("今日中国新闻有哪些"))
print("second suspend:{:0.10f}".format(time.perf_counter() - start)) |