Switch task model and add max tokens limits (#1036)
Browse filesFiles changed (4)
245 unmodified lines246247248249250251252245 unmodified lines{"name": "openchat/openchat-3.5-0106"}]`TASK_MODEL='mistralai/Mistral-7B-Instruct-v0.1'APP_BASE="/chat"PUBLIC_ORIGIN=https://huggingface.co245 unmodified lines246247248249250251252245 unmodified lines{"name": "openchat/openchat-3.5-0106"}]`TASK_MODEL='meta-llama/Meta-Llama-3-70B-Instruct'APP_BASE="/chat"PUBLIC_ORIGIN=https://huggingface.co
3 unmodified lines456789101112131415163 unmodified linesexport async function generateFromDefaultEndpoint({messages,preprompt,}: {messages: Omit<Conversation["messages"][0], "id">[];preprompt?: string;}): Promise<string> {const endpoint = await smallModel.getEndpoint();const tokenStream = await endpoint({ messages, preprompt });for await (const output of tokenStream) {// if not generated_text is here it means the generation is not done3 unmodified lines4567891011121314151617183 unmodified linesexport async function generateFromDefaultEndpoint({messages,preprompt,generateSettings,}: {messages: Omit<Conversation["messages"][0], "id">[];preprompt?: string;generateSettings?: Record<string, unknown>;}): Promise<string> {const endpoint = await smallModel.getEndpoint();const tokenStream = await endpoint({ messages, preprompt, generateSettings });for await (const output of tokenStream) {// if not generated_text is here it means the generation is not done
26 unmodified lines2728293031323326 unmodified linesreturn await generateFromDefaultEndpoint({messages,preprompt: `You are a summarization AI. You'll never answer a user's question directly, but instead summarize the user's request into a single short sentence of four words or less. Always start your answer with an emoji relevant to the summary.`,}).then((summary) => {// add an emoji if none is found in the first three characters26 unmodified lines272829303132333435363726 unmodified linesreturn await generateFromDefaultEndpoint({messages,preprompt:"You are a summarization AI. Summarize the user's request into a single short sentence of four words or less. Do not try to answer it, only summarize the user's query. Always start your answer with an emoji relevant to the summary",generateSettings: {max_new_tokens: 15,},}).then((summary) => {// add an emoji if none is found in the first three characters
63 unmodified lines64656667686963 unmodified linesconst webQuery = await generateFromDefaultEndpoint({messages: convQuery,preprompt: `You are tasked with generating web search queries. Give me an appropriate query to answer my question for google search. Answer with only the query. Today is ${currentDate}`,});return webQuery.trim();63 unmodified lines64656667686970717263 unmodified linesconst webQuery = await generateFromDefaultEndpoint({messages: convQuery,preprompt: `You are tasked with generating web search queries. Give me an appropriate query to answer my question for google search. Answer with only the query. Today is ${currentDate}`,generateSettings: {max_new_tokens: 30,},});return webQuery.trim();
.env.template+1-1
src/lib/server/generateFromDefaultEndpoint.ts+3-1
src/lib/server/summarize.ts+5-1
src/lib/server/websearch/generateQuery.ts+3