From f66f7dee8afe70fc26b3882705741c570095c78c Mon Sep 17 00:00:00 2001 From: Shroominic Date: Sun, 8 Oct 2023 12:28:26 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20Fixed=20circular=20import=20issu?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- funcchain/prompt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/funcchain/prompt.py b/funcchain/prompt.py index 1fe032e..38e616a 100644 --- a/funcchain/prompt.py +++ b/funcchain/prompt.py @@ -1,7 +1,6 @@ from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate from langchain.schema import BaseMessage, SystemMessage -from funcchain import settings from funcchain.utils import count_tokens @@ -17,6 +16,8 @@ def create_prompt( base_tokens = count_tokens(instruction + system) for k, v in input_kwargs.copy().items(): if isinstance(v, str): + from funcchain import settings # fix circular import + content_tokens = count_tokens(v) if base_tokens + content_tokens > settings.MAX_TOKENS: input_kwargs[k] = v[: (settings.MAX_TOKENS - base_tokens) * 2 // 3]