Update README

This commit is contained in:
Hemang
2025-02-18 10:42:09 +01:00
parent 426994ef51
commit 4a98eccdf2
2 changed files with 59 additions and 1 deletions
+59 -1
View File
@@ -21,7 +21,7 @@ This will start the Invariant Proxy on [http://localhost:8005/api/v1/proxy/](htt
To integrate the Proxy with your AI agent, youll need to modify how your client interacts with LLM providers.
**Setup an Invariant API Key**
1. Follow the instructions [here](https://explorer.invariantlabs.ai/docs/explorer/Explorer_API/1_client_setup/) to obtain an API key. This will allow the Proxy to push traces to [https://explorer.invariantlabs.ai](https://explorer.invariantlabs.ai),
1. Follow the instructions [here](https://explorer.invariantlabs.ai/docs/explorer/Explorer_API/1_client_setup/) to obtain an API key. This will allow the Proxy to push traces to [https://explorer.invariantlabs.ai](https://explorer.invariantlabs.ai).
**🔹 OpenAI Integration**
@@ -70,6 +70,64 @@ To integrate the Proxy with your AI agent, youll need to modify how your clie
# before adding the traces to it.
# Make API requests to Anthropic using the client as usual.
## **OpenHands Integration**
[OpenHands](https://github.com/All-Hands-AI/OpenHands) (formerly OpenDevin) is a platform for software development agents powered by AI.
OpenHands does not support custom headers, meaning you **cannot** pass the Invariant API Key via the `Invariant-Authorization` header directly. However, **there is a workaround** using the Invariant Proxy.
#### **Step 1: Modify the API Base**
Enable the `Advanced Options` toggle under settings and update the `Base URL` in the modal like:
<img src="./resources/images/openhands-integration.png" height=300/>
#### **Step 2: Adjust the API Key Format**
Instead of setting your OPENAI_API_KEY (or ANTHROPIC_API_KEY) normally in the settings modal under `API Key` you will need to change the format.
Updated format: ```{your-llm-api-key}|invariant-auth: {your-invariant-api-key}``` without the curly braces.
The Invariant Proxy extracts the invariant-auth field from the API key and correctly forwards the Invariant API Key, allowing traces to be pushed to Invariant Explorer. The request is correctly passed to OpenAI (or Anthropic) with the actual API Key.
This setup ensures that OpenHands works seamlessly with Invariant Proxy, maintaining compatibility while enabling full functionality. 🚀
## SWE-agent Integration
[SWE-agent](https://github.com/SWE-agent/SWE-agent) allows your preferred language model (e.g., GPT-4o or Claude Sonnet 3.5) to autonomously utilize tools for various tasks, such as:
- Fixing issues in real GitHub repositories
- Performing tasks on the web
- Cracking cybersecurity challenges
- Executing custom-defined tasks
### Using SWE-agent with Invariant Proxy
SWE-agent does not support custom headers, meaning you **cannot** pass the Invariant API Key via the `Invariant-Authorization` header directly. However, **there is a workaround** using the Invariant Proxy.
#### **Step 1: Modify the API Base**
When running `sweagent run`, add the following flag to route requests through the Invariant Proxy:
```bash
--agent.model.api_base=http://localhost:8005/api/v1/proxy/{add-your-dataset-name-here}/openai
```
without the curly braces.
#### **Step 2: Adjust the API Key Format**
Instead of setting your OPENAI_API_KEY (or ANTHROPIC_API_KEY) normally, modify the environment variable as follows:
```bash
export OPENAI_API_KEY={your-openai-api-key}|invariant-auth: {your-invariant-api-key}
export ANTHROPIC_API_KEY={your-anthropic-api-key}|invariant-auth: {your-invariant-api-key}
```
without the curly braces.
The Invariant Proxy extracts the invariant-auth field from the API key and correctly forwards the Invariant API Key, allowing traces to be pushed to Invariant Explorer. The request is correctly passed to OpenAI (or Anthropic) with the actual API Key.
This setup ensures that SWE-agent works seamlessly with Invariant Proxy, maintaining compatibility while enabling full functionality. 🚀
## Dev
### Run tests
```bash
./run.sh tests
Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB