Mintplex-Labs / anything-llm

The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, and more.
https://anythingllm.com
MIT License
27.48k stars 2.77k forks source link

[BUG]: AnythingLLM does not query right LM Studio model for a given role. #2496

Closed joselael closed 1 month ago

joselael commented 1 month ago

How are you running AnythingLLM?

AnythingLLM desktop app

What happened?

I have two models running in the lm studio server. I set my workspace and system model to deepseek-coder-v2-lite, and agent to llama-groq-tool-use

image image

However when I do @agent [something that should trigger a tool] I can see in the LM Studio server logs that Anything LLM actually selected the system/chat model: Received POST request to /v1/chat/completions with body: { "model": "deepseek-coder-v2-lite-instruct-4bit-mlx", "temperature": 0, "messages": [ { "content": "You are a program which picks the most optimal function and parameters to call.\n DO NOT HAVE TO PICK A FUNCTION IF IT WILL NOT HELP ANSWER OR FULFILL THE USER'S QUERY.\n When a function is selection, respond in JSON with no additional text.\n When there is no relevant function to call - return with a regular chat text response.\n Your task is to pick a **single** function that we will use to call, if any seem useful or relevant for the user query.\n\n All JSON responses should have two keys.\n 'name': this is the name of the function name to call. eg: 'web-scraper', 'rag-memory', etc..\n 'arguments': this is an object with the function properties to invoke the function.\n DO NOT INCLUDE ANY OTHER KEYS IN JSON RESPONSES.\n\n Here are the available tools you can use an examples of a query and response so you can understand how each one works.\n -----------\nFunction name: rag-memory\nFunction Description: Search against local documents for context that is relevant to the query or store a snippet of text into memory for retrieval later. Storing information should only be done when the user specifically requests for information to be remembered or saved to long-term memory. You should use this tool before search the internet for information. Do not use this tool unless you are explicity told to 'remember' or 'store' information.\nFunction parameters in JSON format:\n{\n \"action\": {\n \"type\": \"string\",\n \"enum\": [\n \"search\",\n \"store\"\n ],\n \"description\": \"The action we want to take to search for existing similar context or storage of new context.\"\n },\n \"content\": {\n \"type\": \"string\",\n \"description\": \"The plain text to search our local documents with or to store in our vector database.\"\n }\n}\nQuery: \"What is AnythingLLM?\"\nJSON: {\"action\":\"search\",\"content\":\"What is AnythingLLM?\"}\nQuery: \"What do you know about Plato's motives?\"\nJSON: {\"action\":\"search\",\"content\":\"What are the facts about Plato's motives?\"}\nQuery: \"Remember that you are a robot\"\nJSON: {\"action\":\"store\",\"content\":\"I am a robot, the user told me that i am.\"}\nQuery: \"Save that to memory please.\"\nJSON: {\"action\":\"store\",\"content\":\"<insert summary of conversation until now>\"}\n-----------\n-----------\nFunction name: document-summarizer\nFunction Description: Can get the list of files available to search with descriptions and can select a single file to open and summarize.\nFunction parameters in JSON format:\n{\n \"action\": {\n \"type\": \"string\",\n \"enum\": [\n \"list\",\n \"summarize\"\n ],\n \"description\": \"The action to take. 'list' will return all files available with their filename and descriptions. 'summarize' will open and summarize the file by the a document name.\"\n },\n \"document_filename\": {\n \"type\": \"string\",\n \"x-nullable\": true,\n \"description\": \"The file name of the document you want to get the full content of.\"\n }\n}\nQuery: \"Summarize example.txt\"\nJSON: {\"action\":\"summarize\",\"document_filename\":\"example.txt\"}\nQuery: \"What files can you see?\"\nJSON: {\"action\":\"list\",\"document_filename\":null}\nQuery: \"Tell me about readme.md\"\nJSON: {\"action\":\"summarize\",\"document_filename\":\"readme.md\"}\n-----------\n-----------\nFunction name: web-scraping\nFunction Description: Scrapes the content of a webpage or online resource from a provided URL.\nFunction parameters in JSON format:\n{\n \"url\": {\n \"type\": \"string\",\n \"format\": \"uri\",\n \"description\": \"A complete web address URL including protocol. Assumes https if not provided.\"\n }\n}\nQuery: \"What is anythingllm.com about?\"\nJSON: {\"url\":\"https://anythingllm.com\"}\nQuery: \"Scrape https://example.com\"\nJSON: {\"url\":\"https://example.com\"}\n-----------\n-----------\nFunction name: save-file-to-browser\nFunction Description: Save content to a file when the user explicity asks for a download of the file.\nFunction parameters in JSON format:\n{\n \"file_content\": {\n \"type\": \"string\",\n \"description\": \"The content of the file that will be saved.\"\n },\n \"filename\": {\n \"type\": \"string\",\n \"description\": \"filename to save the file as with extension. Extension should be plaintext file extension.\"\n }\n}\nQuery: \"Save me that to a file named 'output'\"\nJSON: {\"file_content\":\"<content of the file we will write previous conversation>\",\"filename\":\"output.txt\"}\nQuery: \"Save me that to my desktop\"\nJSON: {\"file_content\":\"<content of the file we will write previous conversation>\",\"filename\":\"<relevant filename>.txt\"}\nQuery: \"Save me that to a file\"\nJSON: {\"file_content\":\"<content of the file we will write from previous conversation>\",\"filename\":\"<descriptive filename>.txt\"}\n-----------\n-----------\nFunction name: create-chart\nFunction Description: Generates the JSON data required to generate a RechartJS chart to the user based on their prompt and available data.\nFunction parameters in JSON format:\n{\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"area\",\n \"bar\",\n \"line\",\n \"composed\",\n \"scatter\",\n \"pie\",\n \"radar\",\n \"radialBar\",\n \"treemap\",\n \"funnel\"\n ],\n \"description\": \"The type of chart to be generated.\"\n },\n \"title\": {\n \"type\": \"string\",\n \"description\": \"Title of the chart. There MUST always be a title. Do not leave it blank.\"\n },\n \"dataset\": {\n \"type\": \"string\",\n \"description\": \"Valid JSON in which each element is an object for Recharts API for the 'type' of chart defined WITHOUT new line characters. Strictly using this FORMAT and naming:\\n{ \\\"name\\\": \\\"a\\\", \\\"value\\\": 12 }].\\nMake sure field \\\"name\\\" always stays named \\\"name\\\". Instead of naming value field value in JSON, name it based on user metric and make it the same across every item.\\nMake sure the format use double quotes and property names are string literals. Provide JSON data only.\"\n }\n}\n-----------\n-----------\nFunction name: web-browsing\nFunction Description: Searches for a given query using a search engine to get better results for the user query.\nFunction parameters in JSON format:\n{\n \"query\": {\n \"type\": \"string\",\n \"description\": \"A search query.\"\n }\n}\nQuery: \"Who won the world series today?\"\nJSON: {\"query\":\"Winner of today's world series\"}\nQuery: \"What is AnythingLLM?\"\nJSON: {\"query\":\"AnythingLLM\"}\nQuery: \"Current AAPL stock price\"\nJSON: {\"query\":\"AAPL stock price today\"}\n-----------\n\n\n Now pick a function if there is an appropriate one to use given the last user message and the given conversation so far.", "role": "system" }, { "content": "Hey", "role": "user" }, { "content": " Hello! How can I assist you today?", "role": "assistant" }, { "content": "@agent search the web for the current time in sf", "role": "user" } ] }

Are there known steps to reproduce?

Setup AnythingLLM to use LM Studio for both system/chat and agent. Load two models in LM Studio. Select one as the agent model, and the other as the chat model in AnythingLLM. Observed behavior: AnythingLLM makes post request to workspace LLM not agent - as shown in the LM Studio log in the description.