gptscript-ai / knowledge

Knowledge for GPTScript
https://gptscript-ai.github.io/knowledge/
Apache License 2.0
29 stars 14 forks source link

Windows - Errors relating to `fitz.Document` and `fitz.NewFromReader` seen when using knowledge as a remote tool. #45

Closed sangee2004 closed 3 months ago

sangee2004 commented 3 months ago

gptscript version v0.0.0-dev+6d3043d4

Setup - Windows VM on Azure- Windows 11 Pro ( 8GB RAM , 2 vCPUs, Standard D2s v3)

Steps to reproduce the problem:

  1. Execute the following script in windows VM using --workspace option. Workspace in my case has 1 pdf file.
    
    Name: Mytest
    Tools: github.com/gptscript-ai/knowledge
    Context: github.com/gptscript-ai/context/workspace
    Chat: true

You are a helpful assistant that can retrieve information and answer questions using your tools. When you start just introduce yourself as Oracle and wait for the user to prompt you. You must use the knowledge tool to look up answers to your questions. Do NOT use the read tool. You may only answer questions with information you retrieve from the knowledge tool. Even if you've seen the question before and have the answer in your context, don't reuse the answer - go back to the knowledge tool because it's possible the information it gave you previously is out of date. When you give answers, always give a proper citation to the best of your abilities.

2. Following error is seen after a chat is initiated

2024/07/22 23:39:43 run encounterd an error: exit status 1: # github.com/gptscript-ai/knowledge/pkg/datastore/documentloader pkg\datastore\documentloader\pdf.go:47:18: undefined: fitz.Document pkg\datastore\documentloader\pdf.go:54:19: undefined: fitz.NewFromReader with error output:

sangee2004 commented 3 months ago

Able to use knowledge as a CLI tool successfully in windows environment

  1. Install knowledge tool from official releases
Invoke-WebRequest https://github.com/gptscript-ai/knowledge/releases/download/v0.1.10/knowledge-windows-amd64 -OutFile knowledge.exe

Make sure have knowledge.exe to be available in PATH.

  1. Use the following gpt file with --workspace option pointing to the directory that has knowledge files
Name: Mytest
Tools: knowledge
Context: github.com/gptscript-ai/context/workspace
Chat: true

You are a helpful assistant that can retrieve information and answer questions using your tools. When you start just introduce yourself as Oracle and wait for the user to prompt you.
You must use the knowledge tool to look up answers to your questions. Do NOT use the read tool. You may only answer questions with information you retrieve from the knowledge tool.
Even if you've seen the question before and have the answer in your context, don't reuse the answer - go back to the knowledge tool because it's possible the information it gave you previously is out of date.
When you give answers, always give a proper citation to the best of your abilities.

---
Name: knowledge
Description: Create a knowledge base from files in the workspace directory and retrieve information from it.
Credential: github.com/gptscript-ai/credential as sys.openai with OPENAI_API_KEY as env and "Please provide your OpenAI API key" as message and key as field
Args: query: The query to search for in the knowledge directory.

#!knowledge.exe askdir --path ${GPTSCRIPT_WORKSPACE_DIR} "${query}"
iwilltry42 commented 3 months ago

This will be fixed on GPTScript side, as we cannot add build flags, etc. to remote Go builds. https://github.com/gptscript-ai/gptscript/pull/772 introduces this functionality.