-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
80 lines (73 loc) · 2.49 KB
/
Copy pathApp.tsx
File metadata and controls
80 lines (73 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React, { useState, useCallback } from 'react';
import { PromptFormData, OptimizationResult } from './types';
import { optimizePrompt } from './services/geminiService';
import InputForm from './components/InputForm';
import OutputDisplay from './components/OutputDisplay';
const App: React.FC = () => {
const [formData, setFormData] = useState<PromptFormData>({
source_prompt: '',
llm: '',
accuracy: '',
failure_modes: '',
cost: '',
});
const [isLoading, setIsLoading] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
const [result, setResult] = useState<OptimizationResult | null>(null);
const handleSubmit = useCallback(async () => {
if (!formData.source_prompt.trim()) {
setError('The source prompt cannot be empty.');
return;
}
setIsLoading(true);
setError(null);
setResult(null);
try {
const optimizationResult = await optimizePrompt(formData);
setResult(optimizationResult);
} catch (e) {
console.error(e);
setError('Failed to optimize prompt. Please check the console for more details.');
} finally {
setIsLoading(false);
}
}, [formData]);
return (
<div className="min-h-screen bg-gray-950 text-gray-200 font-sans">
<header className="bg-gray-950/70 backdrop-blur-lg sticky top-0 z-10 border-b border-gray-700">
<div className="container mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex items-center justify-between h-16">
<div className="flex items-center">
<h1 className="text-xl font-bold text-gray-50">
Prompt Engineer
</h1>
</div>
</div>
</div>
</header>
<main className="container mx-auto p-4 sm:p-6 lg:p-8">
<div className="grid grid-cols-1 md:grid-cols-2 md:gap-8">
<div className="flex flex-col">
<InputForm
formData={formData}
setFormData={setFormData}
onSubmit={handleSubmit}
isLoading={isLoading}
/>
</div>
<div className="mt-8 md:mt-0">
<OutputDisplay
result={result}
isLoading={isLoading}
error={error}
/>
</div>
</div>
</main>
<footer className="text-center p-4 mt-8 border-t border-gray-800">
<p className="text-sm text-gray-500">Powered by Gemini</p>
</footer>
</div>
);
};
export default App;