mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-12 07:45:14 -05:00
Compare commits
6 Commits
fix/claude
...
zamilmajdy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b54bd5ebc0 | ||
|
|
5048c43859 | ||
|
|
2f670c903d | ||
|
|
4e3df63dcd | ||
|
|
bb24883651 | ||
|
|
c3e17f7b30 |
@@ -1,21 +1,23 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect, useCallback } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { IconRefresh, IconCoin } from "@/components/ui/icons";
|
import { IconRefresh } from "@/components/ui/icons";
|
||||||
import AutoGPTServerAPI from "@/lib/autogpt-server-api";
|
import AutoGPTServerAPI from "@/lib/autogpt-server-api";
|
||||||
|
|
||||||
|
const api = new AutoGPTServerAPI();
|
||||||
|
|
||||||
export default function CreditButton() {
|
export default function CreditButton() {
|
||||||
const [credit, setCredit] = useState<number | null>(null);
|
const [credit, setCredit] = useState<number | null>(null);
|
||||||
const api = new AutoGPTServerAPI();
|
|
||||||
|
|
||||||
const fetchCredit = async () => {
|
const fetchCredit = useCallback(async () => {
|
||||||
const response = await api.getUserCredit();
|
const response = await api.getUserCredit();
|
||||||
setCredit(response.credits);
|
setCredit(response.credits);
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchCredit();
|
fetchCredit();
|
||||||
}, [api]);
|
}, [fetchCredit]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
credit !== null && (
|
credit !== null && (
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ export function CustomNode({ data, id, width, height }: NodeProps<CustomNode>) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleInputClick = (key: string) => {
|
const handleInputClick = (key: string) => {
|
||||||
console.log(`Opening modal for key: ${key}`);
|
console.debug(`Opening modal for key: ${key}`);
|
||||||
setActiveKey(key);
|
setActiveKey(key);
|
||||||
const value = getValue(key);
|
const value = getValue(key);
|
||||||
setInputModalValue(
|
setInputModalValue(
|
||||||
@@ -427,7 +427,7 @@ export function CustomNode({ data, id, width, height }: NodeProps<CustomNode>) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteNode = useCallback(() => {
|
const deleteNode = useCallback(() => {
|
||||||
console.log("Deleting node:", id);
|
console.debug("Deleting node:", id);
|
||||||
|
|
||||||
// Remove the node
|
// Remove the node
|
||||||
deleteElements({ nodes: [{ id }] });
|
deleteElements({ nodes: [{ id }] });
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
BlockIOStringSubSchema,
|
BlockIOStringSubSchema,
|
||||||
BlockIONumberSubSchema,
|
BlockIONumberSubSchema,
|
||||||
BlockIOBooleanSubSchema,
|
BlockIOBooleanSubSchema,
|
||||||
BlockIOCredentialsSubSchema,
|
|
||||||
} from "@/lib/autogpt-server-api/types";
|
} from "@/lib/autogpt-server-api/types";
|
||||||
import React, { FC, useCallback, useEffect, useState } from "react";
|
import React, { FC, useCallback, useEffect, useState } from "react";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
@@ -313,6 +312,18 @@ const NodeCredentialsInput: FC<{
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const InputRef = (value: any): React.RefObject<HTMLInputElement> => {
|
||||||
|
const inputRef = React.useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current && value && inputRef.current.value !== value) {
|
||||||
|
inputRef.current.value = value;
|
||||||
|
}
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
|
return inputRef;
|
||||||
|
};
|
||||||
|
|
||||||
const NodeKeyValueInput: FC<{
|
const NodeKeyValueInput: FC<{
|
||||||
selfKey: string;
|
selfKey: string;
|
||||||
schema: BlockIOKVSubSchema;
|
schema: BlockIOKVSubSchema;
|
||||||
@@ -416,7 +427,7 @@ const NodeKeyValueInput: FC<{
|
|||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Value"
|
placeholder="Value"
|
||||||
defaultValue={value ?? ""}
|
ref={InputRef(value ?? "")}
|
||||||
onBlur={(e) =>
|
onBlur={(e) =>
|
||||||
updateKeyValuePairs(
|
updateKeyValuePairs(
|
||||||
keyValuePairs.toSpliced(index, 1, {
|
keyValuePairs.toSpliced(index, 1, {
|
||||||
@@ -600,7 +611,9 @@ const NodeStringInput: FC<{
|
|||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
id={selfKey}
|
id={selfKey}
|
||||||
defaultValue={schema.secret && value ? "********" : value}
|
ref={InputRef(
|
||||||
|
schema.secret && value ? "*".repeat(value.length) : value,
|
||||||
|
)}
|
||||||
readOnly={schema.secret}
|
readOnly={schema.secret}
|
||||||
placeholder={
|
placeholder={
|
||||||
schema?.placeholder || `Enter ${beautifyString(displayName)}`
|
schema?.placeholder || `Enter ${beautifyString(displayName)}`
|
||||||
@@ -658,7 +671,6 @@ export const NodeTextBoxInput: FC<{
|
|||||||
schema?.placeholder || `Enter ${beautifyString(displayName)}`
|
schema?.placeholder || `Enter ${beautifyString(displayName)}`
|
||||||
}
|
}
|
||||||
onChange={(e) => handleInputChange(selfKey, e.target.value)}
|
onChange={(e) => handleInputChange(selfKey, e.target.value)}
|
||||||
onBlur={(e) => handleInputChange(selfKey, e.target.value)}
|
|
||||||
className="h-full w-full resize-none overflow-hidden border-none bg-transparent text-lg text-black outline-none"
|
className="h-full w-full resize-none overflow-hidden border-none bg-transparent text-lg text-black outline-none"
|
||||||
style={{
|
style={{
|
||||||
fontSize: "min(1em, 16px)",
|
fontSize: "min(1em, 16px)",
|
||||||
@@ -696,7 +708,7 @@ const NodeNumberInput: FC<{
|
|||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
id={selfKey}
|
id={selfKey}
|
||||||
defaultValue={value}
|
ref={InputRef(value)}
|
||||||
onBlur={(e) => handleInputChange(selfKey, parseFloat(e.target.value))}
|
onBlur={(e) => handleInputChange(selfKey, parseFloat(e.target.value))}
|
||||||
placeholder={
|
placeholder={
|
||||||
schema.placeholder || `Enter ${beautifyString(displayName)}`
|
schema.placeholder || `Enter ${beautifyString(displayName)}`
|
||||||
|
|||||||
@@ -45,13 +45,15 @@ const VideoRenderer: React.FC<{ videoUrl: string }> = ({ videoUrl }) => {
|
|||||||
|
|
||||||
const ImageRenderer: React.FC<{ imageUrl: string }> = ({ imageUrl }) => (
|
const ImageRenderer: React.FC<{ imageUrl: string }> = ({ imageUrl }) => (
|
||||||
<div className="w-full p-2">
|
<div className="w-full p-2">
|
||||||
<img
|
<picture>
|
||||||
src={imageUrl}
|
<img
|
||||||
alt="Image"
|
src={imageUrl}
|
||||||
className="h-auto max-w-full"
|
alt="Image"
|
||||||
width="100%"
|
className="h-auto max-w-full"
|
||||||
height="auto"
|
width="100%"
|
||||||
/>
|
height="auto"
|
||||||
|
/>
|
||||||
|
</picture>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -747,6 +747,9 @@ export default function useAgentGraph(
|
|||||||
api,
|
api,
|
||||||
nodes,
|
nodes,
|
||||||
edges,
|
edges,
|
||||||
|
pathname,
|
||||||
|
router,
|
||||||
|
searchParams,
|
||||||
savedAgent,
|
savedAgent,
|
||||||
agentName,
|
agentName,
|
||||||
agentDescription,
|
agentDescription,
|
||||||
|
|||||||
@@ -26,13 +26,10 @@ export function deepEquals(x: any, y: any): boolean {
|
|||||||
ty = typeof y;
|
ty = typeof y;
|
||||||
|
|
||||||
const res =
|
const res =
|
||||||
x &&
|
x && y && tx === ty && tx === "object"
|
||||||
y &&
|
|
||||||
tx === ty &&
|
|
||||||
(tx === "object"
|
|
||||||
? ok(x).length === ok(y).length &&
|
? ok(x).length === ok(y).length &&
|
||||||
ok(x).every((key) => deepEquals(x[key], y[key]))
|
ok(x).every((key) => deepEquals(x[key], y[key]))
|
||||||
: x === y);
|
: x === y;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user