Shago commited on
Commit
ac0a470
·
verified ·
1 Parent(s): 71b2da0

Update agents/agents_nodes.py

Browse files
Files changed (1) hide show
  1. agents/agents_nodes.py +16 -7
agents/agents_nodes.py CHANGED
@@ -1,11 +1,13 @@
1
  import json
 
 
2
  from langchain_core.messages import AIMessage, ToolMessage
3
- from langgraph.prebuilt import ToolNode
4
  from langchain_huggingface import HuggingFacePipeline
 
 
5
  from utils.state_utils import AgentState
6
  from tools.financial_tools import time_value_tool
7
- from transformers import pipeline
8
- import torch
9
 
10
 
11
  # LLL instantation
@@ -23,10 +25,17 @@ text_generator = pipeline(
23
  )
24
 
25
 
26
- llm = HuggingFacePipeline(pipeline=text_generator)
27
- llm_instantiated = llm.bind_tools(
28
- [time_value_tool],
29
- tool_choice={"type": "function", "function": {"name": "time_value_tool"}}
 
 
 
 
 
 
 
30
  )
31
 
32
  def agent_node(state: AgentState):
 
1
  import json
2
+ from transformers import pipeline
3
+ import torch
4
  from langchain_core.messages import AIMessage, ToolMessage
 
5
  from langchain_huggingface import HuggingFacePipeline
6
+ from langchain_core.runnables import RunnableLambda
7
+ from langgraph.prebuilt import ToolNode
8
  from utils.state_utils import AgentState
9
  from tools.financial_tools import time_value_tool
10
+
 
11
 
12
 
13
  # LLL instantation
 
25
  )
26
 
27
 
28
+ # llm = HuggingFacePipeline(pipeline=text_generator)
29
+ # llm_instantiated = llm.bind_tools(
30
+ # [time_value_tool],
31
+ # tool_choice={"type": "function", "function": {"name": "time_value_tool"}}
32
+ # )
33
+
34
+ llm_instantiated = llm | RunnableLambda(
35
+ lambda x: x.bind_tools(
36
+ [time_value_tool],
37
+ tool_choice={"type": "function", "function": {"name": "time_value_tool"}}
38
+ )
39
  )
40
 
41
  def agent_node(state: AgentState):