Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Community hub integration #2555

Merged
merged 45 commits into from
Nov 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0c617a2
wip hub connection page fe + backend
shatfield4 Oct 29, 2024
3481afb
Merge branch 'master' into 2545-feat-community-hub-integration
shatfield4 Oct 29, 2024
795c87d
lint
shatfield4 Oct 29, 2024
de7866c
implement backend for local hub items + placeholder endpoints to fetc…
shatfield4 Oct 29, 2024
8c56b00
Merge branch 'master' into 2545-feat-community-hub-integration
shatfield4 Oct 29, 2024
1db99ca
fix hebrew translations
shatfield4 Oct 29, 2024
a7757de
Merge branch 'master' into 2545-feat-community-hub-integration
timothycarambat Nov 7, 2024
77b1615
revamp community integration flow
timothycarambat Nov 8, 2024
890fb29
change sidebar
timothycarambat Nov 8, 2024
3f04c71
Auto import if id in URL param
timothycarambat Nov 9, 2024
679c5d0
get user's items + team items from hub + ui improvements to hub settings
shatfield4 Nov 9, 2024
5256b3b
lint
shatfield4 Nov 9, 2024
ac911c0
Merge branch '2545-feat-community-hub-integration' of github.com:Mint…
shatfield4 Nov 9, 2024
e7f9fce
fix merge conflict
shatfield4 Nov 9, 2024
cfce320
refresh hook for community items
timothycarambat Nov 11, 2024
58e73e8
add fallback for user items
shatfield4 Nov 11, 2024
8be4f13
Merge branch '2545-feat-community-hub-integration' of github.com:Mint…
shatfield4 Nov 11, 2024
d5324fc
Disable bundle items by default on all instances
timothycarambat Nov 11, 2024
e2827b2
Merge branch '2545-feat-community-hub-integration' of github.com:Mint…
timothycarambat Nov 11, 2024
78740e4
remove translations (will complete later)
timothycarambat Nov 11, 2024
f4c4b92
loading skeleton
timothycarambat Nov 11, 2024
7e66433
Make community hub endpoints admin only
timothycarambat Nov 11, 2024
3292c71
Merge branch 'master' into 2545-feat-community-hub-integration
timothycarambat Nov 11, 2024
9937089
improve middleware and import flow
timothycarambat Nov 13, 2024
6d55352
Merge branch '2545-feat-community-hub-integration' of github.com:Mint…
timothycarambat Nov 13, 2024
db49983
Merge branch 'master' into 2545-feat-community-hub-integration
shatfield4 Nov 19, 2024
1c0f73f
community hub ui updates
shatfield4 Nov 19, 2024
c3fca12
Merge branch 'master' into 2545-feat-community-hub-integration
shatfield4 Nov 19, 2024
6c4a954
Merge branch 'master' into 2545-feat-community-hub-integration
timothycarambat Nov 21, 2024
7abe3d8
Merge branch 'master' into 2545-feat-community-hub-integration
timothycarambat Nov 21, 2024
539abbb
Adjust importing process
timothycarambat Nov 21, 2024
0ca2ab5
Merge branch 'master' into 2545-feat-community-hub-integration
timothycarambat Nov 21, 2024
a757d99
community hub to dev
timothycarambat Nov 21, 2024
c3a28b6
Merge branch 'master' of github.com:Mintplex-Labs/anything-llm into 2…
timothycarambat Nov 24, 2024
e385037
Add webscraper preload into imported plugins
timothycarambat Nov 25, 2024
bdc3477
add runtime property to plugins
timothycarambat Nov 25, 2024
3fe10db
Fix button status on imported skill change
timothycarambat Nov 25, 2024
b64d573
update documentaion paths
timothycarambat Nov 26, 2024
1e8f399
remove unused import
timothycarambat Nov 26, 2024
2639326
Merge branch 'master' into 2545-feat-community-hub-integration
timothycarambat Nov 26, 2024
1a575a4
Merge branch 'master' into 2545-feat-community-hub-integration
timothycarambat Nov 26, 2024
0f81c50
Merge branch 'master' into 2545-feat-community-hub-integration
timothycarambat Nov 26, 2024
07da923
linting
timothycarambat Nov 26, 2024
fa6cbb2
review loading state
timothycarambat Nov 26, 2024
dcbaee7
Merge branch '2545-feat-community-hub-integration' of github.com:Mint…
timothycarambat Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement backend for local hub items + placeholder endpoints to fetc…
…h hub app data
shatfield4 committed Oct 29, 2024
commit de7866c2b33de3cb2c2c84ed6c127c38b4dabd91
68 changes: 39 additions & 29 deletions frontend/src/models/hub.js
Original file line number Diff line number Diff line change
@@ -16,72 +16,82 @@ const Hub = {
});
},

