From 7294abc890c377d75c6c8c932620c2e2c8b3f0f9 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 28 Aug 2023 01:43:45 +0200 Subject: Add async support for H2o Add format_prompt helper Fix create_completion in AsyncGeneratorProvider Move get_cookies from constructor to function Add ow HuggingChat implement Remove need auth form Liabots Add staic cache for access_token in OpenaiChat Add OpenAssistant provider Support stream and async in You Support async and add userId in Yqcloud Add log_time module --- testing/log_time.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 testing/log_time.py (limited to 'testing/log_time.py') diff --git a/testing/log_time.py b/testing/log_time.py new file mode 100644 index 00000000..376ab86d --- /dev/null +++ b/testing/log_time.py @@ -0,0 +1,25 @@ +from time import time + + +async def log_time_async(method: callable, **kwargs): + start = time() + result = await method(**kwargs) + secs = f"{round(time() - start, 2)} secs" + if result: + return " ".join([result, secs]) + return secs + + +def log_time_yield(method: callable, **kwargs): + start = time() + result = yield from method(**kwargs) + yield f" {round(time() - start, 2)} secs" + + +def log_time(method: callable, **kwargs): + start = time() + result = method(**kwargs) + secs = f"{round(time() - start, 2)} secs" + if result: + return " ".join([result, secs]) + return secs \ No newline at end of file -- cgit v1.2.3 From 51c5197c5cd15fe90afb40604ae14934d42cc785 Mon Sep 17 00:00:00 2001 From: abc <98614666+xtekky@users.noreply.github.com> Date: Mon, 28 Aug 2023 21:14:07 +0100 Subject: ~ --- testing/log_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testing/log_time.py') diff --git a/testing/log_time.py b/testing/log_time.py index 376ab86d..7d268128 100644 --- a/testing/log_time.py +++ b/testing/log_time.py @@ -22,4 +22,4 @@ def log_time(method: callable, **kwargs): secs = f"{round(time() - start, 2)} secs" if result: return " ".join([result, secs]) - return secs \ No newline at end of file + return secs -- cgit v1.2.3