diff --git a/src/lib/apis/ollama/index.ts b/src/lib/apis/ollama/index.ts
index 10eddc1c..4dbcd70d 100644
--- a/src/lib/apis/ollama/index.ts
+++ b/src/lib/apis/ollama/index.ts
@@ -167,6 +167,45 @@ export const generateTitle = async (token: string = '', model: string, prompt: s
return res?.response ?? 'New Chat';
};
+export const generatePrompt = async (token: string = '', model: string, conversation: string) => {
+ let error = null;
+
+ if (conversation === '') {
+ conversation = '[You need to start the conversation]';
+ }
+
+ const res = await fetch(`${OLLAMA_API_BASE_URL}/generate`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'text/event-stream',
+ Authorization: `Bearer ${token}`
+ },
+ body: JSON.stringify({
+ model: model,
+ prompt: `Based on the following conversation, you are playing the role of 'USER.' Your task is to provide a thoughtful and appropriate response to the last message in the conversation, taking into account the context and tone of the discussion.
+
+ Conversation:
+ ${conversation}
+
+ As USER, how would you respond to the latest message? If no previous conversation is provided, start a new conversation with a common, friendly greeting or a relevant question. If there is an existing conversation, continue it by providing a thoughtful, relevant, and engaging response.
+ Response:
+ `
+ })
+ }).catch((err) => {
+ console.log(err);
+ if ('detail' in err) {
+ error = err.detail;
+ }
+ return null;
+ });
+
+ if (error) {
+ throw error;
+ }
+
+ return res;
+};
+
export const generateChatCompletion = async (token: string = '', body: object) => {
let error = null;
diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte
index 72782da9..67b8ebf7 100644
--- a/src/lib/components/chat/MessageInput.svelte
+++ b/src/lib/components/chat/MessageInput.svelte
@@ -10,6 +10,7 @@
import AddFilesPlaceholder from '../AddFilesPlaceholder.svelte';
import { SUPPORTED_FILE_TYPE } from '$lib/constants';
import Documents from './MessageInput/Documents.svelte';
+ import Models from './MessageInput/Models.svelte';
export let submitPrompt: Function;
export let stopResponse: Function;
@@ -18,12 +19,17 @@
export let autoScroll = true;
let filesInputElement;
+
let promptsElement;
let documentsElement;
+ let modelsElement;
let inputFiles;
let dragged = false;
+ let user = null;
+ let chatInputPlaceholder = '';
+
export let files = [];
export let fileUploadEnabled = true;
@@ -35,6 +41,15 @@
let speechRecognition;
+ $: if (prompt) {
+ const chatInput = document.getElementById('chat-textarea');
+
+ if (chatInput) {
+ chatInput.style.height = '';
+ chatInput.style.height = Math.min(chatInput.scrollHeight, 200) + 'px';
+ }
+ }
+
const speechRecognitionHandler = () => {
// Check if SpeechRecognition is supported
@@ -79,7 +94,7 @@
console.log('recognition ended');
speechRecognitionListening = false;
if (prompt !== '' && $settings?.speechAutoSend === true) {
- submitPrompt(prompt);
+ submitPrompt(prompt, user);
}
};
@@ -242,6 +257,14 @@
];
}}
/>
+ {:else if prompt.charAt(0) === '@'}
+