Skip to content

Commit 04626dc

Browse files
aaronsteersdevin-ai-integration[bot]coderabbitai[bot]
authored
feat: Add welcome message and agent tools to populate form fields (#33)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 8432c18 commit 04626dc

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

agentic_connector_builder_webapp/agentic_connector_builder_webapp.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ class ConnectorBuilderState(rx.State):
6969
email: email_address
7070
"""
7171

72-
chat_messages: list[dict[str, str]] = []
72+
chat_messages: list[dict[str, str]] = [
73+
{
74+
"role": "assistant",
75+
"content": "Welcome! 👋\n\nWhat connector do you want to build today?",
76+
}
77+
]
7378
chat_input: str = ""
7479
current_streaming_message: str = ""
7580
chat_loading: bool = False
@@ -200,6 +205,8 @@ async def send_message(self):
200205
documentation_urls=self.documentation_urls,
201206
functional_requirements=self.functional_requirements,
202207
test_list=self.test_list,
208+
set_source_api_name=self.set_source_api_name,
209+
set_connector_name=self.set_connector_name,
203210
)
204211

205212
recent_messages = self.chat_messages[:-1][-HISTORY_MAX_MESSAGES:]

agentic_connector_builder_webapp/chat_agent.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ class SessionDeps:
8383
documentation_urls: str
8484
functional_requirements: str
8585
test_list: str
86+
from typing import Annotated, Any, Callable
87+
88+
@dataclass
89+
class SessionDeps:
90+
"""Dependencies containing the current webapp session state."""
91+
92+
yaml_content: str
93+
connector_name: str
94+
source_api_name: str
95+
documentation_urls: str
96+
functional_requirements: str
97+
test_list: str
98+
set_source_api_name: Callable[[str], Any] | None = None
99+
set_connector_name: Callable[[str], Any] | None = None
86100

87101

88102
mcp_server = MCPServerStdio(
@@ -357,4 +371,64 @@ def replace_manifest_lines(
357371
except Exception as e:
358372
return f"Error replacing lines in manifest: {str(e)}"
359373

374+
@agent.tool
375+
def set_api_name(
376+
ctx: RunContext[SessionDeps],
377+
api_name: Annotated[
378+
str, Field(description="The name of the API (e.g., 'JSONPlaceholder API')")
379+
],
380+
) -> str:
381+
"""Set the Source API Name in the requirements form.
382+
383+
Use this tool when the user tells you what API they want to build a connector for.
384+
This will populate the 'Source API name' field in the Define Requirements tab.
385+
386+
Args:
387+
ctx: Runtime context with session dependencies
388+
api_name: The name of the API
389+
390+
Returns:
391+
A confirmation message indicating success.
392+
"""
393+
try:
394+
if ctx.deps.set_source_api_name:
395+
ctx.deps.set_source_api_name(api_name)
396+
return f"Successfully set the Source API Name to '{api_name}' in the requirements form."
397+
else:
398+
return "Error: Unable to update Source API Name (callback not available)"
399+
except Exception as e:
400+
return f"Error setting API name: {str(e)}"
401+
402+
@agent.tool
403+
def set_connector_name(
404+
ctx: RunContext[SessionDeps],
405+
connector_name: Annotated[
406+
str,
407+
Field(
408+
description="The connector name in the format 'source-{name}' (e.g., 'source-jsonplaceholder')"
409+
),
410+
],
411+
) -> str:
412+
"""Set the Connector Name in the requirements form.
413+
414+
Use this tool to populate the 'Connector name' field in the Define Requirements tab.
415+
The connector name should follow the format 'source-{name}' where {name} is derived
416+
from the API name (e.g., 'JSONPlaceholder API' -> 'source-jsonplaceholder').
417+
418+
Args:
419+
ctx: Runtime context with session dependencies
420+
connector_name: The connector name in source-{name} format
421+
422+
Returns:
423+
A confirmation message indicating success.
424+
"""
425+
try:
426+
if ctx.deps.set_connector_name:
427+
ctx.deps.set_connector_name(connector_name)
428+
return f"Successfully set the Connector Name to '{connector_name}' in the requirements form."
429+
else:
430+
return "Error: Unable to update Connector Name (callback not available)"
431+
except Exception as e:
432+
return f"Error setting connector name: {str(e)}"
433+
360434
return agent

0 commit comments

Comments
 (0)