mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-21 08:15:23 -04:00
[GH-ISSUE #19] [Enhancement]: ai api #9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SharkJ0001 on GitHub (Mar 25, 2025).
Original GitHub issue: https://github.com/vxcontrol/pentagi/issues/19
Originally assigned to: @asdek on GitHub.
Target Component
Core Services (Frontend UI/Backend API)
Enhancement Description
Hello, this openai is charged, can it be replaced with other AI APIs such as Deepseek or Tongyi that can be used for free?
Technical Details
No response
Designs and Mockups
No response
Alternative Solutions
No response
Verification
@asdek commented on GitHub (Mar 26, 2025):
Hello @SharkJ0001
Thank you for reaching out and for your interest in PentAGI!
Regarding the use of free models, you might consider experimenting with OpenRouter. However, please note that PentAGI's logic is tailored towards the use of functions, so you'll need to independently select an appropriate set of models capable of handling the tasks within the attack simulation.
These simulations require models with extensive knowledge bases and the ability to execute functions that are typically inherent to big LLMs. As a result, most open-source models freely available on the OpenRouter platform may not be suitable for these specific tasks.
We would also like to highlight that PentAGI supports the DeepSeek API, which you can utilize at a significantly lower cost compared to services like OpenAI or Anthropic. Our project includes configuration files that you can use to integrate PentAGI with these models effectively to achieve your target objectives.
Here is a list of configuration files you might find helpful:
Additionally, you can review the results of our testing and replicate them on your own infrastructure using your configuration files. Below are examples of test reports for the aforementioned configuration files:
To conduct testing yourself, please follow the instructions provided in the Testing LLM Agents section of our README.
Connecting OpenRouter, DeepInfra, or DeepSeek API:
To integrate these services with your PentAGI installation, set the following environment variables in your
.envfile. When launching the simulation, selectcustomas the Provider in the UI.Based on our measurements, using DeepSeek can reduce costs by up to 5 times compared to running the simulation with the OpenAI API. However, please be aware that the execution speed of the simulation will be significantly slower than when using OpenAI or Anthropic.
If you have any further questions or need assistance with the configuration, please don't hesitate to ask.
@liujinpen commented on GitHub (Mar 27, 2025):
@asdek Hello, I have run docker compose in windows environment and successfully started.
In accordance with the above specifications, my configuration is as follows, but after start-up cannot choose 'custom UI interface, the console view network request found https://localhost:8443/api/v1/graphql return values only' openai '. Does it not work in windows?
LLM Providers
OPEN_AI_KEY=key
OPEN_AI_SERVER_URL=https://api.openai.com/v1
Custom LLM provider
LLM_SERVER_URL=https://api.deepseek.com
LLM_SERVER_KEY=key
LLM_SERVER_MODEL=
LLM_SERVER_CONFIG_PATH=LLM_SERVER_CONFIG_PATH=/opt/pentagi/conf/deepseek.provider.yml
@asdek commented on GitHub (Mar 27, 2025):
Hello @liujinpen
Thanks for pointing out this inaccuracy.
This was a bug caused by the
LLM_SERVER_MODELvariable not being set in your.envfile. Even ifLLM_SERVER_CONFIG_PATHwas specified, the Custom Provider would not initialize without a value forLLM_SERVER_MODEL.I have fixed this issue in commit 333bbf6. To resolve this problem on your end, you have two options:
Set the
LLM_SERVER_MODELvariable: Add any value to theLLM_SERVER_MODELvariable in your.envfile. For example:Update the PentAGI Docker image: Pull the latest version of the Docker image where the issue has been fixed. Run the following commands:
If you continue to experience any issues or have further questions, please let me know.
@liujinpen commented on GitHub (Mar 27, 2025):
@asdek Thank you very much. It's up and running!👍👍👍 Now he can answer my simple conversation. In addition, after I switched to 'custom', when I asked 'help me check the local port opening status', the UI kept loping, and the log showed that the openapi related interface could not be accessed (because I only had the deepseek key). Do applications have to use openapi capabilities? Because I found out that I have to fill in the OPEN_AI_KEY parameter at startup (and I just filled it in randomly).If only deepseek-chat is configured, the program's capabilities are limited, right?🤔
@asdek commented on GitHub (Mar 28, 2025):
Hello @liujinpen
I'm glad to hear that you've got the application up and running and that it's working! 😊
Regarding the Issue with the Custom Provider:
The problem you're encountering after switching to the 'custom' provider is due to how the application handles text embeddings. By default, the application uses OpenAI's embedding models for vectorizing text, even when you're using a different LLM provider like DeepSeek. This is reflected in the code here: custom.go.
Why OpenAI Embeddings are Used:
At the initial stage of development, we decided to use a unified model (specifically OpenAI's) for text vectorization across all providers. This approach ensures that the agent's memory and knowledge base function correctly and consistently. The agent's memory stores various valuable information such as manuals, code snippets, software installation scripts, and more.
By using a consistent embedding model, agents can efficiently search their internal vector database for relevant knowledge before resorting to external internet searches. This design choice improves performance and reduces unnecessary internet queries.
Issue with DeepSeek and Embeddings:
The DeepSeek API doesn't currently provide models for text embeddings. As a result, even when you configure DeepSeek as your LLM provider, the application still attempts to use OpenAI's embedding models for processing, which requires a valid OpenAI API key.
Since you don't have a valid OpenAI API key (and only filled in a random value), the application cannot access the OpenAI embeddings API. This leads to the UI looping and the errors you're seeing in the logs:
Temporary Solution:
To resolve this issue for now, you can provide a valid OpenAI API key in your
.envconfiguration file:This will allow the application to access OpenAI's embedding models for text vectorization, even while using DeepSeek for generating responses.
Upcoming Improvements:
If you that you may prefer not to use OpenAI's services or API keys. I'll try to add the ability to choose a custom embedding provider within the application. This means you'll be able to specify an alternative embedding service that suits your needs and doesn't rely on OpenAI.
I anticipate having this feature implemented within the next day or two. Once it's available, you can configure a different embedding provider, and the application will not require an OpenAI API key.
Recommended Updates:
In addition, I made several improvements to the application's interface recently to enhance stability and performance. I recommend updating your application to the latest version to benefit from these updates. You can do this by running:
This will pull the latest Docker images and restart your containers with the updated code.
Have a nice day! 😉
@liujinpen commented on GitHub (Mar 28, 2025):
@asdek Thank you for your detailed reply. I will continue to pay attention to this project and update it in time. Thanks again!👍👍👍
@asdek commented on GitHub (Apr 1, 2025):
Hello @liujinpen
I replied in https://github.com/vxcontrol/pentagi/issues/21#issuecomment-2764292561 and after 'embedding provider' fixes can't reproduce this issue, please check it on your side
I hope that it's will be helpful for your case.
@liujinpen commented on GitHub (Apr 1, 2025):
@asdek Thank you very much. I think it should be fine. I'll give it a try👍
@summersblue commented on GitHub (Apr 1, 2025):
I met the same problem, I have already run :docker compose pull
docker compose up -d ,and .env is as follows:## LLM Providers
OPEN_AI_KEY=sk-deepseekkey
OPEN_AI_SERVER_URL=https://api.deepseek.com
Custom LLM provider
LLM_SERVER_URL=https://api.deepseek.com/
LLM_SERVER_KEY=sk-deepseekkey
LLM_SERVER_MODEL=deepseek-chat
LLM_SERVER_CONFIG_PATH=/opt/pentagi/conf/deepseek.provider.yml
it can run, and docker logs -f pentagi, many error logs as follows: time="2025-04-02T01:26:23Z" level=error msg="failed to get pentester result" error="failed to get task pentester result: failed to exec function 'search': failed to execute handler: failed to get searcher result: failed to get task searcher result: failed to exec function 'search_answer': failed to execute handler: failed to search answer for question: error embedding query: failed to create openai embeddings: API returned unexpected status code: 404: "
@asdek commented on GitHub (Apr 2, 2025):
Hello @summersblue
Unfortunately, the system settings you've provided are not correct. The DeepSeek provider is not fully compatible with the OpenAI provider; specifically, it does not offer the
/embeddingsendpoint. This is why you're receiving a 404 error from the provider.In this comment, I have detailed all the changes and provided a list of supported embedding providers. Please review this message to better understand how PentAGI operates.
Default Behavior:
If you do not set the following environment variables:
and you do not specify a valid key in the
OPEN_AI_KEYvariable, then the vector storage in RAG (Retrieval Augmented Generation) format will be disabled.Below is a short list of commands you can use to test the agents' logic, including those that interact with the vector storage. This is a useful tool for debugging and understanding any issues you might be experiencing.
Commands to Test Agent Logic:
List all flows:
List tasks and subtasks within a flow:
List available functions for testing:
Run the
search_in_memoryfunction in interactive mode (the utility will prompt you for necessary parameters):Get a list of parameters for a function by name:
Note: The
-taskand-subtaskarguments, if accepted by the function and specified before the function name, will be used, and you won't need to input them again.Important:
In your case, since there is no valid embedding provider configured, the
search_in_memoryfunction should not be available. To enable it, you need to specify a valid embedding provider in your settings.Embedding Provider Testing Utility:
I have also added a utility specifically for testing embedding providers, which can be run with the default configuration as follows:
Expected Output:
Additional Commands:
To get statistics about the accumulated knowledge in the vector storage:
When changing the embedding provider, if the statistics indicate that you have data in the current storage, you need to either flush the current state:
Note: Be cautious, as this will remove all existing embeddings.
Or reindex the storage (this will consume tokens, as all accumulated text will be sent again to obtain new vector representations):
Searching the Vector Storage:
The utility also provides the ability to search the vector storage directly, bypassing the agents' logic. Please check the function's argument format before running:
Summary:
To resolve your issue, you need to configure a valid embedding provider that supports the required endpoints. Please refer to the list of supported embedding providers and update your environment variables accordingly.
If you have any further questions or need assistance, feel free to reach out.