Agenta-AI/agenta

[AGE-451] Agent deployed by yourself, how to configure it when you want to Create a Custom App?

lsm1103 opened this issue · 3 comments

截屏2024-07-19 01 18 55
截屏2024-07-19 01 15 05

The cloud version can get the api key.
截屏2024-07-19 01 17 54

AGE-451

To configure an agent for creating a custom app and resolve the configuration check error, follow these steps:

  1. Install Agenta:

    pip install -U agenta
  2. Clone the Example Application:

    git clone https://github.com/Agenta-AI/simple_prompt && cd simple_prompt
  3. Set Up Environment Variable:

    echo -e "OPENAI_API_KEY=sk-xxx" > .env
  4. Setup Agenta (Select Start from Blank):

    agenta init
  5. Serve an App Variant:

    agenta variant serve --file_name app.py

Additionally, ensure your .env file includes the following configuration settings:

NEXT_PUBLIC_AGENTA_API_URL=http://localhost
NEXT_PUBLIC_FF=oss
NEXT_PUBLIC_TELEMETRY_TRACKING_ENABLED=true
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx

Replace sk-xxxxxxxxxxxxxxxxxxxxxxxx with your actual OpenAI API key [1][2].

If you encounter a 502 status code error, it may be due to an application already running on the default backend server port (8000). To resolve this:

  • Verify the Traefik configuration to ensure it is correctly forwarding requests to the backend server on the /api route.
  • Check the relevant Traefik rule in the docker-compose.yml file.
  • Prune Docker resources by stopping and removing all agenta containers and associated volumes:
    docker stop $(docker ps -q -f "name=agenta-*")
    docker rm $(docker ps -aq -f "name=agenta-*")
    docker volume ls -q -f "name=agenta-*")
    docker volume rm VOLUME_NAME
  • Restart the application by running docker compose up and access the backend server by making requests to http://localhost:8000 [3].

For managing API keys within the Agenta web interface:

  1. List API Keys:

    from agenta.client import AgentaApi
    
    client = AgentaApi(
        api_key="YOUR_API_KEY",
        base_url="https://yourhost.com/path/to/api",
    )
    api_keys = client.list_api_keys()
  2. Create an API Key:

    from agenta.client import AgentaApi
    
    client = AgentaApi(
        api_key="YOUR_API_KEY",
        base_url="https://yourhost.com/path/to/api",
    )
    new_api_key = client.create_api_key(
        workspace_id="workspace_id",
    )
  3. Delete an API Key:

    from agenta.client import AgentaApi
    
    client = AgentaApi(
        api_key="YOUR_API_KEY",
        base_url="https://yourhost.com/path/to/api",
    )
    response = client.delete_api_key(
        key_prefix="key_prefix",
    )
  4. Validate an API Key:

    from agenta.client import AgentaApi
    
    client = AgentaApi(
        api_key="YOUR_API_KEY",
        base_url="https://yourhost.com/path/to/api",
    )
    is_valid = client.validate_api_key(
        key_prefix="key_prefix",
    )
    ``` <sup>[[4]](https://github.com/Agenta-AI/agenta/blob/main/agenta-cli/agenta/client/backend/client.py)</sup>.

These steps should help you configure and manage your custom app effectively.

To continue talking to Dosu, mention @dosu.

Hi @lsm1103 ,

In this case, I think in this case running agenta init --backend_host is not working from the CLI.

Please try running agenta init and then following the questionnaire for initializing the app then running it.

Please let me know whether it fixes the problem.

image

It was deployed using docker-compose.coh.yml, and the web version can be accessed normally, but creating the app with the command is still 502
image

error:
image