(fix)[common]: llm client (#22)

* fix buidler init

* add sub llm client in __init__

* fix cmd kagbase

* fix spo kag_llm
This commit is contained in:
Xinhong Zhang 2024-11-05 14:43:52 +08:00 committed by GitHub
parent ba5d89da73
commit 98fa26932d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 6 deletions

View File

@ -11,7 +11,13 @@
# or implied.
from kag.common.llm.llm_config_checker import LLMConfigChecker
from kag.common.llm.client.vllm_client import VLLMClient
from kag.common.llm.client.ollama_client import OllamaClient
from kag.common.llm.client.openai_client import OpenAIClient
__all__ = [
"LLMConfigChecker"
"LLMConfigChecker",
"VLLMClient",
"OpenAIClient",
"OllamaClient"
]

View File

@ -111,7 +111,7 @@ class KagBaseModule(object):
self._init_llm()
self.biz_scene = kwargs.get("KAG_PROMPT_BIZ_SCENE") or os.getenv("KAG_PROMPT_BIZ_SCENE", "default")
self.language = self.config.get("prompt").get("language") or os.getenv("KAG_PROMPT_LANGUAGE", "en")
self.language = self.config.get("prompt").get("language") if self.config.get("prompt") else None or os.getenv("KAG_PROMPT_LANGUAGE", "en")
def _init_llm(self):

View File

@ -171,8 +171,8 @@ class ExactMatchRetrievalSpo(RetrievalSpoBase):
class FuzzyMatchRetrievalSpo(RetrievalSpoBase):
def __init__(self, text_similarity: TextSimilarity = None, llm: LLMClient=None):
super().__init__()
model = eval(os.getenv("KAG_LLM"))
self.llm: LLMClient = llm or LLMClient.from_config(model)
model = os.getenv("KAG_LLM")
self.llm: LLMClient = llm or LLMClient.from_config(eval(model))
self.text_similarity = text_similarity or TextSimilarity()
self.cached_map = {}

View File

@ -11,7 +11,7 @@ six==1.16.0
click==8.1.7
dateutils==0.6.12
certifi==2023.11.17
urllib3==2.1.0
urllib3==1.26.16
python-dateutil==2.8.2
networkx==3.1
pydantic==2.5.2
@ -37,5 +37,5 @@ openai
python-docx
charset_normalizer==3.3.2
pdfminer.six==20231228
openspg-knext==0.5.2b1
openspg-knext==0.5.2b2
ollama