Spaces:
Running
Running
Update agent.py
Browse files
agent.py
CHANGED
@@ -42,7 +42,6 @@ from io import StringIO
|
|
42 |
from transformers import BertTokenizer, BertModel
|
43 |
import torch
|
44 |
import torch.nn.functional as F
|
45 |
-
from langchain.agents import initialize_agent, AgentType
|
46 |
from langchain_community.chat_models import ChatOpenAI
|
47 |
from langchain_community.tools import Tool
|
48 |
import time
|
@@ -50,7 +49,6 @@ from huggingface_hub import InferenceClient
|
|
50 |
from langchain_community.llms import HuggingFaceHub
|
51 |
from langchain.prompts import PromptTemplate
|
52 |
from langchain.chains import LLMChain
|
53 |
-
from langchain.agents import initialize_agent, Tool, AgentType
|
54 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
55 |
from huggingface_hub import login
|
56 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, BitsAndBytesConfig
|
@@ -59,57 +57,6 @@ from langchain_huggingface import HuggingFaceEndpoint
|
|
59 |
|
60 |
load_dotenv()
|
61 |
|
62 |
-
@tool
|
63 |
-
def multiply(a: int, b: int) -> int:
|
64 |
-
"""Multiply two numbers.
|
65 |
-
Args:
|
66 |
-
a: first int
|
67 |
-
b: second int
|
68 |
-
"""
|
69 |
-
return a * b
|
70 |
-
|
71 |
-
@tool
|
72 |
-
def add(a: int, b: int) -> int:
|
73 |
-
"""Add two numbers.
|
74 |
-
|
75 |
-
Args:
|
76 |
-
a: first int
|
77 |
-
b: second int
|
78 |
-
"""
|
79 |
-
return a + b
|
80 |
-
|
81 |
-
@tool
|
82 |
-
def subtract(a: int, b: int) -> int:
|
83 |
-
"""Subtract two numbers.
|
84 |
-
|
85 |
-
Args:
|
86 |
-
a: first int
|
87 |
-
b: second int
|
88 |
-
"""
|
89 |
-
return a - b
|
90 |
-
|
91 |
-
@tool
|
92 |
-
def divide(a: int, b: int) -> int:
|
93 |
-
"""Divide two numbers.
|
94 |
-
|
95 |
-
Args:
|
96 |
-
a: first int
|
97 |
-
b: second int
|
98 |
-
"""
|
99 |
-
if b == 0:
|
100 |
-
raise ValueError("Cannot divide by zero.")
|
101 |
-
return a / b
|
102 |
-
|
103 |
-
@tool
|
104 |
-
def modulus(a: int, b: int) -> int:
|
105 |
-
"""Get the modulus of two numbers.
|
106 |
-
|
107 |
-
Args:
|
108 |
-
a: first int
|
109 |
-
b: second int
|
110 |
-
"""
|
111 |
-
return a % b
|
112 |
-
|
113 |
|
114 |
@tool
|
115 |
def calculator(inputs: dict):
|
@@ -132,6 +79,7 @@ def calculator(inputs: dict):
|
|
132 |
return a % b
|
133 |
else:
|
134 |
return "Unknown operation"
|
|
|
135 |
|
136 |
@tool
|
137 |
def wiki_search(query: str) -> str:
|
|
|
42 |
from transformers import BertTokenizer, BertModel
|
43 |
import torch
|
44 |
import torch.nn.functional as F
|
|
|
45 |
from langchain_community.chat_models import ChatOpenAI
|
46 |
from langchain_community.tools import Tool
|
47 |
import time
|
|
|
49 |
from langchain_community.llms import HuggingFaceHub
|
50 |
from langchain.prompts import PromptTemplate
|
51 |
from langchain.chains import LLMChain
|
|
|
52 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
53 |
from huggingface_hub import login
|
54 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, BitsAndBytesConfig
|
|
|
57 |
|
58 |
load_dotenv()
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
@tool
|
62 |
def calculator(inputs: dict):
|
|
|
79 |
return a % b
|
80 |
else:
|
81 |
return "Unknown operation"
|
82 |
+
|
83 |
|
84 |
@tool
|
85 |
def wiki_search(query: str) -> str:
|