gptscript-ai / desktop

MIT License
22 stars 13 forks source link

Knowledge tool is not able to work with files from the workspace set for the thread. #158

Closed sangee2004 closed 3 months ago

sangee2004 commented 3 months ago

Electron app from commit id d2a9e6ecef

Steps to reproduce the problem:

  1. Create an assistant with knowledge and workspace tool.
  2. Chat using this assistant.
  3. Changed the workspace to a directory where I had information about my travel plan and diet plan as pdf files.
  4. Asked question about my travel plans - What is my day 7 travel plan?

I get the following response

Screenshot 2024-08-14 at 11 55 29 AM

Stack Trace view shows that Knowledge tool is working from the default workspace - /Users/sangeethahariharan/Library/Application Support/acorn/Acorn/workspace

Screenshot 2024-08-14 at 11 46 21 AM

Expected Behavior:

Knowledge tool should work from the current workspace that is set for the thread.

g-linville commented 3 months ago

So far I have been able to figure out that this is a problem unique to the knowledge tool. Other tools are able to handle a workspace switch without a problem.

sangee2004 commented 3 months ago

@g-linville This may be because https://github.com/gptscript-ai/knowledge/blob/1699d925b168fe4cd325d4e345c087115c661bbe/tool.gpt#L18C64-L18C87

Knowledge tool would work even with workspace context when setting just the workspace env variable when testing with "--ui" option.

iwilltry42 commented 3 months ago

This is what I see in the stacktraces - the workspace context tool itself returns something wrong :thinking:

Screenshot-20240816065014-593x318

But here's the weirdest thing is this:

As soon as I swap it out for a local reference to the knowledge tool, it works just fine :thinking:

