Skip to content

Commit

Permalink
Update code reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcampagnolitg committed Aug 8, 2024
1 parent 6241354 commit 198811c
Show file tree
Hide file tree
Showing 24 changed files with 425 additions and 252 deletions.
51 changes: 34 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@

## The Nous Story

Nous started from a simple goal: to harness AI's potential to **enhance real-world productivity**, born in DevOps and Platform Engineering space. We envisioned a tool that could:
Nous started from a simple goal: to harness AI's potential to enhance real-world productivity, born in DevOps and Platform Engineering space. We envisioned a tool that could:

- Automate standard and simple requests using natural language prompts.
- Intelligently triage build failures, support requests and production incidents.
- Automate various processes and support requests, and triage build failures.
- Review code for compliance with standards and best practices.
- Assist with large/complex refactorings, and more.
- Assist with large refactorings, and more.

At TrafficGuard we process billions of events a month for our global clients, [increasing their ad spend ROI](https://www.trafficguard.ai/case-studies?ref=gh) by protecting against bots and other forms of invalid traffic.
Our SaaS on GCP comprises projects developed in TypeScript, Python, GoogleSQL, PHP and Terraform, deployed from GitLab.
Expand All @@ -42,7 +41,7 @@ Key features include:

- Advanced autonomous agents
- Reasoning/planning inspired from Google's [Self-Discover](https://arxiv.org/abs/2402.03620) paper
- Memory and function history for complex, multi-step workflows
- Memory and function call history for complex, multi-step workflows
- Adaptive iterative planning with hierarchical task decomposition
- Two control-loop function calling options (LLM-independent):
- Custom XML-based function calling
Expand All @@ -65,7 +64,7 @@ Key features include:
- Observability with OpenTelemetry tracing
- Code Editing Agent:
- Auto-detection of project initialization, compile, test and lint
- Find the relevant files to edit
- Find the relevant files to edit and perform initial analysis
- Code editing loop with compile, lint, test, fix (editing delegates to [Aider](https://aider.chat/))
- Compile error analyser can search online, add additional files and packages
- Software Engineer Agent:
Expand All @@ -79,7 +78,7 @@ Key features include:

## UI Examples

[New Agent](#new-agent) | [Sample trace](#sample-trace) | [Human in the loop notification](#human-in-the-loop-notification) | [Resume error](#resume-error) | [List agents](#list-agents)
[New Agent](#new-agent) | [Sample trace](#sample-trace) | [Human in the loop notification](#human-in-the-loop-notification) | [Resume error](#resume-error) | [List agents](#list-agents) | [Code review config](#code-review-configuration)

### New Agent

Expand All @@ -93,14 +92,18 @@ Key features include:

<img src="https://public.trafficguard.ai/nous/feedback.png" width="702">

### Resume error
### Agent requested feedback

![Resume error](https://public.trafficguard.ai/nous/error.png)
![Feedback requested](https://public.trafficguard.ai/nous/agent-feedback.png)

### List agents

![List agents](https://public.trafficguard.ai/nous/list.png)

### Code review configuration

![Code review configuration](https://public.trafficguard.ai/nous/code-review.png)

## Code Examples

### Nous vs LangChain
Expand Down Expand Up @@ -147,18 +150,32 @@ console.log(result);

#### Nous
```typescript
import { initAgentContext, llms } from '#agent/context'
import { llms } from '#agent/context'
import { anthropicLLMs } from '#llms/anthropic'

initAgentContext(anthropicLLMs());

const prompt1 = (person: string) => `What is the city ${person} is from? Only respond with the name of the city.`;
const prompt2 = (city: string, language: string) => `What country is the city ${city} in? Respond in ${language}.`;

const city = await llms().easy.generateText(prompt1('Obama'));
const result = await llms().easy.generateText(prompt2(city, 'German'));
runAgentWorkflow({ llms: anthropicLLMs() }, async () => {
const city = await llms().easy.generateText(prompt1('Obama'));
const result = await llms().easy.generateText(prompt2(city, 'German'));

console.log(result);
console.log(result);
});
```

The Nous code also has the advantage of static typing with the prompt arguments, enabling you to refactor with ease.
Using simple control flow allows easy debugging with breakpoints/logging.

To run a fully autonomous agent:

```typescript
startAgent({
agentName: 'Create ollama',
initialPrompt: 'Research how to use ollama using node.js and create a new implementation under the llm folder. Look at a couple of the other files in that folder for the style which must be followed',
functions: [FileSystem, Perplexity, CodeEditinAgent],
llms,
});
```

The Nous code also has the advantage of static typing with the prompt arguments, enabling you to refactor with ease.
Expand All @@ -176,10 +193,10 @@ Visit our [documentation site](https://nous.trafficguard.ai/setup/) for the gett

## Contributing

We welcome contributions to the project through [issues](https://github.com/TrafficGuard/nous/issues), [pull requests](https://github.com/TrafficGuard/nous/pulls) or [discussions](https://github.com/TrafficGuard/nous/discussions)
We warmly welcome contributions to the project through [issues](https://github.com/TrafficGuard/nous/issues), [pull requests](https://github.com/TrafficGuard/nous/pulls) or [discussions](https://github.com/TrafficGuard/nous/discussions)

Contributed by [TrafficGuard](https://www.trafficguard.ai) - Increasing the ROI on your ad spend.


Reach out to us as nous@trafficguard.ai if you'd like support to ramp up as a contributor.


39 changes: 29 additions & 10 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

Nous started from a simple goal: to harness AI's potential to enhance real-world productivity, born in DevOps and Platform Engineering space. We envisioned a tool that could:

- Automate standard processes and triage build failures, support requests and production incidents.
- Automate various processes and support requests, and triage build failures.
- Review code for compliance with standards and best practices.
- Assist with large/complex refactorings, and more.
- Assist with large refactorings, and more.

At TrafficGuard we process billions of events a month for our global clients, [increasing their Ad spend ROI](https://www.trafficguard.ai/case-studies?ref=nous) from bots and other invalid traffic.
Our platform on Google Cloud comprises projects developed in TypeScript, Python, GoogleSQL, PHP and Terraform, deployed from GitLab.
Expand All @@ -32,7 +32,7 @@ Some of the key features include:

- Advanced autonomous agents
- Reasoning/planning inspired from Google's [Self-Discover](https://arxiv.org/abs/2402.03620) paper
- Memory and function history for complex workflows
- Memory and function call history for complex workflows
- Iterative planning with hierarchical task decomposition
- Two LLM-independent function calling options:
- Custom XML-based function calling
Expand All @@ -55,7 +55,7 @@ Some of the key features include:
- Observability with OpenTelemetry tracing
- Code Editing Agent:
- Auto-detection of project initialization, compile, test and lint
- Find the relevant files to edit
- Find the relevant files to edit and perform initial analysis
- Code editing loop with compile, lint, test, fix (editing delegates to [Aider](https://aider.chat/))
- Compile error analyser can search online, add additional files and packages
- Review the changes with an additional code editing loop if required.
Expand All @@ -82,14 +82,18 @@ Some of the key features include:

<img src="https://public.trafficguard.ai/nous/feedback.png" width="702">

### Resume error
### Agent requested feedback

![Resume error](https://public.trafficguard.ai/nous/error.png)
![Feedback requested](https://public.trafficguard.ai/nous/agent-feedback.png)

### List agents

![List agents](https://public.trafficguard.ai/nous/list.png)

### Code review configuration

![Code review configuration](https://public.trafficguard.ai/nous/code-review.png)

## Code Examples

### Nous vs LangChain
Expand Down Expand Up @@ -137,19 +141,33 @@ console.log(result);
#### Nous
```typescript
import { llms } from '#agent/context'
import { anthropicLLMs } from '#llms/anthropic'

const prompt1 = (person: string) => `What is the city ${person} is from? Only respond with the name of the city.`;
const prompt2 = (city: string, language: string) => `What country is the city ${city} in? Respond in ${language}.`;

const city = await llms().easy.generateText(prompt1('Obama'));
const result = await llms().easy.generateText(prompt2(city, 'German'));
runAgentWorkflow({ llms: anthropicLLMs() }, async () => {
const city = await llms().easy.generateText(prompt1('Obama'));
const result = await llms().easy.generateText(prompt2(city, 'German'));

console.log(result);
console.log(result);
});
```

The Nous code also has the advantage of static typing with the prompt arguments, enabling you to refactor with ease.
Using simple control flow allows easy debugging with breakpoints/logging.

To run a fully autonomous agent:

```typescript
startAgent({
agentName: 'Create ollama',
initialPrompt: 'Research how to use ollama using node.js and create a new implementation under the llm folder. Look at a couple of the other files in that folder for the style which must be followed',
functions: [FileSystem, Perplexity, CodeEditinAgent],
llms,
});
```

### Automated LLM function schemas

LLM function calling schema are automatically generated by having the `@func` decorator on class methods, avoiding the
Expand All @@ -176,5 +194,6 @@ export class Jira {

## Contributing

We welcome contributions to the project through [issues](https://github.com/TrafficGuard/nous/issues), [pull requests](https://github.com/TrafficGuard/nous/pulls) or [discussions](https://github.com/TrafficGuard/nous/discussions)
We warmly welcome contributions to the project through [issues](https://github.com/TrafficGuard/nous/issues), [pull requests](https://github.com/TrafficGuard/nous/pulls) or [discussions](https://github.com/TrafficGuard/nous/discussions)

Reach out to us as nous@trafficguard.ai if you'd like support to ramp up as a contributor.
6 changes: 4 additions & 2 deletions docs/docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ GitHub support

Ollama support

https://github.com/nextauthjs/next-auth/pull/9587

Additional agents:

- Slack chatbot agent
- SWE-bench agent
- Build failure investigation agent
- Autonomous agent which generates Python executed by Pyodide for tool function calling
- Add tools for GAIA agent
- CI/CD failure investigation agent

Improvements to the autonomous and code editing agents (a whole roadmap in itself)

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/code-review/code-review-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div formGroupName="file_extensions" class="col">
<mat-form-field appearance="fill" class="full-width">
<mat-label>Included File Extensions</mat-label>
<mat-chip-list #chipList>
<mat-chip-list #chipList required>
<mat-chip
*ngFor="let ext of editForm.get('file_extensions.include')?.value"
[removable]="true"
Expand All @@ -38,7 +38,7 @@
<div formGroupName="requires" class="col">
<mat-form-field appearance="fill" class="full-width">
<mat-label>Required Text In Diff</mat-label>
<mat-chip-list #requiredChipList>
<mat-chip-list #requiredChipList required>
<mat-chip
*ngFor="let text of editForm.get('requires.text')?.value"
[removable]="true"
Expand Down
25 changes: 22 additions & 3 deletions frontend/src/app/code-review/code-review-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export class CodeReviewEditComponent implements OnInit {
requires: this.fb.group({
text: [[], [Validators.required, this.arrayNotEmpty]],
}),
tags: [[], this.arrayNotEmpty],
project_paths: [[], this.arrayNotEmpty],
tags: [[]],
project_paths: [[]],
examples: this.fb.array([], [Validators.required, this.arrayNotEmpty]),
});
}
Expand All @@ -59,7 +59,26 @@ export class CodeReviewEditComponent implements OnInit {
this.isLoading = true;
this.codeReviewService.getCodeReviewConfig(this.configId!).subscribe(
(response) => {
this.editForm.patchValue(response.data);
const data = response.data;
this.editForm.patchValue(data);

// Clear existing examples
while (this.examples.length !== 0) {
this.examples.removeAt(0);
}

// Add examples from the loaded data
if (data.examples && Array.isArray(data.examples)) {
data.examples.forEach((example: any) => {
this.examples.push(
this.fb.group({
code: [example.code, Validators.required],
review_comment: [example.review_comment, Validators.required],
})
);
});
}

this.isLoading = false;
},
(error) => {
Expand Down
41 changes: 25 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"ignore": "^5.3.1",
"jsdom": "^24.0.0",
"lodash": "^4.17.20",
"micromatch": "^4.0.7",
"module-alias": "^2.2.2",
"openai": "^4.28.4",
"pino": "^8.18.0",
Expand Down
Loading

0 comments on commit 198811c

Please sign in to comment.