-
Notifications
You must be signed in to change notification settings - Fork 27
/
base_agent.py
38 lines (24 loc) · 1.1 KB
/
base_agent.py
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
from LLM import get_llm
Openai_Models = ["gpt-35-turbo-16k","gpt4-turbo-2024-04-29"]
class BaseAgent:
# gpt-35-turbo-16k gpt4-turbo-2024-04-29
def __init__(self,model = "gpt-35-turbo-16k") -> None:
self.model = model
self.llm,self.img_generator = get_llm()
def act(self, instruction):
raise NotImplementedError
def get_LLM_response(self,messages,**kwargs):
if kwargs.get("model") == None:
kwargs["model"] = self.model
return self.llm.response(messages,**kwargs)
def get_answer(self,messages,**kwargs):
response = self.get_LLM_response(messages,model = self.model,**kwargs)
return response
async def get_LLM_response_async(self,messages,**kwargs):
if kwargs.get("model") == None:
kwargs["model"] = self.model
response = await self.llm.response_async(messages,**kwargs)
return response
async def get_answer_async(self,messages,**kwargs):
response = await self.get_LLM_response_async(messages,model = self.model,**kwargs)
return response