abdoh-alkhateeb commited on
Commit
e3b702e
1 Parent(s): f08a437

Update some conventions with regards to AccountabilityAgent

Browse files
Files changed (1) hide show
  1. accountability_agent.py +7 -6
accountability_agent.py CHANGED
@@ -2,19 +2,20 @@ from langchain_community.callbacks import get_openai_callback
2
  from langchain_core.prompts import PromptTemplate
3
  from langchain_openai import ChatOpenAI
4
 
 
 
5
 
6
  class AccountabilityAgent:
7
- def __init__(self, model: str = "gpt-4-1106-preview", temperature: float = 0.3, prompt_template_path: str = "prompts/accountability_agent.txt") -> None:
8
- self._llm = ChatOpenAI(model=model, temperature=temperature)
9
 
10
- with open(prompt_template_path) as f:
11
- self._prompt = PromptTemplate(input_variables=["query", "synthesis"], template=f.read().strip())
12
 
13
  self._chain = self._prompt | self._llm
14
 
15
- def run(self, query: str, cynthesis: str) -> tuple[str, dict]:
16
  with get_openai_callback() as cb:
17
- accountability = self._chain.invoke({"query": query, "synthesis": cynthesis}).content.strip()
18
 
19
  tokens = cb.total_tokens
20
  cost = cb.total_cost
 
2
  from langchain_core.prompts import PromptTemplate
3
  from langchain_openai import ChatOpenAI
4
 
5
+ from prompts.accountability_agent import template
6
+
7
 
8
  class AccountabilityAgent:
9
+ def __init__(self, model: str = "gpt-4-1106-preview", temperature: float = 0.3) -> None:
10
+ self._prompt = PromptTemplate(input_variables=["query", "synthesis"], template=template)
11
 
12
+ self._llm = ChatOpenAI(model=model, temperature=temperature)
 
13
 
14
  self._chain = self._prompt | self._llm
15
 
16
+ def run(self, query: str, synthesis: str) -> tuple[str, dict]:
17
  with get_openai_callback() as cb:
18
+ accountability = self._chain.invoke({"query": query, "synthesis": synthesis}).content.strip()
19
 
20
  tokens = cb.total_tokens
21
  cost = cb.total_cost