Merge pull request #2313 from automatisch/brave-search
This commit is contained in:
3
packages/backend/src/apps/brave-search/actions/index.js
Normal file
3
packages/backend/src/apps/brave-search/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import webSearch from './web-search/index.js';
|
||||
|
||||
export default [webSearch];
|
||||
@@ -0,0 +1,52 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Web search',
|
||||
key: 'webSearch',
|
||||
description: 'Queries Brave Search and get back search results from the web.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Query',
|
||||
key: 'q',
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: 'The search query term.',
|
||||
},
|
||||
{
|
||||
label: 'Safe search',
|
||||
key: 'safesearch',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: 'Add or remove messages as needed',
|
||||
value: 'moderate',
|
||||
options: [
|
||||
{
|
||||
label: 'Off',
|
||||
value: 'off',
|
||||
},
|
||||
{
|
||||
label: 'Moderate',
|
||||
value: 'moderate',
|
||||
},
|
||||
{
|
||||
label: 'Strict',
|
||||
value: 'strict',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const params = {
|
||||
q: $.step.parameters.q,
|
||||
safesearch: $.step.parameters.safesearch,
|
||||
};
|
||||
|
||||
const { data } = await $.http.get('/v1/web/search', { params });
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
aria-label="Brave" role="img"
|
||||
viewBox="0 0 512 512"><path
|
||||
d="m0 0H512V512H0"
|
||||
fill="#fff"/><linearGradient id="a"><stop offset="0" stop-color="#f50"/><stop offset="1" stop-color="#f20"/></linearGradient><path d="M416 158l9-23c-24-25-33-43-72-34l-35-40H194l-35 40c-38-3-45 6-72 34l10 23-12 34 39 150c8 32 14 45 37 61l72 49c7 4 16 12 23 12 8 0 16-8 23-12l72-49c23-16 29-29 37-61l40-150" fill="url(#a)"/><path d="M308 343c8-7-13-16-22-20-10-5-20-8-30-11-10 2-20 6-30 11-9 5-30 11-22 20 15 11 34 27 52 39l52-39m35-216-43 7c-5 0-17-5-27-8s-17-3-17-3-7 0-17 3-22 8-27 8l-43-7s-45 54-45 66c0 16 32 42 45 57 17 13-7 31 3 51 7 12 18 20 25 19 17-5 48-21 55-41-2-15-38-20-45-35 0-15 18-27 17-44-2-15-45-22-59-29-2-2-1-3 6-3 21-3 47-4 66 8 8 19-16 63-3 71 19 3 26 5 45 0 13-3-8-55-4-71 14-11 49-10 66-8 8 0 8 1 6 3-15 5-51 15-59 29-1 13 17 31 17 44-2 14-42 18-44 36 2 19 40 32 55 40 7 1 18-7 24-19 9-16-14-35 3-51 15-15 42-36 45-57 0-12-45-66-45-66" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 996 B |
34
packages/backend/src/apps/brave-search/auth/index.js
Normal file
34
packages/backend/src/apps/brave-search/auth/index.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'screenName',
|
||||
label: 'Screen Name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description:
|
||||
'Screen name of your connection to be used on Automatisch UI.',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'apiKey',
|
||||
label: 'API Key',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'Brave Search API key of your account.',
|
||||
docUrl: 'https://automatisch.io/docs/brave-search#api-key',
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
|
||||
verifyCredentials,
|
||||
isStillVerified,
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
const isStillVerified = async () => {
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
||||
@@ -0,0 +1,5 @@
|
||||
const verifyCredentials = async () => {
|
||||
return true;
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
||||
@@ -0,0 +1,7 @@
|
||||
const addContentTypeHeader = ($, requestConfig) => {
|
||||
requestConfig.headers.accept = 'application/json';
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addContentTypeHeader;
|
||||
@@ -0,0 +1,9 @@
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.apiKey) {
|
||||
requestConfig.headers['X-Subscription-Token'] = $.auth.data.apiKey;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
||||
@@ -0,0 +1,3 @@
|
||||
import listModels from './list-models/index.js';
|
||||
|
||||
export default [listModels];
|
||||
@@ -0,0 +1,31 @@
|
||||
export default {
|
||||
name: 'List models',
|
||||
key: 'listModels',
|
||||
|
||||
async run($) {
|
||||
const models = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
limit: 999,
|
||||
};
|
||||
|
||||
let hasMore = false;
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get('/v1/models', { params });
|
||||
params.after_id = data.last_id;
|
||||
hasMore = data.has_more;
|
||||
|
||||
for (const base of data.data) {
|
||||
models.data.push({
|
||||
value: base.id,
|
||||
name: base.display_name,
|
||||
});
|
||||
}
|
||||
} while (hasMore);
|
||||
|
||||
return models;
|
||||
},
|
||||
};
|
||||
21
packages/backend/src/apps/brave-search/index.js
Normal file
21
packages/backend/src/apps/brave-search/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import addAcceptHeader from './common/add-accept-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import actions from './actions/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Brave Search',
|
||||
key: 'brave-search',
|
||||
baseUrl: 'https://search.brave.com',
|
||||
apiBaseUrl: 'https://api.search.brave.com/res',
|
||||
iconUrl: '{BASE_URL}/apps/brave-search/assets/favicon.svg',
|
||||
authDocUrl: '{DOCS_URL}/apps/brave-search/connection',
|
||||
primaryColor: '#181818',
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader, addAcceptHeader],
|
||||
auth,
|
||||
actions,
|
||||
dynamicData,
|
||||
});
|
||||
@@ -6,6 +6,7 @@ exports[`App model > list should have list of applications keys 1`] = `
|
||||
"anthropic",
|
||||
"appwrite",
|
||||
"azure-openai",
|
||||
"brave-search",
|
||||
"carbone",
|
||||
"clickup",
|
||||
"code",
|
||||
|
||||
@@ -59,6 +59,15 @@ export default defineConfig({
|
||||
{ text: 'Connection', link: '/apps/appwrite/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Brave Search',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Actions', link: '/apps/brave-search/actions' },
|
||||
{ text: 'Connection', link: '/apps/brave-search/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Carbone',
|
||||
collapsible: true,
|
||||
|
||||
12
packages/docs/pages/apps/brave-search/actions.md
Normal file
12
packages/docs/pages/apps/brave-search/actions.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/brave-search.svg
|
||||
items:
|
||||
- name: Web search
|
||||
desc: Queries Brave Search and get back search results from the web.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
||||
8
packages/docs/pages/apps/brave-search/connection.md
Normal file
8
packages/docs/pages/apps/brave-search/connection.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Brave Search
|
||||
|
||||
1. Go to [API Keys page](https://api.search.brave.com/app/keys) on Brave Search.
|
||||
2. Create a new API key.
|
||||
3. Paste the key into the `API Key` field in Automatisch.
|
||||
4. Write any screen name to be displayed in Automatisch.
|
||||
5. Click `Save`.
|
||||
6. Start using Brave Search integration with Automatisch!
|
||||
@@ -5,6 +5,7 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Airtable](/apps/airtable/actions)
|
||||
- [Anthropic](/apps/anthropic/actions)
|
||||
- [Appwrite](/apps/appwrite/triggers)
|
||||
- [Brave Search](/apps/brave-search/actions)
|
||||
- [Carbone](/apps/carbone/actions)
|
||||
- [ClickUp](/apps/clickup/triggers)
|
||||
- [Datastore](/apps/datastore/actions)
|
||||
|
||||
5
packages/docs/pages/public/favicons/brave-search.svg
Normal file
5
packages/docs/pages/public/favicons/brave-search.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
aria-label="Brave" role="img"
|
||||
viewBox="0 0 512 512"><path
|
||||
d="m0 0H512V512H0"
|
||||
fill="#fff"/><linearGradient id="a"><stop offset="0" stop-color="#f50"/><stop offset="1" stop-color="#f20"/></linearGradient><path d="M416 158l9-23c-24-25-33-43-72-34l-35-40H194l-35 40c-38-3-45 6-72 34l10 23-12 34 39 150c8 32 14 45 37 61l72 49c7 4 16 12 23 12 8 0 16-8 23-12l72-49c23-16 29-29 37-61l40-150" fill="url(#a)"/><path d="M308 343c8-7-13-16-22-20-10-5-20-8-30-11-10 2-20 6-30 11-9 5-30 11-22 20 15 11 34 27 52 39l52-39m35-216-43 7c-5 0-17-5-27-8s-17-3-17-3-7 0-17 3-22 8-27 8l-43-7s-45 54-45 66c0 16 32 42 45 57 17 13-7 31 3 51 7 12 18 20 25 19 17-5 48-21 55-41-2-15-38-20-45-35 0-15 18-27 17-44-2-15-45-22-59-29-2-2-1-3 6-3 21-3 47-4 66 8 8 19-16 63-3 71 19 3 26 5 45 0 13-3-8-55-4-71 14-11 49-10 66-8 8 0 8 1 6 3-15 5-51 15-59 29-1 13 17 31 17 44-2 14-42 18-44 36 2 19 40 32 55 40 7 1 18-7 24-19 9-16-14-35 3-51 15-15 42-36 45-57 0-12-45-66-45-66" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 996 B |
Reference in New Issue
Block a user