MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / LlamaLLM

Class LlamaLLM

examples/high_level_api/langchain_custom_llm.py:9–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9class LlamaLLM(LLM):
10 model_path: str
11 llm: Llama
12
13 @property
14 def _llm_type(self) -> str:
15 return "llama-cpp-python"
16
17 def __init__(self, model_path: str, **kwargs: Any):
18 model_path = model_path
19 llm = Llama(model_path=model_path)
20 super().__init__(model_path=model_path, llm=llm, **kwargs)
21
22 def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
23 response = self.llm(prompt, stop=stop or [])
24 return response["choices"][0]["text"]
25
26 @property
27 def _identifying_params(self) -> Mapping[str, Any]:
28 return {"model_path": self.model_path}
29
30
31parser = argparse.ArgumentParser()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…