Skip to content

Commit

Permalink
Merge pull request #46 from sirji-ai/reliability
Browse files Browse the repository at this point in the history
Bug fixes and enhancements to make Sirji more reliable
  • Loading branch information
V-R-Dighe authored Apr 12, 2024
2 parents ec69a74 + 9abfbb4 commit a84fcb7
Show file tree
Hide file tree
Showing 22 changed files with 157 additions and 79 deletions.
22 changes: 16 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,33 @@ Open the folder in Visual Studio Code by running:
code .
```

### 4. Install Dependencies
### 4. Local PyPI Packages

Update `src/py_scripts/requirements.txt` with the following content, to use the local editable installations of the PyPI packages:

```
urllib3==1.25.11
-e {{absolute path to cloned sirji repo}}/messages
-e {{absolute path to cloned sirji repo}}/agents
```

### 5. Install Dependencies

Install the project dependencies:

```zsh
npm install
```

### 5. Compile TypeScript
### 7. Compile TypeScript

Compile the TypeScript code to JavaScript:

```zsh
npm run compile
npm run watch
```

### 6. Run Sirji in Debug Mode
### 8. Run Sirji in Debug Mode

To start debugging the extension and see your changes in action, follow these steps:

Expand All @@ -77,7 +87,7 @@ To start debugging the extension and see your changes in action, follow these st

- Press the **Start Debugging** button (the green play icon) to launch a new VS Code window (Extension Development Host) where the extension will be loaded.

### 7. Activating Sirji
### 9. Activating Sirji

To activate the extension in the Extension Development Host:

Expand All @@ -95,6 +105,6 @@ To contribute to one of the PyPI packages (`sirji-agents`, `sirji-messages`, `si

## Questions or Issues?

If you face any issues or have questions about contributing, don’t hesitate to open an issue in our GitHub repository. We're here to help and look forward to your contributions!
If you run into any issues or have suggestions, please report them by following our [issue reporting guidelines](./ISSUES.md). Your reports help us make Sirji better for everyone.

Thank you for considering contributing to Sirji. Happy coding!
2 changes: 1 addition & 1 deletion agents/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sirji-messages==0.0.13
sirji-messages==0.0.14
sirji-tools==0.0.9
openai==1.14.1
2 changes: 1 addition & 1 deletion agents/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='sirji-agents',
version='0.0.18',
version='0.0.19',
author='Sirji',
description='Research, Coding and Planning agents used by Sirji.',
license='MIT',
Expand Down
2 changes: 1 addition & 1 deletion agents/sirji_agents/llm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __call_llm(self, conversation):

chat_completion = self.client.chat.completions.create(
messages=history,
model="gpt-4-turbo-preview",
model="gpt-4-turbo",
temperature=0,
max_tokens=4095,
)
Expand Down
2 changes: 1 addition & 1 deletion agents/sirji_agents/researcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ In this part, the LLM model is called to infer using a prompt that has both the

## Fun Fact

When developing the Researcher module, we needed to go through the OpenAI Assistants API documentation. This documentation was outside the knowledge of our LLM (gpt-4-turbo-preview). So the model was not able to assist us in development. Rather than going through the documentation manually, we thought of using the Sirji approach to research. We manually indexed (manual, since the automated process is what we needed to develop) a new assistant with the PDF prints of the documentation. After this indexing, the assistant helped us to write the Researcher. This also proved to us that the Sirji way of research works!
When developing the Researcher module, we needed to go through the OpenAI Assistants API documentation. This documentation was outside the knowledge of our LLM (gpt-4-turbo). So the model was not able to assist us in development. Rather than going through the documentation manually, we thought of using the Sirji approach to research. We manually indexed (manual, since the automated process is what we needed to develop) a new assistant with the PDF prints of the documentation. After this indexing, the assistant helped us to write the Researcher. This also proved to us that the Sirji way of research works!
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _create_assistant(self):
name="Research Assistant",
instructions="As a research assistant, your task is to address problem statements programmatically. In your response, include code examples, GitHub URLs, relevant external URLs based on your trained knowledge. Also, if knowledge on additional terms is needed, mention them in your response. Avoid providing fabricated information if uncertain.",
tools=[{"type": "retrieval"}],
model="gpt-4-turbo-preview",
model="gpt-4-turbo",
)

