bstraehle commited on
Commit
104aa04
·
1 Parent(s): e838ca2

Update agent_llamaindex.py

Browse files
Files changed (1) hide show
  1. agent_llamaindex.py +11 -8
agent_llamaindex.py CHANGED
@@ -30,20 +30,22 @@ def get_callback(token_counter):
30
  str(token_counter.prompt_llm_token_count) + "\n" +
31
  "Completion Tokens: " +
32
  str(token_counter.completion_llm_token_count))
 
 
 
 
 
 
33
 
34
  def get_service_context(config):
35
  return ServiceContext.from_defaults(
36
- callback_manager = get_callback_manager(config)
37
- )
 
38
 
39
  def agent_llamaindex(config, prompt):
40
  service_context = get_service_context(config)
41
 
42
- llm = OpenAI(
43
- model = config["model"],
44
- service_context = service_context,
45
- temperature = config["temperature"])
46
-
47
  tool_spec = OpenWeatherMapToolSpec(key = os.environ["OPENWEATHERMAP_API_KEY"])
48
  tools = tool_spec.to_tool_list()
49
 
@@ -52,7 +54,8 @@ def agent_llamaindex(config, prompt):
52
  agent = OpenAIAgent.from_tools(
53
  [tools[0], # built-in tools
54
  date_tool], # custom tools
55
- llm = llm,
 
56
  verbose = True
57
  )
58
 
 
30
  str(token_counter.prompt_llm_token_count) + "\n" +
31
  "Completion Tokens: " +
32
  str(token_counter.completion_llm_token_count))
33
+
34
+ def get_llm(self, config):
35
+ return OpenAI(
36
+ model = config["model_name"],
37
+ temperature = config["temperature"]
38
+ )
39
 
40
  def get_service_context(config):
41
  return ServiceContext.from_defaults(
42
+ callback_manager = get_callback_manager(config),
43
+ llm = get_llm(config)
44
+ )
45
 
46
  def agent_llamaindex(config, prompt):
47
  service_context = get_service_context(config)
48
 
 
 
 
 
 
49
  tool_spec = OpenWeatherMapToolSpec(key = os.environ["OPENWEATHERMAP_API_KEY"])
50
  tools = tool_spec.to_tool_list()
51
 
 
54
  agent = OpenAIAgent.from_tools(
55
  [tools[0], # built-in tools
56
  date_tool], # custom tools
57
+ llm = get_llm(),
58
+ service_context = service_context,
59
  verbose = True
60
  )
61