mirror of
https://github.com/simular-ai/Agent-S.git
synced 2026-09-21 12:50:26 +08:00
fix perplexica setup
This commit is contained in:
@@ -141,9 +141,13 @@ Agent S works best with web-knowledge retrieval. To enable this feature, you nee
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
5. Next, export your environment variables. The `PERPLEXICA_URL` is optional. The default value is `http://localhost:{port}/api/search` where the default `port` is `3001` from the `config.toml` if you're using the default port. If you aren't using the default port or need to change the URL, you may use `PERPLEXICA_URL` to specify the URL.
|
||||
|
||||
5. Our implementation of Agent S incorporates the Perplexica API to integrate a search engine capability, which allows for a more convenient and responsive user experience. If you want to tailor the API to your settings and specific requirements, you may modify the URL and the message of request parameters in `agent_s/query_perplexica.py`. For a comprehensive guide on configuring the Perplexica API, please refer to [Perplexica Search API Documentation](https://github.com/ItzCrazyKns/Perplexica/blob/master/docs/API/SEARCH.md)
|
||||
|
||||
```bash
|
||||
export PERPLEXICA_CONFIG_PATH=/absolute/path/to/your/config.toml
|
||||
export PERPLEXICA_URL=http://localhost:{port}/api/search
|
||||
```
|
||||
6. Our implementation of Agent S incorporates the Perplexica API to integrate a search engine capability, which allows for a more convenient and responsive user experience. If you want to tailor the API to your settings and specific requirements, you may modify the URL and the message of request parameters in `agent_s/query_perplexica.py`. For a comprehensive guide on configuring the Perplexica API, please refer to [Perplexica Search API Documentation](https://github.com/ItzCrazyKns/Perplexica/blob/master/docs/API/SEARCH.md).
|
||||
For a more detailed setup and usage guide, please refer to the [Perplexica Repository](https://github.com/ItzCrazyKns/Perplexica.git).
|
||||
|
||||
> ❗**Warning**❗: The agent will directly run python code to control your computer. Please use with care.
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
import requests
|
||||
import toml
|
||||
|
||||
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||
parent_path = os.path.dirname(current_path)
|
||||
import os
|
||||
|
||||
|
||||
def query_to_perplexica(query):
|
||||
config_path = os.getenv("PERPLEXICA_CONFIG_PATH")
|
||||
if not config_path:
|
||||
raise ValueError(
|
||||
"Environment variable PERPLEXICA_CONFIG_PATH is not set. Please set it to the path of your config.toml."
|
||||
)
|
||||
|
||||
# Load Your Port From the configuration file of Perplexica
|
||||
with open(
|
||||
os.path.join(os.path.dirname(parent_path), "Perplexica", "config.toml"), "r"
|
||||
) as f:
|
||||
with open(config_path, "r") as f:
|
||||
data = toml.load(f)
|
||||
port = data["GENERAL"]["PORT"]
|
||||
assert port, "You should set valid port in the config.toml"
|
||||
# Set the URL
|
||||
url = f"http://localhost:{port}/api/search"
|
||||
|
||||
# Retrieve the URL from an environment variable
|
||||
url = os.getenv("PERPLEXICA_URL")
|
||||
if not url:
|
||||
url = f"http://localhost:{port}/api/search"
|
||||
print(
|
||||
f"PERPLEXICA_URL not set, using default URL: http://localhost:{port}/api/search"
|
||||
)
|
||||
|
||||
# Request Message
|
||||
message = {"focusMode": "webSearch", "query": query, "history": [["human", query]]}
|
||||
|
||||
|
||||
@@ -2,18 +2,28 @@ import requests
|
||||
import toml
|
||||
import os
|
||||
|
||||
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||
parent_path = os.path.dirname(os.path.dirname(os.path.dirname(current_path)))
|
||||
|
||||
|
||||
def query_to_perplexica(query):
|
||||
config_path = os.getenv("PERPLEXICA_CONFIG_PATH")
|
||||
if not config_path:
|
||||
raise ValueError(
|
||||
"Environment variable PERPLEXICA_CONFIG_PATH is not set. Please set it to the path of your config.toml."
|
||||
)
|
||||
|
||||
# Load Your Port From the configuration file of Perplexica
|
||||
with open(os.path.join(parent_path, "Perplexica", "config.toml"), "r") as f:
|
||||
with open(config_path, "r") as f:
|
||||
data = toml.load(f)
|
||||
port = data["GENERAL"]["PORT"]
|
||||
assert port, "You should set valid port in the config.toml"
|
||||
# Set the URL
|
||||
url = f"http://localhost:{port}/api/search"
|
||||
|
||||
# Retrieve the URL from an environment variable
|
||||
url = os.getenv("PERPLEXICA_URL")
|
||||
if not url:
|
||||
url = f"http://localhost:{port}/api/search"
|
||||
print(
|
||||
f"PERPLEXICA_URL not set, using default URL: http://localhost:{port}/api/search"
|
||||
)
|
||||
|
||||
# Request Message
|
||||
message = {"focusMode": "webSearch", "query": query, "history": [["human", query]]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user