mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
new version
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from linkup import LinkupClient
|
from linkup import LinkupClient
|
||||||
LINKUP_AVAILABLE = True
|
LINKUP_AVAILABLE = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
LINKUP_AVAILABLE = False
|
LINKUP_AVAILABLE = False
|
||||||
|
LinkupClient = Any # type placeholder when package is not available
|
||||||
|
|
||||||
from pydantic import PrivateAttr
|
from pydantic import PrivateAttr
|
||||||
|
|
||||||
class LinkupSearchTool:
|
class LinkupSearchTool:
|
||||||
name: str = "Linkup Search Tool"
|
name: str = "Linkup Search Tool"
|
||||||
description: str = "Performs an API call to Linkup to retrieve contextual information."
|
description: str = "Performs an API call to Linkup to retrieve contextual information."
|
||||||
_client: LinkupClient = PrivateAttr()
|
_client: LinkupClient = PrivateAttr() # type: ignore
|
||||||
|
|
||||||
def __init__(self, api_key: str):
|
def __init__(self, api_key: str):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
|
from typing import Any, Type, Optional
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import weaviate
|
try:
|
||||||
from pydantic import BaseModel, Field
|
import weaviate
|
||||||
from typing import Type, Optional
|
from weaviate.classes.config import Configure, Vectorizers
|
||||||
from crewai.tools import BaseTool
|
from weaviate.classes.init import Auth
|
||||||
|
WEAVIATE_AVAILABLE = True
|
||||||
|
except ImportError:
|
||||||
|
WEAVIATE_AVAILABLE = False
|
||||||
|
weaviate = Any # type placeholder
|
||||||
|
Configure = Any
|
||||||
|
Vectorizers = Any
|
||||||
|
Auth = Any
|
||||||
|
|
||||||
from weaviate.classes.config import Configure, Vectorizers
|
from pydantic import BaseModel, Field
|
||||||
from weaviate.classes.init import Auth
|
from crewai.tools import BaseTool
|
||||||
|
|
||||||
|
|
||||||
class WeaviateToolSchema(BaseModel):
|
class WeaviateToolSchema(BaseModel):
|
||||||
@@ -51,14 +59,11 @@ class WeaviateVectorSearchTool(BaseTool):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _run(self, query: str) -> str:
|
def _run(self, query: str) -> str:
|
||||||
"""Search the Weaviate database
|
if not WEAVIATE_AVAILABLE:
|
||||||
|
raise ImportError(
|
||||||
Args:
|
"The 'weaviate-client' package is required to use the WeaviateVectorSearchTool. "
|
||||||
query (str): The query to search retrieve relevant information from the Weaviate database. Pass only the query as a string, not the question.
|
"Please install it with: uv add weaviate-client"
|
||||||
|
)
|
||||||
Returns:
|
|
||||||
str: The result of the search query
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not self.weaviate_cluster_url or not self.weaviate_api_key:
|
if not self.weaviate_cluster_url or not self.weaviate_api_key:
|
||||||
raise ValueError("WEAVIATE_URL or WEAVIATE_API_KEY is not set")
|
raise ValueError("WEAVIATE_URL or WEAVIATE_API_KEY is not set")
|
||||||
|
|||||||
Reference in New Issue
Block a user