fix: circular import in arcade.core (#137)

Fixes a circular import issue where `arcade.sdk -> arcade.core` but also
`arcade.core -> arcade.sdk`. My mistake!

Moved some of the shared classes down into `core`, and re-exported them
to `sdk` to keep the expected interface for devs.
This commit is contained in:
Nate Barbettini 2024-11-01 12:38:44 -07:00 committed by GitHub
parent c8e686c04e
commit 3699b16b2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 37 additions and 12 deletions

View file

@ -23,6 +23,8 @@ from pydantic import BaseModel, Field, create_model
from pydantic.fields import FieldInfo
from pydantic_core import PydanticUndefined
from arcade.core.annotations import Inferrable
from arcade.core.auth import OAuth2, ToolAuthorization
from arcade.core.errors import ToolDefinitionError
from arcade.core.schema import (
TOOL_NAME_SEPARATOR,
@ -46,8 +48,6 @@ from arcade.core.utils import (
is_union,
snake_to_pascal_case,
)
from arcade.sdk.annotations import Inferrable
from arcade.sdk.auth import OAuth2, ToolAuthorization
InnerWireType = Literal["string", "integer", "number", "boolean", "json"]
WireType = Union[InnerWireType, Literal["array"]]

View file

@ -0,0 +1,3 @@
from arcade.core.annotations import Inferrable
__all__ = ["Inferrable"]

View file

@ -0,0 +1,23 @@
from arcade.core.auth import (
GitHub,
Google,
LinkedIn,
OAuth2,
Slack,
Spotify,
ToolAuthorization,
X,
Zoom,
)
__all__ = [
"GitHub",
"Google",
"LinkedIn",
"OAuth2",
"Slack",
"Spotify",
"ToolAuthorization",
"X",
"Zoom",
]

View file

@ -12,14 +12,14 @@ client = AsyncOpenAI(api_key=os.environ["ARCADE_API_KEY"], base_url="http://loca
app = FastAPI()
actor_secret = os.environ.get("ARCADE_ACTOR_SECRET")
actor_secret = os.environ["ARCADE_ACTOR_SECRET"]
actor = FastAPIActor(app, secret=actor_secret)
actor.register_toolkit(Toolkit.from_module(arcade_math))
class ChatRequest(BaseModel):
message: str
user_id: str
user_id: str | None = None
@app.post("/chat")
@ -33,14 +33,13 @@ async def postChat(request: ChatRequest, tool_choice: str = "execute"):
model="gpt-4o-mini",
max_tokens=500,
tools=[
# "Google.GetEmails",
# "Google.SearchEmailsByHeader",
# "Google.WriteDraft",
# "GitHub.CountStargazers",
# "GitHub.SetStarred",
# "GitHub.SearchIssues",
# "Slack.SendDmToUser",
# "Slack.SendMessageToChannel",
"Math.Add",
"Math.Subtract",
"Math.Multiply",
"Math.Divide",
"Math.Sqrt",
# Other tools can be added as needed:
# "Math.SumList"
],
tool_choice=tool_choice,
user=request.user_id,