Details ``` Chatted with Know1 Input "" Messages localKnowledgeRetriever -> {"query":"Oystersteel"} Oystersteel is a highly resistant material used by Rolex for its steel watch cases. It belongs to the 904L steel family, which is commonly used in high-technology, aerospace, and chemical industries due to its exceptional resistance to corrosion. Oystersteel is known for its durability, exceptional finish once polished, and its ability to maintain its beauty even in harsh environments. For more details, you can refer to the [Rolex datasheet](file:///home/thklein/git/github.com/gptscript-ai/knowledge/.local/testdata/files/rolex_datasheet.pdf). Source: Rolex Datasheet (Page 4) Calls Loaded context from Workspace Context Input Messages The workspace directory is "/home/thklein/.config/acorn/Acorn/workspace" and contains the following files and directories: - 1000-Ways-to-Make-1000-Dollars.pdf - Small_Business_Administration_Employee.pdf - browsersettings.json - rolex_datasheet.pdf Always use absolute paths to interact with files in the workspace. Prefer creating new files in the workspace if the user does not imply a specific directory. If the user refers to '.' that is the current working directory and not the workspace directory. Loaded context from Knowledge Input "" Messages You have access to an ad-hoc RAG tool named local-knowledge-retriever. It will ingest files in the workspace on-the-fly and query them. Use it to answer questions from the user. If the answers it returns seem irrelevant, you can use other tools. When you give answers, always give a proper citation to the best of your abilities. ALWAYS prefer this tool over the read tool. Loaded context from Workspace Context Input "" Messages The workspace directory is "/home/thklein/.config/acorn/Acorn/workspace" and contains the following files and directories: - 1000-Ways-to-Make-1000-Dollars.pdf - Small_Business_Administration_Employee.pdf - browsersettings.json - rolex_datasheet.pdf Always use absolute paths to interact with files in the workspace. Prefer creating new files in the workspace if the user does not imply a specific directory. If the user refers to '.' that is the current working directory and not the workspace directory. Loaded context from Knowledge Input "" Messages You have access to an ad-hoc RAG tool named local-knowledge-retriever. It will ingest files in the workspace on-the-fly and query them. Use it to answer questions from the user. If the answers it returns seem irrelevant, you can use other tools. When you give answers, always give a proper citation to the best of your abilities. ALWAYS prefer this tool over the read tool. Ran local-knowledge-retriever Input "{\"query\":\"Oystersteel\"}" Messages 2024/08/16 06:44:28 INFO Using embedding model provider provider=openai config="{BaseURL:https://api.openai.com/v1 APIKey:REDACTED Model:gpt-4 EmbeddingModel:text-embedding-ada-002 EmbeddingEndpoint:/embeddings APIVersion:2024-02-01 APIType:OPEN_AI AzureOpenAIConfig:{Deployment:}}" 2024/08/16 06:44:28 INFO Pruned files count=0 basePath=/home/thklein/.config/acorn/Acorn/workspace 2024/08/16 06:44:28 INFO Ignoring duplicate document filename=browsersettings.json absolute_path=/home/thklein/.config/acorn/Acorn/workspace/browsersettings.json 2024/08/16 06:44:28 INFO Ignoring duplicate document filename=Small_Business_Administration_Employee.pdf absolute_path=/home/thklein/.config/acorn/Acorn/workspace/Small_Business_Administration_Employee.pdf 2024/08/16 06:44:28 INFO Ignoring duplicate document filename=rolex_datasheet.pdf absolute_path=/home/thklein/.config/acorn/Acorn/workspace/rolex_datasheet.pdf 2024/08/16 06:44:28 INFO Ignoring duplicate document filename=1000-Ways-to-Make-1000-Dollars.pdf absolute_path=/home/thklein/.config/acorn/Acorn/workspace/1000-Ways-to-Make-1000-Dollars.pdf Retrieved the following 1 source collections for the query "Oystersteel" from path "/home/thklein/.config/acorn/Acorn/workspace": {"Oystersteel":[{"content":"Oystersteel\n\n**Highly resistant to**\n\n**corrosion**\n\nRolex uses Oystersteel for its steel watch cases.\n\nSpecially developed by the brand, Oystersteel\n\nbelongs to the 904L steel family, alloys most\n\ncommonly used in high-technology and in the\n\naerospace and chemical industries, where\n\nmaximum resistance to corrosion is essential.\n\nOystersteel is extremely resistant, offers an\n\nexceptional finish once polished and maintains its\n\nbeauty even in the harshest environments.","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/rolex_datasheet.pdf","filename":"rolex_datasheet.pdf","page":"4","totalPages":"9"},"similarity_score":0.87866634},{"content":"**Datejust 41**\n\nOyster, 41 mm, Oystersteel","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/rolex_datasheet.pdf","filename":"rolex_datasheet.pdf","page":"1","totalPages":"9"},"similarity_score":0.8756807},{"content":"**This Oyster Perpetual**\n\n**Datejust 41** **in**\n\n**Oystersteel** **features** **a**\n\n**white** **dial and** **an Oyster**\n\n**bracelet.**","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/rolex_datasheet.pdf","filename":"rolex_datasheet.pdf","page":"2","totalPages":"9"},"similarity_score":0.84151596},{"content":"The Oyster bracelet\n\n**Alchemy of form and**\n\n**function**\n\nThe Oyster bracelet is a perfect alchemy of form\n\nand function, aesthetics and technology, designed\n\nto be both robust and comfortable.\n\nIt is equipped with an Oysterclasp and the\n\nEasylink comfort extension link, also exclusive to\n\nRolex. This ingenious system allows the wearer to\n\nincrease the bracelet length by approximately 5\n\nmm, providing additional comfort in any\n\ncircumstance.","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/rolex_datasheet.pdf","filename":"rolex_datasheet.pdf","page":"5","totalPages":"9"},"similarity_score":0.8379161},{"content":"**More technical details**\n\n**Datejust**\n\nReference 126300\n\n**Model Case**\n\n**Type**\n\nOyster, 41 mm, Oystersteel\n\n**Diameter**\n\n41 mm\n\n**Material**\n\nOystersteel\n\n**Bezel**\n\nSmooth\n\n**Oyster Architecture**\n\nMonobloc middle case, screw-down\n\ncase back and winding crown\n\n**Winding Crown**\n\nScrew-down, Twinlock double\n\nwaterproofness system\n\n**Crystal**\n\nScratch-resistant sapphire, Cyclops\n\nlens over the date\n\n**Water Resistance**\n\nWaterproof to 100 metres / 330\n\nfeet\n\n**Movement**\n\n**Type**\n\nPerpetual, mechanical, self-winding\n\n**Calibre**\n\n3235, Manufacture Rolex\n\n**Precision**\n\n-2/+2 sec/day, after casing\n\n**Oscillator**\n\nParamagnetic blue Parachrom\n\nhairspring. High-performance\n\nParaflex shock absorbers\n\n**Winding**\n\nBidirectional self-winding via\n\nPerpetual rotor","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/rolex_datasheet.pdf","filename":"rolex_datasheet.pdf","page":"7","totalPages":"9"},"similarity_score":0.8165454},{"content":"**Power reserve**\n\nApproximately 70 hours\n\n**Functions**\n\nCentre hour, minute and seconds\n\nhands. Instantaneous date with\n\nrapid setting. Stop-seconds for\n\nprecise time setting\n\n**Bracelet**\n\n**Type**\n\nOyster, three-piece solid links\n\n**Bracelet Material**\n\nOystersteel\n\n**Clasp**\n\nFolding Oysterclasp with Easylink 5\n\nmm comfort extension link\n\n**Dial**\n\n**Type**\n\nWhite\n\n**Details**\n\nHighly legible Chromalight display\n\nwith long-lasting blue luminescence\n\n**Certification**\n\n**Type**\n\nSuperlative Chronometer (COSC +\n\nRolex certification after casing)","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/rolex_datasheet.pdf","filename":"rolex_datasheet.pdf","page":"8","totalPages":"9"},"similarity_score":0.797245},{"content":"above the shells becomes a neck. Now drill a hole in one side of a small\n\nconical shell. Attach this to the top of the pipe cleaner. You now have the\n\nfigure of a comical man, with two large feet made from oyster shells, a body\n\nmade from oyster shells, and the legs and neck from the pipe cleaners. The\n\nsmall shell on top is, of course, the head. Arms may be added by cutting a\n\npipe cleaner in half, and attaching to the neck at the juncture of the oyster\n\nshells. A small brush and ten cents’ worth of paint will enable you to tint\n\nyour figures any color. Ash trays and a score of useful items may be easily\n\nmade in this way.\n\n**_Tosdale Sisters Saw Paris on FancyPillows_**\n\nT\n\n**HE** Tosdale sisters had just finished college, and after the usual round of\n\nparties had been given for them in their home town, they developed a bad\n\ncase of wanderlust. Somehow or other Helen and Mary Tosdale meant to\n\nmake some money for a trip.\n\nThere was one thing in which both girls excelled and that was sewing. Both\n\nof them had made all their dresses and many of their suits and coats since\n\ntheir high-school days. They knew colors and fabrics and they had style\n\nsense. However, neither one of the girls had any desire to develop a\n\ndressmaking trade. It would have to be some other type of sewing, they\n\ndecided. And then they hit on the idea of fancy pillows. The years of sewing\n\nin the Tosdale home had resulted in trunks and boxes of both used and\n\nunused fabrics and ribbons and edgings. After a check-up, they found they\n\nwould have enough for quite a number of pillows before they would have to\n\nbuy any new material.\n\nThat summer they worked over pillow designs and by November, they had\n\nmade several dozen unusual and beautiful pillows. Ribbons in matching tones\n\nwere woven together to make interesting squares; bands of contrasting\n\nmaterial were appliqued in modern effects; porch pillows were made of\n\nsturdy chintz and cretonne, their edges bound in contrasting colors; fine\n\nlinens were daintily embroidered to fashion baby pillows of softest down;","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/1000-Ways-to-Make-1000-Dollars.pdf","filename":"1000-Ways-to-Make-1000-Dollars.pdf","page":"103","totalPages":"509"},"similarity_score":0.78117484},{"content":"cigarette boxes, ash trays, toys, novelties, and innumerable other things. Until\n\nrecently, this work meant tedious hours with soldering irons and other hand\n\ntools. Now, however, with the new sheet metal working outfit on the market,\n\nthe home craftsman can use the same methods as the modern factory does.\n\nWith this equipment, a simple piece like a metal waste basket can be\n\ncompleted in less than half an hour and the total cost, including the paint, is\n\nless than twenty cents. The makers of the metal working equipment furnish\n\nbooks of designs and patterns as well as the necessary materials.\n\n**o** **ther** **M** **aterIals**—Parchment lamp shades (particularly shades for wall lights)\n\nare always in good taste. The parchment may be purchased in the stores and\n\nmany department stores have trained women on their staffs who will help you\n\nwith designs. Handmade baskets, pottery, beadwork, batik work and hand-\n\nloomed fabrics are not difficult to learn to make and bring good prices. Raffia\n\nmakes beautiful table mats and coverings for wine bottles. Shells make droll\n\nlittle figures. Sheet celluloid makes costume jewelry, buttons, silhouettes, etc.\n\nA scroll or jig saw is necessary for this work. Old inner tubes can be used to\n\nmake marionettes—the rubber helps to make the dancing figures more\n\nrealistic. Leather covered boxes, desk pads, letter cases, telephone book\n\ncovers, book carriers, and many other articles made of leather sell well in the\n\nstores today, especially at Christmas. Tooled leather work is not hard to learn\n\n—a surprisingly small number of tools are needed to carry on the entire work.\n\nSome of the plastics on the market today can be used to make ornamental and\n\nuseful items that are money makers. Practically all the companies making this\n\nmaterial furnish directions for the beginner.\n\n**c** **hapter** **f** **our**\n\n**RAISING THINGS TO SELL**\n\nT\n\n**HE** next time you complain about making a living in the United States, think\n\nof that little party of Pilgrims who landed at Plymouth Rock in 1620. Think\n\nof what they were up against. They had come to a new country, about which\n\nthey knew very little, seeking religious freedom and an opportunity to\n\nprosper. The country to which they came had no currency. There was no\n\ngovernment to guarantee their livelihood. There was no police force to","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/1000-Ways-to-Make-1000-Dollars.pdf","filename":"1000-Ways-to-Make-1000-Dollars.pdf","page":"119","totalPages":"509"},"similarity_score":0.7777917},{"content":"in the colonial days, are known all over the world for their beauty. For years\n\nthese examples of art and skill have endured. The intricate, lacy designs are\n\nreally the work of artists and are not easy to equal. However, there are many\n\nsimpler designs which can be made by the average craftsman. Home-\n\nmarkers, colonial lanterns for entrance lights, railings, small balconies\n\nbeneath windows, fireplace equipment, grills, hinges, door knockers—all are\n\nin vogue today due to the revival of interest in colonial architecture and\n\nfurnishings. Prices charged for wrought iron things should, of course, be high\n\nenough to put a proper value on original design and expert craftsmanship of\n\nthis sort.\n\n**_James Mack’s Sandwich Bar_**\n\nF\n\n**OUR** years ago, James Mack, in search of a better climate for his health,\n\ndrove to Florida and stopped for a while in Miami. Now James Mack was a\n\nconnoisseur of good coffee. He was fussy about the kind of coffee he drank,\n\nand well he might be for he made a good cup of coffee himself. According to\n\nMack, there was no good coffee in Miami. He tried all the restaurants, the\n\nhotels, and even the refreshment stands. The coffee was terrible!\n\nWell, if he couldn’t get a good cup of coffee in Miami, he would make it\n\nhimself and show these Florida cooks how the people from up north liked\n\ntheir coffee! No sooner said than done—James Mack opened up a sandwich\n\nbar. The menu included only two types of sandwiches—fish and hamburger\n\n—and the best coffee you could buy at any price. Yet he charged only a\n\nnickel a cup for it. Milk was added to the menu as a concession to those who\n\ncouldn’t drink coffee. The fish used in the sandwiches was always whatever\n\nwas in the market that morning in quantities sufficient to be purchased at a\n\ngood price. The hamburger was always strictly fresh and prepared so that it\n\nreally was good enough to accompany the best cup of coffee in town. No pie,\n\nno cake, no cookies, no ham and eggs—nothing but the sandwiches and\n\ncoffee and milk were served.\n\nPeople were skeptical at first, but the few who tried his coffee were back","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/1000-Ways-to-Make-1000-Dollars.pdf","filename":"1000-Ways-to-Make-1000-Dollars.pdf","page":"112","totalPages":"509"},"similarity_score":0.7655687},{"content":"sells for $1.25 for a four and one-half ounce can; the uncooked meat bringing\n\n$2.50 a pound. The meat is also smoked in the same fashion ham is smoked\n\nand marketed as “Snake Snaks” in small bags. In view of the fact that the\n\nmeat has a very delicate flavor, it is especially delicious served as canapes.\n\nOther parts of the rattler such as the head, the rattles, the fangs are made up\n\ninto ornaments and a rubbing oil is made from the fatty tissues. The skin, of\n\ncourse, is made into hat bands, belts, pocketbooks, book covers, etc.\n\nYou may not be keen about the idea of starting a snake cannery, even though\n\nyou live in a snake infested area. However, the way Mr. End made his $1,000\n\nmay suggest to you the many opportunities for making money that exist right\n\nin your own back yard, so to speak, if only you look for them.\n\n**_What You Can Make from Clam Shells_**\n\nM\n\n**ARY COOPER** , who lived with her two small children in a cheap rooming\n\nhouse, had lost her job. However, being an ingenious person, she had soon\n\nestablished herself in a nice little business of her own making novelties from\n\nclam and oyster shells. She secured the shells without cost from a near-by sea\n\nfood shop and made them up into novelties. She took them down to the\n\nbeauty parlor where she had been working and the owner of the shop gave\n\nher display space in a window for a commission on all that were sold. Such\n\nnovelties are inexpensive to make. The materials used consist of common\n\npipe cleaners, clam, oyster shells, and other shells. No particular skill is\n\nrequired. Here is how to do it:\n\nDrill a hole in the small end of an oyster shell. Insert one end of a pipe\n\ncleaner through this hole and fasten it securely by twisting the wire over and\n\naround the edge of the shell, letting most of the pipe cleaner extend upward.\n\nNow repeat this operation with a second oyster shell of the same size. Place\n\nthe two shells alongside each other. Halfway up the length of the pipe\n\ncleaners, bend and twist them together for the rest of their length. Next select\n\ntwo small oyster shells. Match and fit them together about the twisted single\n\nportion of the pipe cleaners. That portion of the pipe cleaners which protrudes","metadata":{"absPath":"/home/thklein/.config/acorn/Acorn/workspace/1000-Ways-to-Make-1000-Dollars.pdf","filename":"1000-Ways-to-Make-1000-Dollars.pdf","page":"102","totalPages":"509"},"similarity_score":0.76111716}]} Calls Loaded context from Workspace Context Input "" Messages The workspace directory is "/home/thklein/.config/acorn/Acorn/workspace" and contains the following files and directories: - 1000-Ways-to-Make-1000-Dollars.pdf - Small_Business_Administration_Employee.pdf - browsersettings.json - rolex_datasheet.pdf Always use absolute paths to interact with files in the workspace. Prefer creating new files in the workspace if the user does not imply a specific directory. If the user refers to '.' that is the current working directory and not the workspace directory. Loaded provider from GPTScript Gateway Provider Input "" Messages http://127.0.0.1:11187 ```
g-linville commented 3 months ago

I created a fork and added some logging to try to debug (github.com/g-linville/knowledge@grant-gateway), but it just worked also. This is weird. Must be something particular to how the UI handles the knowledge repo maybe? I'll have to look into it more.

sangee2004 commented 3 months ago

Tested the workflow mentioned in the issue and it works as expected with electron build from 523bf344b

But I dont see the new version of knowledge tool made available when adding knowledge tool using tool catalog . I still get "Knowledge@V0 4.7 Gateway" version.

Will retest scenario when the new knowledge tool is made available in tool catalog.

sangee2004 commented 3 months ago

This workflow of having knowledge exposed in the "tool catalog" will be removed shortly. Closing this issue since it will be a supported workflow anymore.