|
|
@@ -8,6 +8,7 @@ import React, { useState, useEffect } from 'react';
|
|
|
import { Server, Loader2, AlertCircle, X, Copy, CheckCircle2, Code } from 'lucide-react';
|
|
|
import { localModelApi, LocalModel } from '../services/localModelApi';
|
|
|
import { useToast } from '../contexts/NotificationContext';
|
|
|
+import { copyToClipboard } from '../utils/clipboard';
|
|
|
|
|
|
interface LocalModelListProps {
|
|
|
onUseModel?: (modelId: string) => void;
|
|
|
@@ -42,8 +43,8 @@ const LocalModelList: React.FC<LocalModelListProps> = ({ onUseModel }) => {
|
|
|
setApiExampleModel(model);
|
|
|
};
|
|
|
|
|
|
- const copyToClipboard = async (text: string, key: string) => {
|
|
|
- await navigator.clipboard.writeText(text);
|
|
|
+ const handleCopy = async (text: string, key: string) => {
|
|
|
+ await copyToClipboard(text);
|
|
|
setCopied(key);
|
|
|
setTimeout(() => setCopied(null), 2000);
|
|
|
};
|
|
|
@@ -543,7 +544,7 @@ console.log(data.choices[0].message.content);`;
|
|
|
<div className="flex items-center justify-between mb-2">
|
|
|
<h4 className="text-sm font-medium text-gray-700">cURL</h4>
|
|
|
<button
|
|
|
- onClick={() => copyToClipboard(generateCurlExample(apiExampleModel), 'curl')}
|
|
|
+ onClick={() => handleCopy(generateCurlExample(apiExampleModel), 'curl')}
|
|
|
className="flex items-center gap-1 text-xs text-gray-500 hover:text-blue-600 transition-colors"
|
|
|
>
|
|
|
{copied === 'curl' ? (
|
|
|
@@ -569,7 +570,7 @@ console.log(data.choices[0].message.content);`;
|
|
|
<div className="flex items-center justify-between mb-2">
|
|
|
<h4 className="text-sm font-medium text-gray-700">Python (OpenAI SDK)</h4>
|
|
|
<button
|
|
|
- onClick={() => copyToClipboard(generatePythonExample(apiExampleModel), 'python')}
|
|
|
+ onClick={() => handleCopy(generatePythonExample(apiExampleModel), 'python')}
|
|
|
className="flex items-center gap-1 text-xs text-gray-500 hover:text-blue-600 transition-colors"
|
|
|
>
|
|
|
{copied === 'python' ? (
|
|
|
@@ -595,7 +596,7 @@ console.log(data.choices[0].message.content);`;
|
|
|
<div className="flex items-center justify-between mb-2">
|
|
|
<h4 className="text-sm font-medium text-gray-700">JavaScript (Fetch)</h4>
|
|
|
<button
|
|
|
- onClick={() => copyToClipboard(generateJsExample(apiExampleModel), 'js')}
|
|
|
+ onClick={() => handleCopy(generateJsExample(apiExampleModel), 'js')}
|
|
|
className="flex items-center gap-1 text-xs text-gray-500 hover:text-blue-600 transition-colors"
|
|
|
>
|
|
|
{copied === 'js' ? (
|