Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ from langchain_community.tools import DuckDuckGoSearchRun
|
|
4 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
5 |
import os
|
6 |
import google.generativeai as genai
|
|
|
|
|
7 |
|
8 |
# Configure Gemini API Key (replace with your actual key)
|
9 |
# Use Streamlit secrets for secure storage.
|
@@ -11,11 +13,23 @@ GOOGLE_API_KEY = st.secrets["GOOGLE_API_KEY"]
|
|
11 |
genai.configure(api_key=GOOGLE_API_KEY)
|
12 |
|
13 |
|
14 |
-
# Define Tools
|
15 |
search_tool = DuckDuckGoSearchRun()
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
# Define Agents
|
19 |
inventory_specialist = Agent(
|
20 |
role='Inventory Specialist',
|
21 |
goal='Identify the best matching homes from current inventory based on customer criteria.',
|
@@ -26,7 +40,7 @@ inventory_specialist = Agent(
|
|
26 |
""",
|
27 |
verbose=True,
|
28 |
allow_delegation=False,
|
29 |
-
tools=[search_tool],
|
30 |
llm=ChatGoogleGenerativeAI(model="gemini-pro", temperature=0.7, convert_system_message_to_human=True) # Use Gemini model
|
31 |
)
|
32 |
|
|
|
4 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
5 |
import os
|
6 |
import google.generativeai as genai
|
7 |
+
from langchain.tools import BaseTool # Import BaseTool
|
8 |
+
|
9 |
|
10 |
# Configure Gemini API Key (replace with your actual key)
|
11 |
# Use Streamlit secrets for secure storage.
|
|
|
13 |
genai.configure(api_key=GOOGLE_API_KEY)
|
14 |
|
15 |
|
16 |
+
# Define Tools - Corrected: Wrap the tool in a list if it's a single tool
|
17 |
search_tool = DuckDuckGoSearchRun()
|
18 |
|
19 |
+
class ToolWrapper(BaseTool):
|
20 |
+
"""Wrapper for tools to make them compatible with CrewAI."""
|
21 |
+
name: str
|
22 |
+
func: callable
|
23 |
+
description: str
|
24 |
+
|
25 |
+
def _run(self, *args, **kwargs):
|
26 |
+
return self.func(*args, **kwargs)
|
27 |
+
|
28 |
+
async def _arun(self, *args, **kwargs):
|
29 |
+
return await self.func(*args, **kwargs)
|
30 |
+
|
31 |
|
32 |
+
# Define Agents - Corrected: Use ToolWrapper
|
33 |
inventory_specialist = Agent(
|
34 |
role='Inventory Specialist',
|
35 |
goal='Identify the best matching homes from current inventory based on customer criteria.',
|
|
|
40 |
""",
|
41 |
verbose=True,
|
42 |
allow_delegation=False,
|
43 |
+
tools=[ToolWrapper(name=search_tool.name, func=search_tool.run, description=search_tool.description)], # Corrected Tool Usage
|
44 |
llm=ChatGoogleGenerativeAI(model="gemini-pro", temperature=0.7, convert_system_message_to_human=True) # Use Gemini model
|
45 |
)
|
46 |
|