Skip to content

laiso/webchatgpt-retrieval-plugin

 
 

Repository files navigation

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.

// 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,
}
})
}

About

The fork that replaced DuckDuckGo search in WebChatGPT with Retrieval Plugins.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 92.0%
  • JavaScript 6.9%
  • Other 1.1%