This repository is a fork of qunash/chatgpt-advanced. It uses ChatGPT Retrieval Plugins instead of DuckDuckGo for search.
You can pass search results to WebChatGPT by replacing the following line with the URL of your plugin.
webchatgpt-retrieval-plugin/src/content-scripts/ddg_search.ts
Lines 5 to 55 in 65cb799
// ChatGPT Retrieval Plugin Endpoint | |
const BASE_URL = 'http://localhost:3333' | |
export interface SearchRequest { | |
query: string | |
timerange: string | |
region: string | |
} | |
export interface SearchResponse { | |
metadata: { | |
title: string; | |
url: string; | |
}; | |
text: string; | |
} | |
export interface SearchResult { | |
title: string | |
body: string | |
url: string | |
} | |
export async function getHtml({ query, timerange, region }: SearchRequest): Promise<SearchResult[]> { | |
const headers = { | |
'Content-Type': 'application/json', | |
Accept: 'application/json', | |
} | |
const response = await fetch(`${BASE_URL}/query`, { | |
method: 'POST', | |
headers, | |
body: JSON.stringify({ | |
queries: [{query}] | |
}), | |
}) | |
if (!response.ok) { | |
throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`) | |
} | |
const json = await response.json(); | |
return json.results[0].results.map((result: SearchResponse) => { | |
return { | |
title: result.metadata.title, | |
body: result.text, | |
url: result.metadata.url, | |
} | |
}) | |
} |