Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(integrations-service): Add new integrations & refactor integrations service #540

Merged
merged 32 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4ace5fa
fix: Remove unnecessary docker compose dependencies
Sep 22, 2024
d633c77
fix: Fix litellm config for voyage-3
creatorrr Sep 23, 2024
50f96d3
Merge branch 'main' into dev
creatorrr Sep 23, 2024
ecc95ea
Implement ToolCallStep & Fix transition after PromptStep (#513)
HamadaSalhab Sep 23, 2024
6896c23
doc: Update README.md with announcement update (#517)
creatorrr Sep 23, 2024
a4151d0
feat: Add basic support for integration tools to ToolStep (#519)
creatorrr Sep 25, 2024
d8072a0
feat(integration-service): Add integrations service (#520)
HamadaSalhab Sep 25, 2024
ed33cf9
feat(agents-api,integrations): Working integrations for tool-call ste…
creatorrr Sep 25, 2024
833433a
fix(agents-api): Fix wait for input step (#522)
HamadaSalhab Sep 26, 2024
087495b
feat(integration-service): template spider integration added
Vedantsahai18 Sep 26, 2024
683522c
feat(integration-service): template spider integration updated
Vedantsahai18 Sep 27, 2024
6c0a919
Remove disabled integrations
HamadaSalhab Sep 27, 2024
9db28a6
feat(integrations-service): Refactor models
HamadaSalhab Sep 28, 2024
e345dfe
feat(agents-api): Add support for reading setup args from metadata an…
creatorrr Sep 28, 2024
5060ee3
feat: Add docker bake builder (#528)
creatorrr Sep 28, 2024
de2be8b
fix: Minor fix to docker bake github actions (#529)
creatorrr Sep 28, 2024
cc8adca
feat: Add changelog from release notes (#530)
creatorrr Sep 28, 2024
be4d40f
Update changelog for v0.4.0 (#531)
github-actions[bot] Sep 28, 2024
98d322b
fix: Bake on release as well (#532)
creatorrr Sep 28, 2024
79a2114
feat(integrations-service): Refactor models & endpoints | Add spider …
HamadaSalhab Sep 29, 2024
9f46e02
feat(integrations-service): Add get_integration endpoint
HamadaSalhab Sep 29, 2024
e9b7075
Merge branch 'dev' into f/integrations-improvement
HamadaSalhab Sep 30, 2024
b9c3c9e
feat(integrations-service): Update poetry.lock
HamadaSalhab Sep 30, 2024
23f1964
fix(integrations-service): fix spider crawl output
HamadaSalhab Sep 30, 2024
d67c375
fix(agents-api): Set empty integration setup to None
HamadaSalhab Sep 30, 2024
a568f4b
feat(integrations-service): Add brave & browserbase integrations | Sw…
HamadaSalhab Sep 30, 2024
d977e98
Reformat
HamadaSalhab Oct 1, 2024
ff15631
feat(agents-api): Add new integrations to typespec & loosen integrati…
HamadaSalhab Oct 1, 2024
53bb994
Merge branch 'dev' into f/integrations-improvement
HamadaSalhab Oct 1, 2024
aeb20a8
Fix(integrations-service): Add setuptools to fix weather integration
HamadaSalhab Oct 1, 2024
c1828e6
Fix(integrations-service): Change to asynchronous methods
HamadaSalhab Oct 1, 2024
a6f7e6a
Fix(agents-api): Remove duplicate fields in autogen
HamadaSalhab Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions agents-api/agents_api/autogen/Tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,18 @@ class IntegrationDef(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
provider: Literal[
"dummy",
"dalle_image_generator",
"duckduckgo_search",
"hacker_news",
"weather",
"wikipedia",
]
provider: (
Literal[
"dummy",
"hacker_news",
"weather",
"wikipedia",
"spider",
"brave",
"browserbase",
]
| str
)
"""
The provider of the integration
"""
Expand Down Expand Up @@ -129,12 +133,14 @@ class IntegrationDefUpdate(BaseModel):
provider: (
Literal[
"dummy",
"dalle_image_generator",
"duckduckgo_search",
"hacker_news",
"weather",
"wikipedia",
"spider",
"brave",
"browserbase",
]
| str
| None
) = None
"""
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/clients/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def run_integration_service(
slug = f"{provider}/{method}" if method else provider
url = f"{integration_service_url}/execute/{slug}"

setup = setup or {}
setup = setup or None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant assignment: setup = setup or None is unnecessary since setup is already None by default. Remove this line to simplify the code.


async with AsyncClient() as client:
response = await client.post(
Expand Down
31 changes: 16 additions & 15 deletions integrations-service/integrations/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from .dalle_image_generator import (
DalleImageGeneratorArguments,
DalleImageGeneratorSetup,
from .base_models import (
BaseArguments,
BaseOutput,
BaseProvider,
BaseProviderMethod,
BaseSetup,
ProviderInfo,
)
from .duckduckgo_search import DuckDuckGoSearchExecutionArguments
from .hacker_news import HackerNewsExecutionArguments

# TODO: Move these models somewhere else
from .models import (
ExecuteIntegrationArguments,
ExecuteIntegrationSetup,
IntegrationDef,
IntegrationExecutionRequest,
IntegrationExecutionResponse,
from .brave import BraveSearchArguments, BraveSearchOutput, BraveSearchSetup
from .browserbase import (
BrowserBaseLoadArguments,
BrowserBaseLoadOutput,
BrowserBaseSetup,
)
from .weather import WeatherExecutionArguments, WeatherExecutionSetup
from .wikipedia import WikipediaExecutionArguments
from .hacker_news import HackerNewsFetchArguments, HackerNewsFetchOutput
from .spider import SpiderFetchArguments, SpiderFetchOutput, SpiderSetup
from .weather import WeatherGetArguments, WeatherGetOutput, WeatherSetup
from .wikipedia import WikipediaSearchArguments, WikipediaSearchOutput
36 changes: 36 additions & 0 deletions integrations-service/integrations/models/base_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from typing import Annotated, Any, Optional

from pydantic import BaseModel, Field, RootModel
from pydantic_core import Url

IdentifierName = Annotated[str, Field(max_length=40, pattern="^[^\\W0-9]\\w*$")]


class BaseSetup(BaseModel): ...


class BaseArguments(BaseModel): ...


class BaseOutput(BaseModel): ...


class ProviderInfo(BaseModel):
url: Optional[Url]
docs: Optional[Url]
icon: Optional[Url]
friendly_name: str


class BaseProviderMethod(BaseModel):
method: IdentifierName
description: str
arguments: type[BaseArguments]
output: type[BaseOutput]


class BaseProvider(BaseModel):
provider: IdentifierName
setup: type[BaseSetup] | None
methods: list[BaseProviderMethod]
info: ProviderInfo
19 changes: 19 additions & 0 deletions integrations-service/integrations/models/brave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from pydantic import Field

from .base_models import (
BaseArguments,
BaseOutput,
BaseSetup,
)


class BraveSearchSetup(BaseSetup):
api_key: str = Field(..., description="The api key for Brave Search")


class BraveSearchArguments(BaseArguments):
query: str = Field(..., description="The search query for searching with Brave")


class BraveSearchOutput(BaseOutput):
result: str = Field(..., description="The result of the Brave Search")
29 changes: 29 additions & 0 deletions integrations-service/integrations/models/browserbase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import List, Optional

from langchain_core.documents import Document
from pydantic import Field
from pydantic_core import Url

from .base_models import (
BaseArguments,
BaseOutput,
BaseSetup,
)


class BrowserBaseSetup(BaseSetup):
api_key: str = Field(..., description="The api key for BrowserBase")
project_id: str = Field(..., description="The project id for BrowserBase")
session_id: Optional[str] = Field(
None, description="The session id for BrowserBase"
)


class BrowserBaseLoadArguments(BaseArguments):
urls: List[Url] = Field(..., description="The urls for loading with BrowserBase")


class BrowserBaseLoadOutput(BaseOutput):
documents: List[Document] = Field(
..., description="The documents loaded from the urls"
)
50 changes: 50 additions & 0 deletions integrations-service/integrations/models/execution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from typing import Optional, Union

from pydantic import BaseModel

from .brave import BraveSearchArguments, BraveSearchOutput, BraveSearchSetup
from .browserbase import (
BrowserBaseLoadArguments,
BrowserBaseLoadOutput,
BrowserBaseSetup,
)
from .hacker_news import HackerNewsFetchArguments, HackerNewsFetchOutput
from .spider import SpiderFetchArguments, SpiderFetchOutput, SpiderSetup
from .weather import WeatherGetArguments, WeatherGetOutput, WeatherSetup
from .wikipedia import WikipediaSearchArguments, WikipediaSearchOutput

ExecutionSetup = Union[
SpiderSetup,
WeatherSetup,
BraveSearchSetup,
BrowserBaseSetup,
]

ExecutionArguments = Union[
SpiderFetchArguments,
WeatherGetArguments,
HackerNewsFetchArguments,
WikipediaSearchArguments,
BraveSearchArguments,
BrowserBaseLoadArguments,
]

ExecutionResponse = Union[
SpiderFetchOutput,
WeatherGetOutput,
HackerNewsFetchOutput,
WikipediaSearchOutput,
BraveSearchOutput,
BrowserBaseLoadOutput,
]


class ExecutionRequest(BaseModel):
setup: Optional[ExecutionSetup]
"""
The setup parameters the integration accepts (such as API keys)
"""
arguments: ExecutionArguments
"""
The arguments to pass to the integration
"""
16 changes: 13 additions & 3 deletions integrations-service/integrations/models/hacker_news.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
from pydantic import BaseModel, Field
from langchain_core.documents import Document
from pydantic import Field
from pydantic_core import Url

from .base_models import BaseArguments, BaseOutput

class HackerNewsExecutionArguments(BaseModel):
url: str = Field(..., description="The URL of the Hacker News thread to fetch")

class HackerNewsFetchArguments(BaseArguments):
url: Url = Field(..., description="The URL of the Hacker News thread to fetch")


class HackerNewsFetchOutput(BaseOutput):
documents: list[Document] = Field(
..., description="The documents returned from the Hacker News search"
)
Empty file.
21 changes: 21 additions & 0 deletions integrations-service/integrations/models/spider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from langchain_core.documents import Document
from pydantic import Field
from pydantic_core import Url

from .base_models import BaseArguments, BaseOutput, BaseSetup


class SpiderSetup(BaseSetup):
spider_api_key: str = Field(..., description="The request for which to fetch data")


class SpiderFetchArguments(BaseArguments):
url: Url = Field(..., description="The url for which to fetch data")
mode: str = Field("scrape", description="The type of crawlers")
params: dict | None = Field(None, description="The parameters for the Spider API")


class SpiderFetchOutput(BaseOutput):
documents: list[Document] = Field(
..., description="The documents returned from the spider"
)
18 changes: 14 additions & 4 deletions integrations-service/integrations/models/weather.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
from pydantic import BaseModel, Field
from pydantic import Field

from .base_models import (
BaseArguments,
BaseOutput,
BaseSetup,
)

class WeatherExecutionSetup(BaseModel):

class WeatherSetup(BaseSetup):
openweathermap_api_key: str = Field(
..., description="The location for which to fetch weather data"
..., description="The api key for OpenWeatherMap"
)


class WeatherExecutionArguments(BaseModel):
class WeatherGetArguments(BaseArguments):
location: str = Field(
..., description="The location for which to fetch weather data"
)


class WeatherGetOutput(BaseOutput):
result: str = Field(..., description="The weather data for the specified location")
18 changes: 16 additions & 2 deletions integrations-service/integrations/models/wikipedia.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
from pydantic import BaseModel, Field
from typing import Literal

from langchain_core.documents import Document
from pydantic import Field

class WikipediaExecutionArguments(BaseModel):
from .base_models import (
BaseArguments,
BaseOutput,
)


class WikipediaSearchArguments(BaseArguments):
query: str = Field(..., description="The search query string")
load_max_docs: int = Field(2, description="Maximum number of documents to load")


class WikipediaSearchOutput(BaseOutput):
documents: list[Document] = Field(
..., description="The documents returned from the Wikipedia search"
)
Loading
Loading