mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-08 20:25:19 +02:00
add 'useGithubStarts' hook
This commit is contained in:
parent
5b957ec21c
commit
8007597b50
4 changed files with 48 additions and 13 deletions
|
|
@ -153,8 +153,8 @@ export default function BaiduSearchApiPage() {
|
|||
<CardHeader>
|
||||
<CardTitle className="text-2xl font-bold">Connect Baidu Search</CardTitle>
|
||||
<CardDescription>
|
||||
Integrate with Baidu AI Search to enhance your search capabilities with
|
||||
intelligent Chinese web search results.
|
||||
Integrate with Baidu AI Search to enhance your search capabilities with intelligent
|
||||
Chinese web search results.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
|
|
@ -224,13 +224,9 @@ export default function BaiduSearchApiPage() {
|
|||
<SelectContent>
|
||||
<SelectItem value="ernie-3.5-8k">ERNIE 3.5 8K</SelectItem>
|
||||
<SelectItem value="ernie-4.5-turbo-32k">ERNIE 4.5 Turbo 32K</SelectItem>
|
||||
<SelectItem value="ernie-4.5-turbo-128k">
|
||||
ERNIE 4.5 Turbo 128K
|
||||
</SelectItem>
|
||||
<SelectItem value="ernie-4.5-turbo-128k">ERNIE 4.5 Turbo 128K</SelectItem>
|
||||
<SelectItem value="deepseek-v3">DeepSeek V3</SelectItem>
|
||||
<SelectItem value="qwen3-235b-a22b-instruct-2507">
|
||||
Qwen3 235B
|
||||
</SelectItem>
|
||||
<SelectItem value="qwen3-235b-a22b-instruct-2507">Qwen3 235B</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormDescription>
|
||||
|
|
@ -255,7 +251,9 @@ export default function BaiduSearchApiPage() {
|
|||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="baidu_search_v1">Baidu Search V1</SelectItem>
|
||||
<SelectItem value="baidu_search_v2">Baidu Search V2 (Recommended)</SelectItem>
|
||||
<SelectItem value="baidu_search_v2">
|
||||
Baidu Search V2 (Recommended)
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormDescription>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ const connectorCategories: ConnectorCategory[] = [
|
|||
description: "Connect to Elasticsearch to index and search documents, logs and metrics.",
|
||||
icon: getConnectorIcon(EnumConnectorName.ELASTICSEARCH_CONNECTOR, "h-6 w-6"),
|
||||
status: "available",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "baidu-search-api",
|
||||
title: "Baidu Search",
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ export function SourceDetailSheet({
|
|||
|
||||
// Check if this is a source type that should render directly from node
|
||||
const isDirectRenderSource =
|
||||
sourceType === "TAVILY_API" ||
|
||||
sourceType === "LINKUP_API" ||
|
||||
sourceType === "SEARXNG_API" ||
|
||||
sourceType === "TAVILY_API" ||
|
||||
sourceType === "LINKUP_API" ||
|
||||
sourceType === "SEARXNG_API" ||
|
||||
sourceType === "BAIDU_SEARCH_API";
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
37
surfsense_web/hooks/use-github-starts.ts
Normal file
37
surfsense_web/hooks/use-github-starts.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { useCallback, useEffect, useState } from "react";
|
||||
import { apiClient } from "@/lib/api";
|
||||
|
||||
export const useGithubStarts = () => {
|
||||
const repo = process.env.NEXT_PUBLIC_GITHUB_REPO;
|
||||
const owner = process.env.NEXT_PUBLIC_GITHUB_OWNER;
|
||||
const token = process.env.NEXT_PUBLIC_GITHUB_TOKEN;
|
||||
|
||||
const [starts, setStarts] = useState<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const getStarts = async () => {
|
||||
try {
|
||||
if (!repo || !owner || !token) {
|
||||
throw new Error("Missing GitHub credentials");
|
||||
}
|
||||
const response = await apiClient.get<{ stargazers_count: number }>(
|
||||
`https://api.github.com/repos/${owner}/${repo}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
setStarts(response.stargazers_count);
|
||||
} catch (err) {
|
||||
console.error("Error fetching starts:", err);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
getStarts();
|
||||
}, []);
|
||||
|
||||
return { starts };
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue