(e: any)
| 10 | const [loading, setLoading] = useState(false); |
| 11 | |
| 12 | const handleSubmit = async (e: any) => { |
| 13 | e.preventDefault(); |
| 14 | if (!prompt.trim()) return; |
| 15 | |
| 16 | setLoading(true); |
| 17 | try { |
| 18 | const response = await fetch('/api/langbase/pipes/run-tool', { |
| 19 | method: 'POST', |
| 20 | headers: { 'Content-Type': 'application/json' }, |
| 21 | // Send prompt as an LLM message. |
| 22 | body: JSON.stringify({ |
| 23 | messages: [{ role: 'user', content: prompt }], |
| 24 | }), |
| 25 | }); |
| 26 | |
| 27 | if (!response.ok) { |
| 28 | throw new Error('Network response was not ok'); |
| 29 | } |
| 30 | |
| 31 | // Parse the JSON response. |
| 32 | const data = await response.json(); |
| 33 | setCompletion(data.completion); |
| 34 | } catch (error) { |
| 35 | console.error('Error:', error); |
| 36 | setCompletion('An error occurred while generating the completion.'); |
| 37 | } finally { |
| 38 | setLoading(false); |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | return ( |
| 43 | <div className="bg-neutral-200 rounded-md p-2 flex flex-col gap-2 w-full"> |
nothing calls this directly
no outgoing calls
no test coverage detected