ele

ele

ele

Come for the wool, Tencent Cloud Cloud Studio big wool!!! Five

Following the fourth article, since I didn't know what to write, I happened to see someone in the group mention how to call the anythingllm API elsewhere, which led to this blog post, intended for technical learning purposes. For more application methods, please refer to the anythingllm API documentation.

image

Now that we have built a knowledge base using the private knowledge base set up with cloud studio, how can we call it elsewhere, or can we provide an API for our use?
anythingllm actually provides an API, but you need to have a bit of programming knowledge to use it. After all, having an API means we can use it under any project, as the data we feed in needs to be utilized, and we want to use it wherever we want, not just under anythingllm.

Alright, without further ado, let's start the tutorial.

Now that we have fed data to deepseek through the fourth article, how can we use it via the API?

  1. Open the anythingllm settings interface [wrench icon].

image

  1. Scroll through the left menu and select Tools ---> API Key
  2. Click to generate a new API key, a new pop-up will appear, we create the API key.

39E3E616-C7CF-4592-A8D6-9D39941FBBAE

  1. Then click copy key and read the API doc in sequence,

8DDE62BF-6DA0-4684-B191-E90C835F5FE0

  1. On the opened AnythingLLM Developer API page, we click Authorize, paste the API key we just copied.

6574D458-8F8F-4C30-8C79-7DA2B6301E5F

image

  1. Close the pop-up.

image

  1. Scroll down to find /v1/workspace/{slug}/stream-chat under the Workspaces group and click it.

image

  1. Click the try out button and modify the slug value, the slug value is the name of the workspace we created initially.

image

See the image: Workspace

image

My value here is demo.

And modify the Request body content to:

Finally, click execute.
As shown in the image:

image

After a moment, we will see the response content.

image

Here, we are testing whether this API can be used normally.
So how can we call it elsewhere?
Suppose we call it from a webpage.

This requires using node + html.
Since this is a test, I will directly provide my demo code.
main.js

index.html

These two files can be directly written in cs.
The directory structure is as follows:

image

Then in the terminal, run, I simply use python to provide the web service on port 8089, press enter, nginx or nodejs can also be used.

Click to open the browser.

image

Paste the key we created earlier and click save.

image

Enter our question in the dialog box.
Let's see how the response is.

image

At this point, we have already called the data from our private knowledge base in the demo workspace.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.