-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Gitfoe/dev
Dev
- Loading branch information
Showing
14 changed files
with
1,820 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
llm-app-interface | ||
Copyright 2024 Julian Calvin Rill | ||
|
||
This product includes software developed at | ||
Osnabrück University (https://www.uni-osnabrueck.de). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,112 @@ | ||
# llm-app-interface | ||
A flexible and intelligent context-aware navigation interface utilizing LangChain and LLMs, enhancing interoperability with accessibility apps for vision impaired individuals. | ||
# Flexible Context-Aware Navigation Interface for Accessibitiy Apps | ||
|
||
This project is a **flexible and intelligent context-aware navigation interface** designed to enhance interoperability with accessibility applications for vision-impaired individuals. Utilizing **LangChain** and **LLMs (Large Language Models)**, it provides a seamless API that supports both human and system inputs, enabling back-and-forth communication and clarifying interactions. It is designed to work with accesibility apps such as the [Natural Language Interface](https://github.com/StudyProject-NLI/NLInterface). | ||
|
||
### Features | ||
|
||
- **API Interface**: Exposed via `LangServe` for interaction with other apps. | ||
- **Context-aware**: Uses a `LangGraph` based approach for efficient state management and future-proofing. | ||
- **Interoperability**: Designed to enhance accessibility apps and facilitate communication with LLMs. | ||
- **Support for OAuth**: User authentication using `OAuth2`. | ||
- **Back-and-Forth Communication**: Enables real-time clarifying questions and data exchange between apps and users. | ||
- **Customizable for Accessibility Apps**: Currently configured for a single accessibility app but designed with ambitions for broader app support. | ||
|
||
--- | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
- **Python 3.x** installed | ||
- API keys from **LangChain** and **OpenAI**. | ||
|
||
### Installation | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/Gitfoe/llm-app-interface | ||
cd your-repo-url | ||
``` | ||
|
||
2. Install the required Python packages: | ||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
3. Set up your environment variables by creating a `.env` file in the project root and filling in the required fields: | ||
```env | ||
LANGCHAIN_TRACING_V2=true | ||
LANGCHAIN_API_KEY=your_langchain_api_key_here | ||
OPENAI_API_KEY=your_openai_api_key_here | ||
SECRET_KEY=your_secret_key_here | ||
``` | ||
|
||
To generate a secure `SECRET_KEY`, you can run: | ||
```bash | ||
openssl rand -hex 32 | ||
``` | ||
|
||
### Usage | ||
|
||
1. Start the server locally: | ||
```bash | ||
python serve.py | ||
``` | ||
|
||
By default, the API will be accessible at: | ||
``` | ||
http://localhost:8000/llm-app-interface | ||
``` | ||
|
||
2. The application currently supports one user: | ||
- **Username**: `johndoe` | ||
- **Password**: `secret` | ||
|
||
3. Use the `/token` endpoint to generate a JWT token for authentication: | ||
```bash | ||
curl -X POST "http://localhost:8000/token" -H "Content-Type: application/x-www-form-urlencoded" -d "username=johndoe&password=secret" | ||
``` | ||
|
||
--- | ||
|
||
## API Endpoints | ||
|
||
- **`/llm-app-interface/invoke`** | ||
The primary endpoint for invoking LLM interactions, supporting both system and human input. | ||
|
||
**Example Request**: | ||
```bash | ||
curl -X POST "http://localhost:8000/llm-app-interface/invoke" \ | ||
-H "Authorization: Bearer <your_jwt_token>" \ | ||
-H "Content-Type: application/json" \ | ||
-d '{"messages": "Hello, can you assist me?"}' | ||
``` | ||
|
||
**Note**: Ensure you include a valid JWT token for authorization. | ||
|
||
--- | ||
|
||
## Integrating your Accessibility App | ||
|
||
You can extend the model to accommodate additional accessibility apps by adding descriptions of your app functionalities to the documents within the `tools.py` file. | ||
|
||
--- | ||
|
||
## Security | ||
|
||
- **OAuth2** is implemented for user authentication. The `SECRET_KEY` is used to sign and validate JWT tokens. | ||
- Currently, one user (`johndoe`) is supported. For more users, you can extend the `fake_users_db` or integrate with a proper database. | ||
|
||
--- | ||
|
||
## Future Plans | ||
|
||
- **Multi-App Support**: The current version only supports one accessibility app at a time, but we aim to generalize this for multiple apps. | ||
- **LLM Flexibility**: While this system is configured for OpenAI models, it can easily be adapted to other LLMs by swapping out the model initialization. | ||
- **Increasing Reliability**: A base of the model has been implemented, but reliability can be improved by i.e. utilizing additional nodes within the graph. | ||
|
||
--- | ||
|
||
## Contributing | ||
|
||
We welcome contributions! Please submit a pull request or open an issue for discussion. |
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from langserve import RemoteRunnable | ||
|
||
remote_chain = RemoteRunnable("http://localhost:8000/chain/") | ||
remote_chain.invoke({"language": "japanese", "text": "hi"}) |
Oops, something went wrong.