clean
This commit is contained in:
74
internal/api-harness/src/pages/core/CreateSignedUrl.jsx
Normal file
74
internal/api-harness/src/pages/core/CreateSignedUrl.jsx
Normal file
@@ -0,0 +1,74 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import ApiResponse from "@/components/ApiResponse";
|
||||
import { krowSDK } from "@/api/krowSDK";
|
||||
import { Card, CardHeader, CardTitle, CardContent, CardDescription } from "@/components/ui/card";
|
||||
|
||||
const CreateSignedUrl = () => {
|
||||
const [response, setResponse] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [formData, setFormData] = useState({
|
||||
file_uri: "gs://your-bucket/private-file.pdf",
|
||||
expires_in: 3600,
|
||||
});
|
||||
|
||||
const handleChange = (e) => {
|
||||
const { id, value } = e.target;
|
||||
setFormData(prev => ({ ...prev, [id]: value }));
|
||||
};
|
||||
|
||||
const handleCreateUrl = async (e) => {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setResponse(null);
|
||||
try {
|
||||
const params = {
|
||||
...formData,
|
||||
expires_in: parseInt(formData.expires_in, 10),
|
||||
};
|
||||
const res = await krowSDK.integrations.Core.CreateFileSignedUrl(params);
|
||||
setResponse(res);
|
||||
} catch (err) {
|
||||
setError(err.response?.data || err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-slate-900 mb-4">Create Signed URL</h1>
|
||||
<p className="text-slate-600 mb-6">Tests the `integrations.Core.CreateFileSignedUrl` endpoint.</p>
|
||||
|
||||
<Card className="max-w-2xl">
|
||||
<CardHeader>
|
||||
<CardTitle>Test `/createSignedUrl`</CardTitle>
|
||||
<CardDescription>Creates a temporary access URL for a private file stored in GCS.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleCreateUrl} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="file_uri">File URI</Label>
|
||||
<Input id="file_uri" value={formData.file_uri} onChange={handleChange} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="expires_in">Expires In (seconds)</Label>
|
||||
<Input id="expires_in" type="number" value={formData.expires_in} onChange={handleChange} />
|
||||
</div>
|
||||
<Button type="submit" disabled={loading}>
|
||||
{loading ? "Creating..." : "Create Signed URL"}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<ApiResponse response={response} error={error} loading={loading} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CreateSignedUrl;
|
||||
81
internal/api-harness/src/pages/core/InvokeLLM.jsx
Normal file
81
internal/api-harness/src/pages/core/InvokeLLM.jsx
Normal file
@@ -0,0 +1,81 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import ApiResponse from "@/components/ApiResponse";
|
||||
import { krowSDK } from "@/api/krowSDK";
|
||||
import { Card, CardHeader, CardTitle, CardContent, CardDescription } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
const InvokeLLM = () => {
|
||||
const [response, setResponse] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [formData, setFormData] = useState({
|
||||
prompt: "Extract the total amount from the attached invoice.",
|
||||
response_json_schema: JSON.stringify({ type: "object", properties: { total_amount: { type: "number" } } }, null, 2),
|
||||
file_urls: "https://example.com/invoice.pdf",
|
||||
});
|
||||
|
||||
const handleChange = (e) => {
|
||||
const { id, value } = e.target;
|
||||
setFormData(prev => ({ ...prev, [id]: value }));
|
||||
};
|
||||
|
||||
const handleInvokeLLM = async (e) => {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setResponse(null);
|
||||
try {
|
||||
const params = {
|
||||
...formData,
|
||||
response_json_schema: JSON.parse(formData.response_json_schema),
|
||||
file_urls: formData.file_urls.split(',').map(url => url.trim()),
|
||||
};
|
||||
const res = await krowSDK.integrations.Core.InvokeLLM(params);
|
||||
setResponse(res);
|
||||
} catch (err) {
|
||||
setError(err.response?.data || err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-slate-900 mb-4">Invoke LLM</h1>
|
||||
<p className="text-slate-600 mb-6">Tests the `integrations.Core.InvokeLLM` endpoint.</p>
|
||||
|
||||
<Card className="max-w-2xl">
|
||||
<CardHeader>
|
||||
<CardTitle>Test `/invokeLLM`</CardTitle>
|
||||
<CardDescription>Calls a large language model (e.g., Vertex AI).</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleInvokeLLM} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="prompt">Prompt</Label>
|
||||
<Textarea id="prompt" value={formData.prompt} onChange={handleChange} rows={4} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="response_json_schema">Response JSON Schema</Label>
|
||||
<Textarea id="response_json_schema" value={formData.response_json_schema} onChange={handleChange} rows={6} className="font-mono" />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="file_urls">File URLs (comma-separated)</Label>
|
||||
<Input id="file_urls" value={formData.file_urls} onChange={handleChange} />
|
||||
</div>
|
||||
<Button type="submit" disabled={loading}>
|
||||
{loading ? "Invoking..." : "Invoke LLM"}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<ApiResponse response={response} error={error} loading={loading} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default InvokeLLM;
|
||||
75
internal/api-harness/src/pages/core/SendEmail.jsx
Normal file
75
internal/api-harness/src/pages/core/SendEmail.jsx
Normal file
@@ -0,0 +1,75 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import ApiResponse from "@/components/ApiResponse";
|
||||
import { krowSDK } from "@/api/krowSDK";
|
||||
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
||||
|
||||
const SendEmail = () => {
|
||||
const [response, setResponse] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [formData, setFormData] = useState({
|
||||
to: "test@example.com",
|
||||
subject: "Test Email from Harness",
|
||||
body: "This is a test email.",
|
||||
});
|
||||
|
||||
const handleChange = (e) => {
|
||||
const { id, value } = e.target;
|
||||
setFormData(prev => ({ ...prev, [id]: value }));
|
||||
};
|
||||
|
||||
const handleSendEmail = async (e) => {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setResponse(null);
|
||||
try {
|
||||
const res = await krowSDK.integrations.Core.SendEmail(formData);
|
||||
setResponse(res);
|
||||
} catch (err) {
|
||||
setError(err.response?.data || err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-slate-900 mb-4">Send Email</h1>
|
||||
<p className="text-slate-600 mb-6">Tests the `integrations.Core.SendEmail` endpoint.</p>
|
||||
|
||||
<Card className="max-w-2xl">
|
||||
<CardHeader>
|
||||
<CardTitle>Test `/sendEmail`</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleSendEmail} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="to">To</Label>
|
||||
<Input id="to" type="email" value={formData.to} onChange={handleChange} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="subject">Subject</Label>
|
||||
<Input id="subject" value={formData.subject} onChange={handleChange} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="body">Body</Label>
|
||||
<Textarea id="body" value={formData.body} onChange={handleChange} rows={5} />
|
||||
</div>
|
||||
<Button type="submit" disabled={loading}>
|
||||
{loading ? "Sending..." : "Send Email"}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<ApiResponse response={response} error={error} loading={loading} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SendEmail;
|
||||
67
internal/api-harness/src/pages/core/UploadFile.jsx
Normal file
67
internal/api-harness/src/pages/core/UploadFile.jsx
Normal file
@@ -0,0 +1,67 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import ApiResponse from "@/components/ApiResponse";
|
||||
import { krowSDK } from "@/api/krowSDK";
|
||||
import { Card, CardHeader, CardTitle, CardContent, CardDescription } from "@/components/ui/card";
|
||||
|
||||
const UploadFile = () => {
|
||||
const [response, setResponse] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [file, setFile] = useState(null);
|
||||
|
||||
const handleFileChange = (e) => {
|
||||
setFile(e.target.files[0]);
|
||||
};
|
||||
|
||||
const handleUpload = async (e) => {
|
||||
e.preventDefault();
|
||||
if (!file) {
|
||||
setError({ message: "Please select a file to upload." });
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setResponse(null);
|
||||
|
||||
try {
|
||||
const res = await krowSDK.integrations.Core.UploadFile({ file });
|
||||
setResponse(res);
|
||||
} catch (err) {
|
||||
setError(err.response?.data || err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-slate-900 mb-4">Upload Public File</h1>
|
||||
<p className="text-slate-600 mb-6">Tests the `integrations.Core.UploadFile` endpoint for public files.</p>
|
||||
|
||||
<Card className="max-w-2xl">
|
||||
<CardHeader>
|
||||
<CardTitle>Test `/uploadFile`</CardTitle>
|
||||
<CardDescription>Handles multipart/form-data upload to GCS and returns a public URL.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleUpload} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="file">File</Label>
|
||||
<Input id="file" type="file" onChange={handleFileChange} />
|
||||
</div>
|
||||
<Button type="submit" disabled={loading || !file}>
|
||||
{loading ? "Uploading..." : "Upload File"}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<ApiResponse response={response} error={error} loading={loading} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default UploadFile;
|
||||
67
internal/api-harness/src/pages/core/UploadPrivateFile.jsx
Normal file
67
internal/api-harness/src/pages/core/UploadPrivateFile.jsx
Normal file
@@ -0,0 +1,67 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import ApiResponse from "@/components/ApiResponse";
|
||||
import { krowSDK } from "@/api/krowSDK";
|
||||
import { Card, CardHeader, CardTitle, CardContent, CardDescription } from "@/components/ui/card";
|
||||
|
||||
const UploadPrivateFile = () => {
|
||||
const [response, setResponse] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [file, setFile] = useState(null);
|
||||
|
||||
const handleFileChange = (e) => {
|
||||
setFile(e.target.files[0]);
|
||||
};
|
||||
|
||||
const handleUpload = async (e) => {
|
||||
e.preventDefault();
|
||||
if (!file) {
|
||||
setError({ message: "Please select a file to upload." });
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setResponse(null);
|
||||
|
||||
try {
|
||||
const res = await krowSDK.integrations.Core.UploadPrivateFile({ file });
|
||||
setResponse(res);
|
||||
} catch (err) {
|
||||
setError(err.response?.data || err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-slate-900 mb-4">Upload Private File</h1>
|
||||
<p className="text-slate-600 mb-6">Tests the `integrations.Core.UploadPrivateFile` endpoint.</p>
|
||||
|
||||
<Card className="max-w-2xl">
|
||||
<CardHeader>
|
||||
<CardTitle>Test `/uploadPrivateFile`</CardTitle>
|
||||
<CardDescription>Handles multipart/form-data upload to GCS and returns a secure gs:// URI.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleUpload} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="file">File</Label>
|
||||
<Input id="file" type="file" onChange={handleFileChange} />
|
||||
</div>
|
||||
<Button type="submit" disabled={loading || !file}>
|
||||
{loading ? "Uploading..." : "Upload File"}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<ApiResponse response={response} error={error} loading={loading} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default UploadPrivateFile;
|
||||
Reference in New Issue
Block a user