Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'ask_user' error #649

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bf5c2ef
Fix - optimized UI dockerfile and removed unnecessary index.html file
rajakumar05032000 Mar 31, 2024
4c05126
Fix - Added npm install
rajakumar05032000 Mar 31, 2024
fc5d901
Merge main branch changes into fix branch
rajakumar05032000 Apr 1, 2024
e74a1d0
Merge branch 'main' into fix/ui-dockerfile
rajakumar05032000 Apr 5, 2024
cfff713
Update prompt.jinja2 with an example for more consistent format reply
obliviousz Apr 14, 2024
8c3a963
Fix agent_state codestyle
scythargon Apr 18, 2024
1f3fae9
Strip backquote from generated filenames
kgott May 17, 2024
75f4889
search_engine.md
shvynu Aug 27, 2024
35e5e43
Fix 'ask_user' error
EdenwareApps Sep 25, 2024
8fb3c06
Update README.md
alexanderbehrens1978 Oct 6, 2024
cd227ab
Update README.md
alexanderbehrens1978 Oct 6, 2024
61b9f8b
devika.py aktualisieren
alexanderbehrens1978 Oct 6, 2024
0f4c51f
Update README.md
alexanderbehrens1978 Oct 8, 2024
712082b
Update README.md
alexanderbehrens1978 Oct 8, 2024
e350363
Update README.md
alexanderbehrens1978 Oct 8, 2024
8f1aadc
Update README.md
alexanderbehrens1978 Oct 8, 2024
822b9a0
Update README.md
alexanderbehrens1978 Oct 8, 2024
d01c5c7
Update README.md
alexanderbehrens1978 Oct 8, 2024
9b48666
Update README.md
alexanderbehrens1978 Oct 8, 2024
d4cfbb5
Update README.md
alexanderbehrens1978 Oct 8, 2024
cf965f3
Update README.md
alexanderbehrens1978 Oct 8, 2024
9855bbd
Update README.md
alexanderbehrens1978 Oct 8, 2024
b274a70
Update README.md
alexanderbehrens1978 Oct 8, 2024
614eb31
Update devika.py
alexanderbehrens1978 Oct 8, 2024
66de63e
Update README.md
alexanderbehrens1978 Oct 8, 2024
12883d4
Update README.md
alexanderbehrens1978 Oct 8, 2024
2106a6f
Update README.md
alexanderbehrens1978 Oct 8, 2024
74da6a2
Update README.md
alexanderbehrens1978 Oct 8, 2024
6a2e14d
Update README.md
alexanderbehrens1978 Oct 8, 2024
594dae6
Update README.md
alexanderbehrens1978 Oct 9, 2024
3023d61
Update README.md
alexanderbehrens1978 Oct 9, 2024
9d5b942
Update README.md
alexanderbehrens1978 Oct 9, 2024
9b7f97d
Update README.md
alexanderbehrens1978 Oct 9, 2024
035c6d0
README.md aktualisieren
alexanderbehrens1978 Oct 9, 2024
4ec321e
Update requirements.txt
alexanderbehrens1978 Oct 9, 2024
50de197
Update README.md
alexanderbehrens1978 Oct 9, 2024
237696c
Update README.md
alexanderbehrens1978 Oct 9, 2024
5a0b6e1
Update README.md
alexanderbehrens1978 Oct 9, 2024
f4fdd76
Update README.md
alexanderbehrens1978 Oct 9, 2024
e8aaeb2
Add files via upload
alexanderbehrens1978 Oct 9, 2024
0095755
Update README.md
alexanderbehrens1978 Oct 9, 2024
f41c4d9
Rename get-ollama-modells.sh to get-ollama-models.sh
alexanderbehrens1978 Oct 9, 2024
abb0c21
Update README.md
alexanderbehrens1978 Oct 9, 2024
e3700c0
Added OpenAI Compatible Support
Nov 28, 2024
8165998
Merge branch 'pr/661'
EdenwareApps Dec 12, 2024
2a54e9c
Merge branch 'pr/651'
EdenwareApps Dec 12, 2024
52f0361
Merge branch 'pr/643'
EdenwareApps Dec 12, 2024
904d385
Merge branch 'pr/567'
EdenwareApps Dec 12, 2024
757275e
Merge branch 'pr/438'
EdenwareApps Dec 12, 2024
a3f24a8
Merge branch 'pr/436'
EdenwareApps Dec 12, 2024
9b8812b
Merge branch 'pr/276'
EdenwareApps Dec 12, 2024
65b46c4
Bugfixes and DuckDuckGo compatibilty
EdenwareApps Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 66 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,55 @@ Read [**README.md**](docs/architecture) for the detailed documentation.


## Getting Started

### Requirements
```
Version's requirements
- Python >= 3.10 and < 3.12
- NodeJs >= 18
- bun
```

