MCPcopy Index your code
hub / github.com/FSoft-AI4Code/HyperAgent / LocalLLM

Class LocalLLM

src/hyperagent/agents/llms.py:46–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45
46class LocalLLM(LLM):
47 def __init__(self, config):
48 super().__init__(config)
49 openai_api_key = os.environ["TOGETHER_API_KEY"]
50 openai_api_base = "https://api.together.xyz"
51 # openai_api_base = "http://localhost:8004/v1"
52 # openai_api_key="token-abc123"
53
54
55 self.client = OpenAI(
56 api_key=openai_api_key,
57 base_url=openai_api_base,
58 )
59
60 def __call__(self, prompt: str):
61 prompt = truncate_tokens_hf(prompt, encoding_name=self.config["model"])
62 response = self.client.chat.completions.create(
63 temperature=0,
64 model=self.config["model"],
65 messages=[
66 {"role": "system", "content": self.system_prompt},
67 {"role": "user", "content": prompt},
68 ],
69 max_tokens=None
70 )
71 return response.choices[0].message.content
72
73
74class OpenAILLM(LLM):

Callers 3

gen_tools.pyFile · 0.90
__init__Method · 0.90
load_summarizerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected