maykcaldas commited on
Commit
5b63bb8
1 Parent(s): b831acd

Upload 6 files

Browse files
Files changed (3) hide show
  1. agent.py +22 -21
  2. app.py +2 -1
  3. version.py +1 -0
agent.py CHANGED
@@ -45,24 +45,25 @@ total_energy = MAPI_reg_tools(
45
  "e_total","total energy"
46
  )
47
 
48
-
49
- memory = GPTIndexMemory(index=GPTListIndex([]), memory_key="chat_history", query_kwargs={"response_mode": "compact"})
50
- llm=OpenAI(temperature=0.7)
51
- tools = (
52
- stability.get_tools() +
53
- magnetism.get_tools() +
54
- gap_direct.get_tools() +
55
- metal.get_tools() +
56
- band_gap.get_tools() +
57
- volume.get_tools() +
58
- density.get_tools() +
59
- atomic_density.get_tools() +
60
- formation_energy_per_atom.get_tools() +
61
- energy_per_atom.get_tools() +
62
- electronic_energy.get_tools() +
63
- ionic_energy.get_tools() +
64
- total_energy.get_tools() +
65
- agents.load_tools(["llm-math", "python_repl"], llm=llm) +
66
- common_tools
67
- )
68
- agent_chain = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True, memory=memory)
 
 
45
  "e_total","total energy"
46
  )
47
 
48
+ class Agent:
49
+ def __init__(self, openai_api_key, mapi_api_key):
50
+ memory = GPTIndexMemory(index=GPTListIndex([]), memory_key="chat_history", query_kwargs={"response_mode": "compact"})
51
+ llm=OpenAI(temperature=0.7)
52
+ tools = (
53
+ stability.get_tools() +
54
+ magnetism.get_tools() +
55
+ gap_direct.get_tools() +
56
+ metal.get_tools() +
57
+ band_gap.get_tools() +
58
+ volume.get_tools() +
59
+ density.get_tools() +
60
+ atomic_density.get_tools() +
61
+ formation_energy_per_atom.get_tools() +
62
+ energy_per_atom.get_tools() +
63
+ electronic_energy.get_tools() +
64
+ ionic_energy.get_tools() +
65
+ total_energy.get_tools() +
66
+ agents.load_tools(["llm-math", "python_repl"], llm=llm) +
67
+ common_tools
68
+ )
69
+ agent_chain = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True, memory=memory)
app.py CHANGED
@@ -12,8 +12,9 @@ css_style = """
12
  def agent_run(q, openai_api_key, mapi_api_key):
13
  os.environ["OPENAI_API_KEY"]=openai_api_key
14
  os.environ["MAPI_API_KEY"]=mapi_api_key
 
15
  try:
16
- out = agent.agent_chain.run(input=q)
17
  except:
18
  out = "Something went wrong, please try again"
19
  return out
 
12
  def agent_run(q, openai_api_key, mapi_api_key):
13
  os.environ["OPENAI_API_KEY"]=openai_api_key
14
  os.environ["MAPI_API_KEY"]=mapi_api_key
15
+ agent_chain = agent.Agent(openai_api_key, mapi_api_key)
16
  try:
17
+ out = agent_chain.run(input=q)
18
  except:
19
  out = "Something went wrong, please try again"
20
  return out
version.py ADDED
@@ -0,0 +1 @@
 
 
1
+ 0.0.1