forked from brettin/ARC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomLLM.py
More file actions
44 lines (33 loc) · 1.1 KB
/
CustomLLM.py
File metadata and controls
44 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from typing import Any, List, Mapping, Optional
from langchain_core.callbacks.manager import CallbackManagerForLLMRun
from langchain_core.language_models.llms import LLM
import requests
import json
from ARGO import ArgoWrapper
# The ARGO_LLM class. Uses the _invoke_model helper function.
# It implements the _call function.
class ARGO_LLM(LLM):
argo: ArgoWrapper
@property
def _llm_type(self) -> str:
return "custom"
def _call(
self,
prompt: str,
stop: Optional[List[str]] = None,
run_manager: Optional[CallbackManagerForLLMRun] = None,
**kwargs: Any,
) -> str:
if stop is not None:
print(f"STOP={stop}")
# raise ValueError("stop kwargs are not permitted.")
response = self.argo.invoke(prompt)
print(f"ARGO Response: {response['response']}\nEND ARGO RESPONSE")
return response['response']
@property
def _identifying_params(self) -> Mapping[str, Any]:
"""Get the identifying parameters."""
return {}
@property
def _generations(self):
return