Unstructured-IO / unstructured

Open source libraries and APIs to build custom preprocessing pipelines for labeling, training, or production machine learning pipelines.
https://www.unstructured.io/
Apache License 2.0
7.53k stars 595 forks source link

how to get API_KEY ? #637

Closed codeacme17 closed 1 year ago

codeacme17 commented 1 year ago

I'm using JS to call Unstructured REST API, but now I need to provide api key, I don't know where can I get this api key. Sorry, I'm a beginner, hope you can give me an answer

cragwolfe commented 1 year ago

@codeacme17 , for now it is just ignored. You should be able to pass an empty string or null for the api key value. this will likely change in the future, but in that event we'll have clear instructions on how to get an API key.

codeacme17 commented 1 year ago

ok, thx, But I got this error, when I don't pass API KEY.

file:///Users/codeacme17/1LLESTGROUP/Websits/talk-with-files/server/node_modules/.pnpm/langchain@0.0.75_@pinecone-database+pinecone@0.1.5_cheerio@1.0.0-rc.12_mammoth@1.5.1_pdf-parse@1.1.1_playwright@1.33.0/node_modules/langchain/dist/document_loaders/fs/unstructured.js:72
            throw new Error(`Failed to partition file ${this.filePath} with error ${response.status} and message ${await response.text()}`);
                  ^

Error: Failed to partition file /Users/codeacme17/1LLESTGROUP/Websits/talk-with-files/server/sources/ads/test.html with error 404 and message {"detail":"API key is invalid, please provide a valid API key in the header."}
    at UnstructuredLoader._partition (file:///Users/codeacme17/1LLESTGROUP/Websits/talk-with-files/server/node_modules/.pnpm/langchain@0.0.75_@pinecone-database+pinecone@0.1.5_cheerio@1.0.0-rc.12_mammoth@1.5.1_pdf-parse@1.1.1_playwright@1.33.0/node_modules/langchain/dist/document_loaders/fs/unstructured.js:72:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async UnstructuredLoader.load (file:///Users/codeacme17/1LLESTGROUP/Websits/talk-with-files/server/node_modules/.pnpm/langchain@0.0.75_@pinecone-database+pinecone@0.1.5_cheerio@1.0.0-rc.12_mammoth@1.5.1_pdf-parse@1.1.1_playwright@1.33.0/node_modules/langchain/dist/document_loaders/fs/unstructured.js:81:26)
    at async file:///Users/codeacme17/1LLESTGROUP/Websits/talk-with-files/server/src/utils/loaders.js:83:21
    at async Promise.all (index 0)
    at async filesLoader (file:///Users/codeacme17/1LLESTGROUP/Websits/talk-with-files/server/src/utils/loaders.js:62:3)
    at async Module.initFiles (file:///Users/codeacme17/1LLESTGROUP/Websits/talk-with-files/server/src/models/modules/file-model.js:17:16)
    at async file:///Users/codeacme17/1LLESTGROUP/Websits/talk-with-files/server/index.js:65:3

this is my code

const loader = new UnstructuredLoader(filePath)
rawDocs = await loader.load()
cragwolfe commented 1 year ago

OK, if the value passed for api key is not empty, there will be an error message refrom the API currently. From JS, try null as the value or empty string if that does not work.

Can you try https://js.langchain.com/docs/modules/indexes/document_loaders/examples/file_loaders/unstructured#usage

except with set apiKey: "",

codeacme17 commented 1 year ago

its also not work...

const options = {
  apiKey: '',
}

const loader = new UnstructuredLoader(filePath, options)

rawDocs = await loader.load()
ericpullukaran commented 1 year ago

I've tried the aforementioned api_key='' and I, too, am getting issues with this. Server Returning a 404

ValueError: Receive unexpected status code 404 from the API.

with details

{'detail': 'API key is invalid, please provide a valid API key in the header.'}
cragwolfe commented 1 year ago

i've just updated the API so hopefully now you won't see errors with your original code.

codeacme17 commented 1 year ago

yeah, thx, now its working~

cragwolfe commented 1 year ago

thanks for reporting!

focus7eleven commented 3 months ago

Any update on this? I have set apiKey: "" and it's still not working.

I'm running Unstructed locally in a docker container. Here is my code:

const options = {
  apiKey: "",
};
const loader = new UnstructuredLoader(filePath, options);
const docs = await loader.load();

Error Message:

(node:72872) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/longcha/Projects/github.com/langchain-ai/assistant-js/node_modules/_langchain@0.1.29@langchain/dist/document_loaders/fs/unstructured.cjs:229
            throw new Error(`Failed to partition file ${this.filePath} with error ${response.status} and message ${await response.text()}`);
                  ^

Error: Failed to partition file /Users/docs/xxx.md with error 401 and message {"detail":"API key is missing, please provide an API key in the header."}
    at UnstructuredLoader._partition (/Users/longcha/Projects/github.com/langchain-ai/assistant-js/node_modules/_langchain@0.1.29@langchain/dist/document_loaders/fs/unstructured.cjs:229:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async UnstructuredLoader.load (/Users/longcha/Projects/github.com/langchain-ai/assistant-js/node_modules/_langchain@0.1.29@langchain/dist/document_loaders/fs/unstructured.cjs:238:26)
    at async loadDocs (/Users/longcha/Projects/github.com/langchain-ai/assistant-js/lib/index.js:11:18)

Node.js v18.0.0