Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnou committed Jun 27, 2024
0 parents commit 7691753
Show file tree
Hide file tree
Showing 105 changed files with 22,705 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
HELP.md
target/
node_modules/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
.DS_Store

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Java ###
src/main/resources/application-local.properties

### OpenGPA ###
logs/
application-local.properties
opengpa-server/src/main/bundles/
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
1 change: 1 addition & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copyright (c) 2024 Laurent Eschenauer
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Laurent Eschenauer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
131 changes: 131 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# OpenGPA - (Open) Agentic is all you need 😁

[![Twitter Follow](https://img.shields.io/twitter/follow/opengpa?style=social)](https://twitter.com/opengpa)  
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**OpenGPA** is an Open-source General Purpose Agent. A self-hosted solution boasting capabilities similar to
popular GPTs.

- Agentic system with multi-step-reasoning, chain-of-thought, ReAct, tool use etc
- Support for [all major LLMs](https://docs.spring.io/spring-ai/reference/api/chatmodel.html) such as LLama, Mistral, Anthropic, OpenAI, etc.
- Off-line first. You can run on your own box with a local LLM. Data won't leave the server. All the power of GPT without the data privacy nightmare.
- Extensible framework allows to plug your own actions, such as calling into internal services and APIs
- Simple UI exposing insight on the GPA internal reasoning and actions
- Free and open source, deploy anywhere, customize to your needs

<p align="center">
<img src="/assets/opengpa_ui.png" width="640" />
</p>

## :pencil2: Design principles

OpenGPA is much more than a UI on top of a LLM. It implements an agentic workflow, where a LLM is used as the
*brain* of an agent to reason through multiple steps of planning, reasoning, and tool use. In particular, OpenGpa
is using the [ReAct](https://arxiv.org/abs/2210.03629) approach to verbally reason on the next step, decide on the action to execute,
and observe the outcome.

```
{
"reasoning": "The user wants to know the current weather in Liege, Belgium.
The best action to get this information is to perform a web search with
the query 'current weather in Liege, Belgium'. The result of this action
will then be used to respond to the user's request.
This is not the final action as we have to get the results from the web
search first."
"action": {
"name": "webSearch",
"arguments": {
"query": "current weather in Liege, Belgium"
}
},
"is_final": false
}
```

Action selection is based on a catalog of action that can easily be extended through code. You could add an action
to tap into an internal service to fetch some data, or a workflow engine to trigger a next step, etc.

## 🛠️️ Key Features

The current version is a minimal POC yet, it already packs a few interesting pieces:
- Works with all LLM supported by [spring-ai](https://spring.io/projects/spring-ai), including running **LLama** locally
- Multi-step task processing with **chain-of-thought** approach
- Action model with easy to extend **actions** for use by the agent
- Upload of **artifacts** to process by the agent
- Download of **artifacts** generated by the agent

## 🚧 Roadmap

Improve the Agentic capabilities:
- **RAG** enabling the agent to consult vast volume of internal documents
- **Memory** enabling the agent to remember key facts and use them later
- **code generation** and **execution** within the agent (using Groovy scripts?)
- **remote API invocation** to tap into existing enterprise APIs
- **web interactions** allowing the agent to navigate pages submit forms
- **scheduled** jobs for automating workflow
- **triggers** to create complete end-to-end workflows

Make OpenGPA enterprise ready:
- Persistence of tasks/steps
- Proper file storage and management
- User management and access control
- Secure API access through API gateway
- Auditing of task processing costs (token usage)
- Instrumentation and observability

## 🚀 Getting started

### Build and run the server

By default, opengpa is using a locally hosted LLama3 as its core LLM. Check the `application.properties` file
for configuration options and the spring-ai documentation to configure support for other LLMs.

```bash
mvn clean package -Pproduction
OPENAI_API_KEY=sk-*** java -jar opengpa-server/target/opengpa-server-0.1-SNAPSHOT.jar
```

Open the UI on [http://localhost:8000](http://localhost:8000) and login with username `opengpa` and password `opengpa`.


### Debugging

For debugging purposes you can log all interactions and prompts using the following config:
```
opengpa.server.log-prompt=true
opengpa.server.log-folder=/tmp/opengpa/logs
```

# Documentation
- [Setting up an OpengGPA server](documentation/setup.md)
- [Using local open-source LLM](documentation/offline.md)
- [Creating a custom Action](documentation/actions.md)

# Support
- Join us on [Discord](https://discord.gg/3XPsmCRNE2)
- Reach out on [X](https://x.com/opengpa)
- File an [issue](https://github.com/eschnou/OpenGPA/issues)

# License

MIT License

Copyright (c) 2024 Laurent Eschenauer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file added assets/opengpa_ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tts_action.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions devops/opengpa.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
OPENGPA_UI_NAME="OpenGPA"

# OpenAI API Key
OPENAI_API_KEY=sk-***

# Single in-memory user
OPENGPA_SERVER_AUTH_PROVIDER=memory
OPENGPA_SERVER_USERNAME=opengpa
OPENGPA_SERVER_PASSWORD=secret

# Use a file for user accounts, you can find a sample file in /devops
# OPENGPA_SERVER_AUTH_PROVIDER=file
# OPENGPA_SERVER_AUTH_FILE=/etc/opengpa/users.conf

# Log all prompts for easier debugging
# OPENGPA_SERVER_LOGPROMPT=true
# OPENGPA_SERVER_LOGFOLDER=/home/ubuntu/OpenGPA/logs

# The following is required if OpenGPA is behind a proxy/alb serving https
SERVER_FORWARDHEADERSSTRATEGY=native

39 changes: 39 additions & 0 deletions devops/opengpa.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[Unit]
Description=OpengGPA Server
After=network-online.target
Wants=network-online.target

[Service]
EnvironmentFile=-/etc/default/opengpa
User=ubuntu
Group=ubuntu
Type=simple
Restart=always
RestartSec=2
ExecStart=/home/ubuntu/OpenGPA/devops/opengpa.sh
WorkingDirectory=/home/ubuntu/OpenGPA

# Increase the default file descriptor limit
LimitNOFILE=32768

# Security
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=no
ReadWritePaths=/home/ubuntu/OpenGPA/logs/
ProtectHome=no
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
MemoryDenyWriteExecute=no
LockPersonality=yes
UMask=0077

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions devops/opengpa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
java -jar opengpa-server/target/opengpa-server-0.1-SNAPSHOT.jar
7 changes: 7 additions & 0 deletions devops/users.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"username": "opengpa",
"password": "$2y$10$FcbWanQv.xCyyvzOLgwv/e4C2/y32YbO25jz50HJ98P1GNBIwWDuS",
"roles": ["ROLE_USER"]
}
]
Loading

0 comments on commit 7691753

Please sign in to comment.