logger.info("Completed creating a new assistant")
Expand Down
2 changes: 1 addition & 1 deletion agents/sirji_agents/researcher/inferer/openai_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _fetch_response(self):
run = self.client.beta.threads.runs.create(
thread_id=self.init_payload['thread_id'],
assistant_id=self.assistant_id,
model="gpt-4-turbo-preview",
model="gpt-4-turbo",
tools=[{"type": "retrieval"}]
)

Expand Down
2 changes: 1 addition & 1 deletion messages/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='sirji-messages',
version='0.0.13',
version='0.0.14',
author='Sirji',
description='Sirji messaging protocol implementation to create, validate and parse messages.',
license='MIT',
Expand Down
2 changes: 1 addition & 1 deletion messages/sirji_messages/messages/actions/create_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def template_payload_part(self):

def sample(self):
return self.generate({
"file_name": "File name along with the path.",
"file_name": "File name along with the path relative to the workspace root folder.",
"content": "Multiline file content. It should start from a new line."
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def template_payload_part(self):

def sample(self):
return self.generate({
"command": "Command to execute."
"command": "Command to execute, considering workspace root folder as current working directory."
})

def description(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def template_payload_part(self):

def sample(self):
return self.generate({
"command": "Command to install the package or library."
"command": "Command to execute, considering workspace root folder as current working directory."
})

def description(self):
Expand Down
2 changes: 1 addition & 1 deletion messages/sirji_messages/messages/actions/read_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def template_payload_part(self):

def sample(self):
return self.generate({
"dir_path": "Name of a directory alongwith the path.",
"dir_path": "Name of a directory alongwith the path relative to the workspace root folder.",
})

def description(self):
Expand Down
2 changes: 1 addition & 1 deletion messages/sirji_messages/messages/actions/read_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def template_payload_part(self):

def sample(self):
return self.generate({
"file_name": "File name along with the path.",
"file_name": "File name along with the path relative to the workspace root folder.",
})

def description(self):
Expand Down
2 changes: 1 addition & 1 deletion messages/sirji_messages/messages/actions/run_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def template_payload_part(self):

def sample(self):
return self.generate({
"command": "Command to start server process."
"command": "Command to start server process. This command should be relative to the workspace root folder."
})

def description(self):
Expand Down
37 changes: 21 additions & 16 deletions messages/sirji_messages/system_prompts/agents/coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,37 @@ def responsibilities(self):
- Make sure that key points, information and data is always present in the user story.
- Have the features listed as points in the user story.
- Then send this user story as a {ActionEnum.QUESTION.name} to get a confirmation on. The message details should look like: "\nHere's the user story based on your problem statement:\n\n <<user story>> \n\nDoes everything look good, or would you like any changes?"
- Once user story is finalized, by considering the user story and the features in it prepare a list of architecture components needed and get it finalized with the {AgentEnum.USER.name}:
- Prepare list of architecture components including things like programming language (example: Python, Node.js), Framework (example: Express, Flask), Database (example: PostgreSQL, MySQL), Cache (example: Memcache, Redis), etc.
- Once the user story is finalized, then ensure to prepare a list of architecture components needed (by considering the problem statement and the finalized user story) and get it finalized with the {AgentEnum.USER.name}:
- Prepare list of architecture components including things like:
- Programming language (example: Python, Node.js),
- Framework (example: Express, Flask),
- Database (example: PostgreSQL, MySQL),
- Cache (example: Memcache, Redis), etc.
- Do not include Hosting component.
- Have only those components which can run on or can be called from a local development environment.
- Have the architecture components listed as points and sub-points.
- Then send the architecture components as a {ActionEnum.QUESTION.name} to get a confirmation on. The message details should look like: "\nHere are the main parts of the architecture::\n\n <<architecture components>> \n\nDoes everything look good to you, or do you need any adjustments?"
- Show the architecture components listed as points. Also specify intent of each component.
- Send the architecture components as a {ActionEnum.QUESTION.name} to get a confirmation on. The message details should look like: "\nHere are the main parts of the architecture::\n\n <<architecture components>> \n\nDoes everything look good to you, or do you need any adjustments?"
- Once architecture components are finalized, then {ActionEnum.GENERATE_STEPS.name} to solve the problem statement:
- Share the problem statement, finalized user story and finalized architecture compoents with {AgentEnum.PLANNER.name} to get the list of steps on how to solve the problem statement (PS).
- The message details shared with the planner should look like "\n\nProblem Statement (PS):\n<<problem statement>>\n\nUser Story:\n<<finalized user story>>\n\nArchitecture Components:\n<<finalized architecture components>>"
- Once steps are generated, Solve the problem statement programatically by following the generated steps:
- Write concrete code and not just conceptualize or simulate it.
- Always write end-to-end working code in accordance with the problem statement, user story, and architectural components. Strictly don't just create an outline or folder structure.
- Use Python, if the programming language cannot be inferred from PS.
- Once steps are generated, ensure to solve the problem statement programatically by following the generated steps (one step at a time sequentially):
- Always write end-to-end working code in accordance with the problem statement, user story, and architectural components.
- Write concrete code and not just conceptualize or outline or simulate it.
- Identify URLs (Excluding GitHub) present in the PS, on which you have no knowledge and want to be trained on or researched. After training, infer from the trained content/knowledge. If the response of the inference has new URLs (Excluding GitHub), on which you have no knowledge, you can get trained on them too.
- Follow the generated steps sequentially to solve the PS.
- Follow secure software development practices while generating code.
- Ensure that you don't create any file/folder outside of current directory, i.e. './'
- Ensure that you don't create any file/folder outside of workspace root folder, i.e. './'
- Read the GitHub files by first cloning the repository and then reading the files at once.
- Strictly make sure:
- Ensure while responding with {ActionEnum.EXECUTE_COMMAND.name} action or {ActionEnum.INSTALL_PACKAGE.name} action:
- Command must be compatible with macOS.
- Command must be sufficiently chained. For example: 'source venv/bin/activate && pip install openai', 'cd server && npm run start'
- Always make sure:
- To respond with the {ActionEnum.RUN_SERVER.name} action to run a server like continuous process.
- Do not execute chained commands with the {ActionEnum.EXECUTE_COMMAND.name} action.
- Ensure if the step is to verify whether a command is installed or not, you check them one at a time.
- Ensure to always call 'pwd' command before using 'cd' command (either in a standalone way).
- On getting file not found error for files which you created earlier, reason might be a wrongly assumed current directory. Check the present working directory using 'pwd' command.
- Pose explicit questions only when you have no other option but to reach out to the user. An ideal question format is direct, such as "Should I ...?" Additionally, it is crucial to ask such questions only when absolutely necessary.
- Always notify about the step started before you start working on it. Similarly, notify about the step completed before you move to the next step.
- Regarding step status change messages ({ActionEnum.STEP_STARTED.name} action, {ActionEnum.STEP_COMPLETED.name} action):
- Always implement / work on one step at a time, let's call it the current step.
- If the work for the current step was already done as a part of some previous step, respond with {ActionEnum.STEP_COMPLETED.name} action for the current step.
- Before starting work for the current step, respond with {ActionEnum.STEP_STARTED.name} action for the current step.
- Before moving to the next step, respond with {ActionEnum.STEP_COMPLETED.name} action for the current step.
- Only interact with the agents listed below using the allowed responses, also mentioned below.
- Ensure the response is also enclosed inside 3 backticks (```).
- If error is encountered in execution of a command, then find the root cause and resolve the issue by solving the root cause.
Expand Down
File renamed without changes.
57 changes: 37 additions & 20 deletions sirji/vscode-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,45 @@

## Sirji

Sirji is a Visual Studio Code Extension that acts as an AI Software Development Agent, an open-source alternative to Devin. It functions as a virtual software developer, geared towards solving the given problem statement. These problem statements can either involve fresh, greenfield development or efforts aimed at enhancing existing code, bug fixing, documentation, and test case creation in brownfield development.
Sirji is a Visual Studio Code extension that works as an AI software development agent.

The extension leverages the capabilities of VS Code, including the Editor, Terminal, Browser, and Project Explorer.
It is a virtual software developer that includes individual agents for planning, coding, researching, and executing projects.

Additionally, it provides an interactive chat interface through which users can submit their problem statements, enhancement requests, feedback, and answers to requests for elaboration.
Sirji solves users’ problem statements ranging from a new greenfield project to an existing brownfield project where it enhances existing code, fixes bugs, and writes test cases.

## Demo Videos
The extension leverages the capabilities of VS Code, including the Editor, Terminal, and Project Explorer.

It provides an interactive chat interface through which users submit their problem statements, answer questions, and provide feedback to Sirji.

Additionally and most importantly, Sirji sets up your local development environment by installing system-level packages as well as programming language-specific dependencies. It later executes the generated code in your local development environment.

## Demo Video

```
Create a fully interactive website for playing the Tic-Tac-Toe game.
```

Watch on YouTube: <a href="https://www.youtube.com/watch?v=DC_gmz04Ovs" target="_blank">https://www.youtube.com/watch?v=DC_gmz04Ovs</a>

<a href="https://www.youtube.com/watch?v=DC_gmz04Ovs" target="_blank"><img src="https://github.com/sirji-ai/sirji/assets/7627517/fff071a6-f019-4797-ad44-55d7670e819f" alt="Tic Tac Toe game by Sirji"></a>

TODO: Show 2 good demo videos - side by side. Then afterwards, give a link to the demos page.

## Prerequisites

Sirji has been tested on **macOS** only for now. We know there are certain OS-specific functionalities that we will soon generalize.

Make sure you have installed all of the following prerequisites on your machine:

- Visual Studio Code (>= 1.80.2)
- Node.js (>= 18) and npm (>= 8.19)
- Python (>= 3.10) - Make sure `python --version` runs without error.
- tee command - Make sure `which tee` runs without error.

To check whether your machine meets these prerequisites, run:

```zsh
sh check_prerequisites.sh
```

Also, you will need an OpenAI API key.

## Contributing

We welcome contributions to Sirji! If you're interested in helping improve this VS Code extension, please take a look at our [Contributing Guidelines](./CONTRIBUTING.md) for more information on how to get started.

Thank you for considering contributing to Sirji. We look forward to your contributions!
Also, you will need an OpenAI API key to access the GPT-4 Turbo model.

## Reporting Issues
## Installation

If you run into any issues or have suggestions, please report them by following our [issue reporting guidelines](./ISSUES.md). Your reports help us make Sirji better for everyone.
You can start using Sirji by installing this [extension](https://marketplace.visualstudio.com/items?itemName=TrueSparrow.sirji) from the Visual Studio Marketplace.

## Architecture

Expand All @@ -84,6 +87,20 @@ The tools for crawling URLs (converting them into markdowns), searching for term

All these packages are invoked by Python Adapter Scripts, which are spawned by the extension.

## Contributing

We welcome contributions to Sirji! If you're interested in helping improve this VS Code extension, please take a look at our [Contributing Guidelines](./CONTRIBUTING.md) for more information on how to get started.

Thank you for considering contributing to Sirji. We look forward to your contributions!

## Reporting Issues

If you run into any issues or have suggestions, please report them by following our [issue reporting guidelines](./ISSUES.md). Your reports help us make Sirji better for everyone.

## Stay In Touch

<a href="https://calendly.com/nishith-true-sparrow/30min" target="_blank">Office Hours</a>

## License

Distributed under the MIT License. See `LICENSE` for more information.
2 changes: 1 addition & 1 deletion sirji/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sirji",
"displayName": "Sirji",
"description": "Sirji is an AI Software Development Agent.",
"version": "0.0.5",
"version": "0.0.6",
"publisher": "TrueSparrow",
"icon": "out/assets/sirji.png",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions sirji/vscode-extension/src/py_scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
urllib3==1.25.11
sirji-messages==0.0.13
sirji-agents==0.0.18
sirji-messages==0.0.14
sirji-agents==0.0.19
Loading

0 comments on commit a84fcb7

Please sign in to comment.