There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): provide photoengine (#6574)
pengx17f9f0490190c2
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/provider.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/provider.tsindex 5537522d35..f5d7e83f26 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/provider.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/provider.ts@@ -1,4 +1,5 @@import { openSettingModalAtom } from '@affine/core/atoms';+import { getBaseUrl } from '@affine/graphql';import { assertExists } from '@blocksuite/global/utils';import { AIProvider } from '@blocksuite/presets';import { getCurrentStore } from '@toeverything/infra';@@ -266,6 +267,29 @@ export function setupAIProvider() {});});+ AIProvider.provide('photoEngine', {+ async searchImages(options): Promise<string[]> {+ const url = new URL(getBaseUrl() + '/api/copilot/unsplash/photos');+ url.searchParams.set('query', options.query);+ const result: {+ results: {+ urls: {+ regular: string;+ };+ }[];+ } = await fetch(url.toString()).then(res => res.json());+ return result.results.map(r => {+ const url = new URL(r.urls.regular);+ url.searchParams.set('fit', 'crop');+ url.searchParams.set('crop', 'edges');+ url.searchParams.set('dpr', (window.devicePixelRatio ?? 2).toString());+ url.searchParams.set('w', `${options.width}`);+ url.searchParams.set('h', `${options.height}`);+ return url.toString();+ });+ },+ });+AIProvider.slots.requestUpgradePlan.on(() => {getCurrentStore().set(openSettingModalAtom, {activeTab: 'billing',