MCPcopy Create free account
hub / github.com/KnowledgeXLab/LeanRAG / llm_client

Class llm_client

CommonKG/kg_score.py:20–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19
20class llm_client():
21 def __init__(self, args):
22 self.model = args["llm_model"]
23 self.base_url = args["llm_url"]
24 self.api_key = args["llm_api_key"]
25 self.client = OpenAI(base_url=self.base_url, api_key=self.api_key, http_client=httpx.Client(verify=False))
26 def call(self, user_prompt: str, system_prompt: str = "") -> str:
27
28 completion = self.client.chat.completions.create(
29 model=self.model,
30 messages=[
31 {
32 "role": "system",
33 "content": system_prompt if system_prompt else "You are a helpful assistant."
34 },
35 {
36 "role": "user",
37 "content": user_prompt
38 }
39 ]
40 )
41
42 self.response = completion.choices[0].message.content
43
44class TripleScorer:
45 def __init__(self, triple_path:str, triple_soure_path:str , output_path:str = None):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected