-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Websearch] Add no-op websearch action (builder, rendering), gated (#…
…5230) * [Websearch] Add no-op websearch action (builder, rendering), gated Description --- This PR follows #5224 that introduced types and models for websearch. It adds the websearch action to union action types, and creates the necessary boilerplate. Following PRs will implement each part: action execution, action rendering, action configuration in builder Risk --- None, since gated Deployment plan --- Front * remove useless transaction * spolu coms * clean * implement new action pattern * flav review
- Loading branch information
1 parent
837fe9f
commit 8a2c03a
Showing
20 changed files
with
320 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
front/components/assistant/conversation/WebsearchAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { WebsearchActionType } from "@dust-tt/types/dist/front/assistant/actions/websearch"; | ||
|
||
// TODO(pr,websearch) Implement this function | ||
export default function WebsearchAction({ | ||
websearchAction, | ||
}: { | ||
websearchAction: WebsearchActionType; | ||
}) { | ||
return ( | ||
<> | ||
<div> | ||
Action to be implemented here: {JSON.stringify(websearchAction)} | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
front/components/assistant_builder/actions/WebsearchAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { AssistantBuilderActionConfiguration } from "@app/components/assistant_builder/types"; | ||
|
||
export function isActionWebsearchValid( | ||
action: AssistantBuilderActionConfiguration | ||
) { | ||
return ( | ||
action.type === "WEBSEARCH" && Object.keys(action.configuration).length > 0 | ||
); | ||
} | ||
|
||
export function ActionWebsearch() { | ||
return ( | ||
<div> | ||
This action will perform a web search and return the top results (title, | ||
link and summary) to the assistant. | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type { AgentActionSpecification, Result } from "@dust-tt/types"; | ||
import { Ok } from "@dust-tt/types"; | ||
import type { WebsearchConfigurationType } from "@dust-tt/types/dist/front/assistant/actions/websearch"; | ||
|
||
import type { BaseActionRunParams } from "@app/lib/api/assistant/actions/types"; | ||
import { BaseActionConfigurationServerRunner } from "@app/lib/api/assistant/actions/types"; | ||
import type { Authenticator } from "@app/lib/auth"; | ||
|
||
/** | ||
* Params generation. | ||
*/ | ||
|
||
export class WebsearchConfigurationServerRunner extends BaseActionConfigurationServerRunner<WebsearchConfigurationType> { | ||
async buildSpecification( | ||
auth: Authenticator, | ||
{ | ||
name, | ||
description, | ||
}: { name?: string | undefined; description?: string | undefined } | ||
): Promise<Result<AgentActionSpecification, Error>> { | ||
const owner = auth.workspace(); | ||
if (!owner) { | ||
throw new Error( | ||
"Unexpected unauthenticated call to `runWebsearchAction`" | ||
); | ||
} | ||
|
||
return new Ok({ | ||
name: name ?? "web_search", | ||
description: | ||
description ?? "Perform a web search and return the top results.", | ||
inputs: [ | ||
{ | ||
name: "query", | ||
description: "The query used to perform the web search.", | ||
type: "string", | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
run( | ||
auth: Authenticator, | ||
runParams: BaseActionRunParams, | ||
customParams: Record<string, unknown> | ||
): AsyncGenerator<unknown, any, unknown> { | ||
throw new Error( | ||
"Method not implemented." + | ||
JSON.stringify(runParams) + | ||
JSON.stringify(customParams) + | ||
JSON.stringify(auth) | ||
); | ||
} | ||
} |
Oops, something went wrong.