Merge pull request #669 from thecodacus/prompt-url-params
Browse files- app/commit.json +1 -1
- app/components/chat/Chat.client.tsx +20 -0
app/commit.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{ "commit": "
|
|
|
1 |
+
{ "commit": "e3bdd6944be8e4b4a6bb6c81f569fb3d5f444942" }
|
app/components/chat/Chat.client.tsx
CHANGED
@@ -20,6 +20,7 @@ import Cookies from 'js-cookie';
|
|
20 |
import { debounce } from '~/utils/debounce';
|
21 |
import { useSettings } from '~/lib/hooks/useSettings';
|
22 |
import type { ProviderInfo } from '~/types/model';
|
|
|
23 |
|
24 |
const toastAnimation = cssTransition({
|
25 |
enter: 'animated fadeInRight',
|
@@ -92,6 +93,7 @@ export const ChatImpl = memo(
|
|
92 |
const [chatStarted, setChatStarted] = useState(initialMessages.length > 0);
|
93 |
const [uploadedFiles, setUploadedFiles] = useState<File[]>([]); // Move here
|
94 |
const [imageDataList, setImageDataList] = useState<string[]>([]); // Move here
|
|
|
95 |
const files = useStore(workbenchStore.files);
|
96 |
const { activeProviders, promptId } = useSettings();
|
97 |
|
@@ -138,6 +140,24 @@ export const ChatImpl = memo(
|
|
138 |
initialMessages,
|
139 |
initialInput: Cookies.get(PROMPT_COOKIE_KEY) || '',
|
140 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
const { enhancingPrompt, promptEnhanced, enhancePrompt, resetEnhancer } = usePromptEnhancer();
|
143 |
const { parsedMessages, parseMessages } = useMessageParser();
|
|
|
20 |
import { debounce } from '~/utils/debounce';
|
21 |
import { useSettings } from '~/lib/hooks/useSettings';
|
22 |
import type { ProviderInfo } from '~/types/model';
|
23 |
+
import { useSearchParams } from '@remix-run/react';
|
24 |
|
25 |
const toastAnimation = cssTransition({
|
26 |
enter: 'animated fadeInRight',
|
|
|
93 |
const [chatStarted, setChatStarted] = useState(initialMessages.length > 0);
|
94 |
const [uploadedFiles, setUploadedFiles] = useState<File[]>([]); // Move here
|
95 |
const [imageDataList, setImageDataList] = useState<string[]>([]); // Move here
|
96 |
+
const [searchParams, setSearchParams] = useSearchParams();
|
97 |
const files = useStore(workbenchStore.files);
|
98 |
const { activeProviders, promptId } = useSettings();
|
99 |
|
|
|
140 |
initialMessages,
|
141 |
initialInput: Cookies.get(PROMPT_COOKIE_KEY) || '',
|
142 |
});
|
143 |
+
useEffect(() => {
|
144 |
+
const prompt = searchParams.get('prompt');
|
145 |
+
console.log(prompt, searchParams, model, provider);
|
146 |
+
|
147 |
+
if (prompt) {
|
148 |
+
setSearchParams({});
|
149 |
+
runAnimation();
|
150 |
+
append({
|
151 |
+
role: 'user',
|
152 |
+
content: [
|
153 |
+
{
|
154 |
+
type: 'text',
|
155 |
+
text: `[Model: ${model}]\n\n[Provider: ${provider.name}]\n\n${prompt}`,
|
156 |
+
},
|
157 |
+
] as any, // Type assertion to bypass compiler check
|
158 |
+
});
|
159 |
+
}
|
160 |
+
}, [model, provider, searchParams]);
|
161 |
|
162 |
const { enhancingPrompt, promptEnhanced, enhancePrompt, resetEnhancer } = usePromptEnhancer();
|
163 |
const { parsedMessages, parseMessages } = useMessageParser();
|