(e: any)
| 12 | const [loading, setLoading] = useState(false); |
| 13 | |
| 14 | const handleSubmit = async (e: any) => { |
| 15 | e.preventDefault(); |
| 16 | if (!prompt.trim()) return; |
| 17 | |
| 18 | setLoading(true); |
| 19 | try { |
| 20 | const response = await fetch('/api/langbase/pipes/run-tool', { |
| 21 | method: 'POST', |
| 22 | headers: {'Content-Type': 'application/json'}, |
| 23 | // Send prompt as an LLM message. |
| 24 | body: JSON.stringify({ |
| 25 | messages: [{role: 'user', content: prompt}], |
| 26 | }), |
| 27 | }); |
| 28 | |
| 29 | if (!response.ok) { |
| 30 | throw new Error('Network response was not ok'); |
| 31 | } |
| 32 | |
| 33 | // Parse the JSON response. |
| 34 | const data = await response.json(); |
| 35 | setCompletion(data.completion); |
| 36 | } catch (error) { |
| 37 | console.error('Error:', error); |
| 38 | setCompletion('An error occurred while generating the completion.'); |
| 39 | } finally { |
| 40 | setLoading(false); |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | return ( |
| 45 | <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