- Nvidia Driver installation

https://linuxconfig.org/how-to-install-nvidia-drivers-on-ubuntu-24-04

nvtop to see installed Nvidia Cards

- Python >= 3.10 and < 3.12

sudo apt update && sudo apt upgrade

sudo apt install python3 python-is-python3

- NodeJs >= 18 Installation
[NodeJs >= 18 Installation](https://linuxconfig.org/how-to-install-node-js-on-ubuntu-24-04)

sudo apt install nodejs

sudo apt install npm

node -v

- Pip Installation

sudo apt install pip

python3 -m pip config set global.break-system-packages true

als Alternative im uv pip installieren ???

sudo apt install python3-pip

- Install uv - Python Package manager [download](https://github.com/astral-sh/uv)

$ pip install uv

- Install bun - JavaScript runtime [download](https://bun.sh/docs/installation)
- For ollama [ollama setup guide](docs/Installation/ollama.md) (optinal: if you don't want to use the local models then you can skip this step)

curl -fsSL https://ollama.com/install.sh | sh

./get-ollama-models.sh



- For API models, configure the API keys via setting page in UI.

Keys without <>



### Installation

Expand Down Expand Up @@ -99,6 +134,7 @@ To install Devika, follow these steps:
```
5. Start the Devika server:
```bash
npm install @sveltejs/adapter-node
python devika.py
```
6. if everything is working fine, you see the following output:
Expand All @@ -113,6 +149,27 @@ To install Devika, follow these steps:
```
8. Access the Devika web interface by opening a browser and navigating to `http://127.0.0.1:3001`

9. Install xterm in wsl

sudo apt install xterm

10. Windows run Xming Server from http://www.straightrunning.com/XmingNotes/#head-16

11. Change Fontsize in xterm

sudo apt install x11-xserver-utils

vi ~./Xresources

xterm*font: *-fixed-*-*-*-18-*

run xrdb -merge ~/.Xresources

14. Install Code

sudo snap install --classic code


### how to use

To start using Devika, follow these steps:
Expand Down
38 changes: 19 additions & 19 deletions app.dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
FROM debian:12
# Pulling stage 1 image, keep alias as layer1
FROM node:latest as layer1

# setting up build variable
# Setting necessary arguments
ARG VITE_API_BASE_URL
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}

# setting up os env
USER root
# Copy UI source code
copy ui /home/nonroot/client

# Change Work directory
WORKDIR /home/nonroot/client
RUN groupadd -r nonroot && useradd -r -g nonroot -d /home/nonroot/client -s /bin/bash nonroot

# install node js
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y build-essential software-properties-common curl sudo wget git
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
RUN apt-get install nodejs
RUN npm install
# Building APP bundle
RUN npm run build

# copying devika app client only
COPY ui /home/nonroot/client/ui
COPY src /home/nonroot/client/src
COPY config.toml /home/nonroot/client/
# Pulling stage 2 image, to significantly reduce image size
FROM gcr.io/distroless/nodejs20-debian11

RUN cd ui && npm install && npm install -g npm && npm install -g bun
RUN chown -R nonroot:nonroot /home/nonroot/client
# Copy build files from layer 1
COPY --from=layer1 /home/nonroot/client/build /app
COPY --from=layer1 /home/nonroot/client/package.json /app

USER nonroot
WORKDIR /home/nonroot/client/ui
# Change Work directory
WORKDIR /app

ENTRYPOINT [ "npx", "bun", "run", "dev", "--", "--host" ]
# RUN APP
CMD ["index.js"]
32 changes: 17 additions & 15 deletions devika.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,24 @@
CORS(app, resources={r"/*": {"origins": # Change the origin to your frontend URL
[
"https://localhost:3000",
"https://localhost:3001",
"http://localhost:3000",
"http://localhost:3001"
]}})
app.register_blueprint(project_bp)
socketio.init_app(app)


log = logging.getLogger("werkzeug")
log.disabled = True
log.disabled = False


TIKTOKEN_ENC = tiktoken.get_encoding("cl100k_base")

os.environ["TOKENIZERS_PARALLELISM"] = "false"

manager = ProjectManager()
AgentState = AgentState()
agent_state = AgentState()
config = Config()
logger = Logger()

Expand Down Expand Up @@ -84,17 +86,17 @@ def handle_message(data):

agent = Agent(base_model=base_model, search_engine=search_engine)

state = AgentState.get_latest_state(project_name)
state = agent_state.get_latest_state(project_name)
if not state:
thread = Thread(target=lambda: agent.execute(message, project_name))
thread.start()
else:
if AgentState.is_agent_completed(project_name):
if AgentState.is_agent_completed(agent_state, project_name):
thread = Thread(target=lambda: agent.subsequent_execute(message, project_name))
thread.start()
else:
emit_agent("info", {"type": "warning", "message": "previous agent doesn't completed it's task."})
last_state = AgentState.get_latest_state(project_name)
last_state = agent_state.get_latest_state(project_name)
if last_state["agent_is_active"] or not last_state["completed"]:
thread = Thread(target=lambda: agent.execute(message, project_name))
thread.start()
Expand All @@ -107,7 +109,7 @@ def handle_message(data):
def is_agent_active():
data = request.json
project_name = data.get("project_name")
is_active = AgentState.is_agent_active(project_name)
is_active = agent_state.is_agent_active(project_name)
return jsonify({"is_active": is_active})


Expand All @@ -116,8 +118,8 @@ def is_agent_active():
def get_agent_state():
data = request.json
project_name = data.get("project_name")
agent_state = AgentState.get_latest_state(project_name)
return jsonify({"state": agent_state})
latest_state = agent_state.get_latest_state(project_name)
return jsonify({"state": latest_state})


@app.route("/api/get-browser-snapshot", methods=["GET"])
Expand All @@ -131,23 +133,23 @@ def browser_snapshot():
@route_logger(logger)
def get_browser_session():
project_name = request.args.get("project_name")
agent_state = AgentState.get_latest_state(project_name)
if not agent_state:
latest_state = agent_state.get_latest_state(project_name)
if not latest_state:
return jsonify({"session": None})
else:
browser_session = agent_state["browser_session"]
browser_session = latest_state["browser_session"]
return jsonify({"session": browser_session})


@app.route("/api/get-terminal-session", methods=["GET"])
@route_logger(logger)
def get_terminal_session():
project_name = request.args.get("project_name")
agent_state = AgentState.get_latest_state(project_name)
if not agent_state:
latest_state = agent_state.get_latest_state(project_name)
if not latest_state:
return jsonify({"terminal_state": None})
else:
terminal_state = agent_state["terminal_session"]
terminal_state = latest_state["terminal_session"]
return jsonify({"terminal_state": terminal_state})


Expand All @@ -174,7 +176,7 @@ def calculate_tokens():
@route_logger(logger)
def token_usage():
project_name = request.args.get("project_name")
token_count = AgentState.get_latest_token_usage(project_name)
token_count = agent_state.get_latest_token_usage(project_name)
return jsonify({"token_usage": token_count})


Expand Down
72 changes: 46 additions & 26 deletions docs/Installation/search_engine.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,53 @@
# search Engine setup
# Search Engine Setup for Devika

To use the search engine capabilities of Devika, you need to set up the search engine API keys. Currently, Devika supports Bing, Google and DuckDuckGo search engines. If you want to use duckduckgo, you don't need to set up any API keys.
Devika supports three search engines: **Bing**, **Google**, and **DuckDuckGo**. While **DuckDuckGo** does not require any API keys, **Bing** and **Google** do. Follow the steps below to set up the API keys for Bing and Google.

For Bing and Google search engines, you need to set up the API keys. Here's how you can do it:
## 1. Bing Search API Setup

## Bing Search API
- Create Azure account. You can create a free account [here](https://azure.microsoft.com/en-us/free/).
- Go to the [Bing Search API](https://www.microsoft.com/en-us/bing/apis/bing-web-search-api) website.
- click on the `Try now` button.
- Sign in/sign up with your Azure account.
- Create a new resource group (if you don't have any).
![alt text](images/bing.png)
- click on the `Review and create` button.
- if everything is fine, click on the `Create` button.
### Step 1: Create an Azure Account
- Visit the [Azure website](https://azure.microsoft.com/en-us/free/) and create a free account.

### Step 2: Access the Bing Search API
- Go to the [Bing Search API](https://www.microsoft.com/en-us/bing/apis/bing-web-search-api) page.
- Click on the `Try now` button.
- Sign in or sign up using your Azure account.

### Step 3: Create a Resource Group
- If you don't have a resource group, create one during the setup process.

### Step 4: Create a Bing Search API Resource
- Fill in the necessary details for your Bing Search API resource.
- Click on the `Review and create` button.
- If everything is correct, click on the `Create` button.

### Step 5: Retrieve Your API Keys and Endpoint
- Once the resource is created, go to the `Keys and Endpoint` tab.
![alt text](images/bing-1.png)
- Copy either `Key1` or `Key2` and paste it into the `API_KEYS` field with the name `BING` in the `config.toml` file located in the root directory of Devika, or you can set it via the UI.
- ![Keys and Endpoint](images/bing-1.png)
- Copy either `Key1` or `Key2`.
- Paste the key into the `API_KEYS` field with the name `BING` in the `config.toml` file located in the root directory of Devika, or you can set it via the UI.
- Copy the `Endpoint` and paste it into the `API_Endpoints` field with the name `BING` in the `config.toml` file located in the root directory of Devika, or you can set it via the UI.

## 2. Google Search API Setup

### Step 1: Create a Google Cloud Project
- If you don't have one, create a Google Cloud Project via the [Google Cloud Console](https://console.cloud.google.com/).

### Step 2: Enable the Custom Search API
- Visit the [Google Custom Search API Documentation](https://developers.google.com/custom-search/v1/overview).
- Click on `Get a Key`.
- Select your project or create a new one.
- ![Create Project](images/google.png)
- This will enable the Custom Search API for your project and generate an API key.

### Step 3: Retrieve Your API Key
- Copy the API key.
- Paste it in the `API_KEYS` field with the name `GOOGLE_SEARCH` in the `config.toml` file located in the root directory of Devika, or you can set it via the UI.

### Step 4: Create a Custom Search Engine
- Go to the [Google Custom Search Engine](https://programmablesearchengine.google.com/controlpanel/all) website.
- Click on the `Add` button to create a new search engine.
- ![Create Search Engine](images/google-2.png)
- After creating the engine, copy the `Search Engine ID`.
- Paste it in the `API_Endpoints` field with the name `GOOGLE_SEARCH_ENGINE_ID` in the `config.toml` file located in the root directory of Devika, or you can set it via the UI.
```

## Google Search API
- if don't have then create GCP account [Google Cloud Console](https://console.cloud.google.com/).
- visit [Here](https://developers.google.com/custom-search/v1/overview) is the official documentation.
- click on `Get a Key`.
- select the project you have or create a new project. click on next.
![alt text](images/google.png)
- it enable the Custom Search API for the project and create the API key.
- Copy the API key and paste it in the API_KEYS field with the name `GOOGLE_SEARCH` in the `config.toml` file in the root directory of Devika or you can set it via UI.
- for the search engine id, go to the [Google Custom Search Engine](https://programmablesearchengine.google.com/controlpanel/all) website.
- click on the `Add` button.
![alt text](images/google-2.png)
- After creating the engine. Copy the `Search Engine ID` and paste it in the API_Endpoints field with the name `GOOGLE_SEARCH_ENGINE_ID` in the `config.toml` file in the root directory of Devika or you can set it via UI.
4 changes: 2 additions & 2 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Devika's system architecture consists of the following key components:
8. **Knowledge Base**: Stores and retrieves project-specific information, code snippets, and learned knowledge for efficient access.
9. **Database**: Persists project data, agent states, and configuration settings.

Read [ARCHITECTURE.md](https://github.com/stitionai/devika/Docs/architecture/ARCHITECTURE.md) for the detailed architecture of Devika.
Read [UNDER_THE_HOOD.md](https://github.com/stitionai/devika/Docs/architecture/UNDER_THE_HOOD.md) for the detailed working of Devika.
Read [ARCHITECTURE.md](https://github.com/stitionai/devika/blob/main/docs/architecture/ARCHITECTURE.md) for the detailed architecture of Devika.
Read [UNDER_THE_HOOD.md](https://github.com/stitionai/devika/blob/main/docs/architecture/UNDER_THE_HOOD.md) for the detailed working of Devika.
43 changes: 43 additions & 0 deletions get-ollama-models.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /bin/bash
echo "/usr/local/bin/ollama pull llama3.2"
echo
/usr/local/bin/ollama pull llama3.2
echo
echo "/usr/local/bin/ollama pull llama3.1"
/usr/local/bin/ollama pull llama3.1
echo
echo "/usr/local/bin/ollama pull llama3"
/usr/local/bin/ollama pull llama3
echo
echo "/usr/local/bin/ollama pull gemma"
/usr/local/bin/ollama pull gemma
echo
echo "/usr/local/bin/ollama pull qwen"
/usr/local/bin/ollama pull qwen
echo
echo "/usr/local/bin/ollama pull qwen2"
/usr/local/bin/ollama pull qwen2
echo
echo "/usr/local/bin/ollama pull mistral"
/usr/local/bin/ollama pull mistral
echo
echo "/usr/local/bin/ollama pull phi3:14b"
/usr/local/bin/ollama pull phi3:14b
echo
echo "/usr/local/bin/ollama pull phi3:3.8b"
/usr/local/bin/ollama pull phi3:3.8b
echo
echo "/usr/local/bin/ollama pull codellama"
/usr/local/bin/ollama pull codellama
echo
echo "/usr/local/bin/ollama pull qwen2.5"
/usr/local/bin/ollama pull qwen2.5
echo
echo "/usr/local/bin/ollama pull llama2"
/usr/local/bin/ollama pull llama2
echo
echo "/usr/local/bin/ollama pull gemma2"
/usr/local/bin/ollama pull gemma2
echo
echo "/usr/local/bin/ollama pull llama3.1:70b"
/usr/local/bin/ollama pull llama3.1:70b
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ orjson
gevent
gevent-websocket
curl_cffi
vite
shutils
Loading