// Import a new item from the hub
importItem: async (data) => {
return await fetch(`${API_BASE}/hub/items`, {
// Update hub settings (API key, etc.)
updateSettings: async (data) => {
return await fetch(`${API_BASE}/hub/settings`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify(data),
})
.then((res) => {
if (!res.ok) throw new Error("Failed to import item.");
return res.json();
.then(async (res) => {
const response = await res.json();
if (!res.ok)
throw new Error(response.error || "Failed to update settings");
return { success: true, error: null };
})
.catch((e) => ({
success: false,
error: e.message,
}));
},

// Delete an imported item
// Get hub settings
getSettings: async () => {
return await fetch(`${API_BASE}/hub/settings`, {
method: "GET",
headers: baseHeaders(),
})
.then(async (res) => {
const response = await res.json();
if (!res.ok)
throw new Error(response.error || "Failed to fetch settings");
return { settings: response.settings, error: null };
})
.catch((e) => ({
settings: { hasApiKey: false },
error: e.message,
}));
},

// Delete an item
deleteItem: async (id) => {
return await fetch(`${API_BASE}/hub/items/${id}`, {
method: "DELETE",
headers: baseHeaders(),
})
.then((res) => res.ok)
.then((res) => res.json())
.catch((e) => {
console.error(e);
return false;
return { success: false, error: e.message };
});
},

// Get hub API key from system settings
getApiKey: async () => {
return await fetch(`${API_BASE}/system/settings?labels=hub_api_key`, {
method: "GET",
// Import by string
importByString: async (data) => {
return await fetch(`${API_BASE}/hub/import`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((res) => res.settings?.hub_api_key || null)
.catch((e) => {
console.error(e);
return null;
return { success: false, error: e.message };
});
},

// Fetch hub settings (API key, etc.)
getSettings: async () => {
return await fetch(`${API_BASE}/hub/settings`, {
// Explore items
explore: async () => {
return await fetch(`${API_BASE}/hub/explore`, {
method: "GET",
headers: baseHeaders(),
})
.then((res) => res.json())
.then((res) => res.settings)
.catch((e) => {
console.error(e);
return { hasApiKey: false };
return { success: false, error: e.message };
});
},

// Update hub settings (API key, etc.)
updateSettings: async (data) => {
return await fetch(`${API_BASE}/hub/settings`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify(data),
});
},
};

export default Hub;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Trash } from "@phosphor-icons/react";
import { useState } from "react";
import showToast from "@/utils/toast";
import Hub from "@/models/hub";

export default function HubItemRow({ item, onDelete }) {
const [deleting, setDeleting] = useState(false);

const handleDelete = async () => {
if (deleting) return;
setDeleting(true);
const success = await Hub.deleteItem(item.id);
if (!success) {
showToast("Failed to delete item", "error");
setDeleting(false);
return;
}
showToast("Item deleted successfully", "success");
onDelete(item.id);
};

return (
<tr className="bg-transparent text-white text-opacity-80 text-sm font-medium">
<td className="px-6 py-4">{item.name}</td>
<td className="px-6 py-4 capitalize">{item.type}</td>
<td className="px-6 py-4">
{new Date(item.createdAt).toLocaleDateString()}
</td>
<td className="px-6 py-4 cursor-pointer">
<button
onClick={handleDelete}
disabled={deleting}
className="transition-all duration-300 p-2 rounded-lg text-white/60 hover:text-white hover:bg-white/10"
>
<Trash className="h-5 w-5" />
</button>
</td>
</tr>
);
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { useState } from "react";
import ModalWrapper from "@/components/ModalWrapper";
import { X } from "@phosphor-icons/react";

const IMPORT_TYPES = [
{ label: "System Prompt", value: "prompt" },
{ label: "Agent Skill", value: "skill" },
{ label: "Workspace", value: "workspace" },
{ label: "Slash Command", value: "command" },
];
import Hub from "@/models/hub";
import showToast from "@/utils/toast";

export default function ImportModal({ isOpen, closeModal }) {
const [selectedType, setSelectedType] = useState("prompt");
const [importString, setImportString] = useState("");

const handleImport = async (e) => {
e.preventDefault();
// Handle import logic here
const response = await Hub.importByString({ importString });
if (response.success) {
showToast("Items imported successfully", "success");
} else {
showToast(response.error, "error");
}
closeModal();
};

@@ -34,23 +33,6 @@ export default function ImportModal({ isOpen, closeModal }) {

<form onSubmit={handleImport}>
<div className="p-4 space-y-6">
<div>
<label className="block text-sm font-medium text-white mb-2">
Import Type
</label>
<select
value={selectedType}
onChange={(e) => setSelectedType(e.target.value)}
className="bg-zinc-900 border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
>
{IMPORT_TYPES.map((type) => (
<option key={type.value} value={type.value}>
{type.label}
</option>
))}
</select>
</div>

<div>
<label className="block text-sm font-medium text-white mb-2">
Import String
@@ -75,7 +57,7 @@ export default function ImportModal({ isOpen, closeModal }) {
</button>
<button
type="submit"
className="text-white bg-primary-button hover:bg-secondary focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center"
className="text-black bg-primary-button hover:bg-secondary focus:ring-4 focus:outline-none focus:ring-blue-300 hover:text-white font-medium rounded-lg text-sm px-5 py-2.5 text-center"
>
Import
</button>
Loading