Skip to content

Commit d6223be

Browse files
V0.6.0 release (#47)
* Cache agents and chats in the UI * Update backend tsconfig.json target to 2023 * Fix chat title generation * Add multi-agent LLM implementation for reasoning LLMs * Update Perplexity LLM and tool to sonar models * Replace extractStringResult with generic extractTag * Fix DeepSeek R1 model id * Add Together.ai DeepSeek R1 * Add LLM maxRetries opt * Update project detection to use the filesystem tree to handle larger projects * Update listing of files to account for .gitignore in parent directories * Update extractFilenames to use getFileSystemTree * feat: Add iteration parameter to file selection processing response function * Update selectFilesAgent and deprecate codebaseQuery * Update ss script * Add DeepSeekR1LLM using Together and Fireworks * Add Multi-agent debate LLM implementation with reasoning models * Add execCmdSync to exec.ts * Create fastLlama70b.ts * Add deepinfra R1 models * Fix webhook check in auth middleware * Fix gitlab review webhook * Default chat temperature to 0.7 * Set safe directory in Dockerfile * GitLab debugging * Update GitLab code review * Docs updates. Add sonar-reasoning. Add chat keyboard shortcuts * Add Nebius service with DeepSeek R1 * Update LLMs. Update version to 0.6.0. Add CePO MoA * Rename Actions to Workflows * Add OpenAI o1 and o3-mini * Update OpenAI costs for caching
1 parent 1064e0c commit d6223be

File tree

81 files changed

+1573
-640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1573
-640
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ RUN mkdir .sophia
3535
# Generate the function schemas
3636
RUN npm run functionSchemas
3737

38+
# Needed to avoid the error "fatal: detected dubious ownership in repository at '/home/sophia'" when running git commands
39+
# as the application files are owned by the root user so an agent (which runs as the sophia user) can't modify them.
40+
RUN git config --global --add safe.directory /home/sophia
41+
3842
ENV NODE_ENV=production
3943
ENV PORT=8080
4044
EXPOSE 8080

bin/configure

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,26 @@ fi
2828
echo Initialising Angular project
2929
cd frontend
3030
npm install
31-
cd ..
31+
cd ..
32+
33+
# CLI setup -------------
34+
35+
# Setup for bash
36+
if [ -f ~/.bashrc ]; then
37+
if ! grep -q "SOPHIA_HOME" ~/.bashrc; then
38+
echo "\n# Sophia CLI environment" >> ~/.bashrc
39+
echo "export SOPHIA_HOME=$(pwd)" >> ~/.bashrc
40+
echo "export PATH=\$SOPHIA_HOME/bin/path:\$PATH" >> ~/.bashrc
41+
fi
42+
fi
43+
44+
# Setup for zsh
45+
if [ -f ~/.zshrc ]; then
46+
if ! grep -q "SOPHIA_HOME" ~/.zshrc; then
47+
echo "\n# Sophia CLI environment" >> ~/.zshrc
48+
echo "export SOPHIA_HOME=$(pwd)" >> ~/.zshrc
49+
echo "export PATH=\$SOPHIA_HOME/bin/path:\$PATH" >> ~/.zshrc
50+
fi
51+
fi
52+
53+
echo "done"

bin/path/ss

100644100755
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,15 @@ script=$1
1919
shift # Shift the arguments so $@ contains the remaining args
2020

2121
CWD=$(pwd)
22+
23+
# Load NVM
24+
export NVM_DIR="$HOME/.nvm"
25+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
26+
27+
set -x
2228
# Run the npm script with any additional arguments and the filesystem arg
23-
(cd "$SOPHIA_HOME" && npm run "$script" -- --fs="${CWD}" "$@")
29+
(
30+
cd "$SOPHIA_HOME"
31+
nvm use
32+
npm run "$script" -- --fs="${CWD}" "$@"
33+
)

docs/docs/agent-concepts.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,32 @@
22

33
## Agent categories
44

5+
We follow a similar naming convention described in [Building Effective Agents](https://www.anthropic.com/research/building-effective-agents) by Anthropic.
6+
7+
> "Agent" can be defined in several ways. Some customers define agents as fully autonomous systems that operate independently over extended periods, using various tools to accomplish complex tasks. Others use the term to describe more prescriptive implementations that follow predefined workflows. At Anthropic, we categorize all these variations as agentic systems, but draw an important architectural distinction between workflows and agents:
8+
>
9+
> Workflows are systems where LLMs and tools are orchestrated through predefined code paths.
10+
>
11+
> Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks.
12+
513
### 1. Autonomous agents
614

715
Sophia comes with two autonomous agent types (XML and CodeGen), which applying reasoning to break down
816
a user request into a plan to be completed by the available function calls.
917

1018
The Slack chatbot uses an autonomous agent to provide a response to a user.
1119

12-
Function calls may be to API integrations or create sub-agents.
20+
Functions may call to API integrations or create sub-agents.
1321

1422
### 2. Workflow agents
1523

1624
Workflow agents have the control flow logic defined in code, and the results of the LLM calls
17-
may determine the conditional control flow through the workflow. This includes the Software Developer/Code Editing agents.
25+
may determine the conditional control flow through the workflow. This includes the Software Developer/Code Editing workflow agents.
1826

1927
## Agent context
2028

2129
The codebase makes use of `AsyncLocalStorage`, which is similar to `ThreadLocal` in Java and `threading.local()` in Python,
22-
to provide easy lookup of agent state, current user, tool configuration, and default LLMs.
30+
to provide easy lookup of agent state, current user, tool configuration, and default LLMs for both autonomous agents and workflow agents.
2331

2432
This requires the agent code to run within a AsyncLocalStorage context.
2533
```typescript

docs/docs/autonomous-agents.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Autonomous AI Agents
22

3+
- Reasoning/planning inspired from Google's [Self-Discover](https://arxiv.org/abs/2402.03620) and other papers
4+
- Memory and function call history for complex workflows
5+
- Iterative planning with hierarchical task decomposition
6+
- Sandboxed execution of generated code for multi-step function calling and logic
7+
- LLM function schemas auto-generated from source code
8+
- Human-in-the-loop for budget control, agent initiated questions and error handling
9+
310
Sophia provides two autonomous agents which work to complete the request via a control loop which iteratively (re-)plans and calls the functions available to the agent.
411

512
At a high level they share the same internal state, agent memory, human-in-the loop, functional calling history etc.

docs/docs/chat.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1-
# Chat
1+
# AI Chat
22

3-
A basic chat interface like chatgpt.com or claude.ai is provided where you can select the LLM model (or multi-agent model) used for each message generation.
3+
Sophia provides a chat interface like chatgpt.com or claude.ai.
44

5-
Attachments and more features are on the roadmap.
5+
## LLM selection
6+
7+
The LLM model selection can be changed over a conversation.
8+
9+
The model selection also allows selecting the composite implementations of the LLM interface such as multi-agent debate/review implementations or
10+
fallbacks across multiple.
11+
12+
## Attachments
13+
14+
Images and PDF files can be attached to a message. However, it is required that the LLM selected supports all the file/image types
15+
in the new and previous messages, otherwise an error will occur.
16+
17+
## Keyboard shortcuts
18+
19+
- **Ctrl - M**: Open the LLM model selection
20+
- **Ctrl - A**: Add attachment
21+
- **Ctrl - I**: Open/close the chat info/settings panel
22+
- **Ctrl - E**: Toggle enter sends the message or adds a new line
23+
<!--
24+
- **Ctrl - C**: Toggle caching (Anthropic models only)
25+
-->
26+
27+
## Screenshots
628

729
![Chats](https://public.trafficguard.ai/sophia/chat.png)

docs/docs/cli.md

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ There are two main ways to interact with the system:
55

66
## Running the server & UI
77

8+
Run the following commands from the sophia git repo root directory.
9+
810
### Local install
911
In one terminal run
1012
```bash
@@ -22,16 +24,39 @@ Run `docker compose up`
2224

2325
The UI will be available at [http://localhost:4200](http://localhost:4200)
2426

25-
## CLI scripts
27+
## CLI commands
28+
29+
## Running in Docker
30+
31+
To run the CLI scripts when using the Docker container, run the script `./bin/container` from the repo root to first open a bash shell inside the Sophia development container.
32+
33+
### Running outside the repository
34+
35+
To run Sophia agents/workflows via the CLI script described below, in a folder outside the sophia repository, the script at `bin/path/ss` allows you to invoke the Sophia package.json scripts from any directory.
36+
37+
The `bin/configure` script will update your shell configuration files to include it in your PATH.
38+
39+
Either run the `bin/configure` script from the Sophia repository root or copy and run the required section from the script. This will add to your .bashrc and .zshrc files (if they exist) the output of:
40+
41+
```bash
42+
export SOPHIA_HOME=$(pwd)
43+
export PATH=$SOPHIA_HOME/bin/path:$PATH
44+
```
45+
46+
Then from any folder you can run commands like:
2647

27-
To run the CLI scripts when using the Docker container, run the script `./bin/container` to open a bash shell inside the Sophia development container.
48+
`ss query what test frameworks does this repository use`
2849

50+
Where *query* is the Sophia package.json script. For all the examples in the CLI scripts section above you can replace `npm run` with `ss`
51+
52+
53+
### CLI scripts
2954

3055
There are a number of convenience scripts in the package.json for running agents and other scripts such as benchmarks, where the entrypoint file matches `/src/cli/<script-name>.ts`
3156

3257
### agent
3358

34-
`npm run agent` will run the autonomous agent configured in `src/cli/agent.ts`
59+
`npm run agent` or `ss agent` will run the autonomous agent configured in `src/cli/agent.ts`. Note that the agent will have the functions available configured in the `agent.ts` file.
3560

3661
If no arguments are supplied the user prompt will be read from `src/cli/agent-in`
3762

@@ -44,7 +69,7 @@ npm run agent research the latest news about large language models and write a r
4469

4570
### code
4671

47-
`npm run code` runs the CodeEditingAgent configured in `src/cli/code.ts`
72+
`npm run code` or `ss code` runs the [CodeEditingAgent](/software-engineer/) configured in `src/cli/code.ts`
4873

4974
Without arguments the prompt is read from `src/cli/code-in` otherwise it uses the provided arguments for the prompt.
5075

@@ -54,12 +79,22 @@ This is a useful for editing the sophia codebase. You could run a command like:
5479
npm run code In the anthropic vertex class update the pricing for claude 3.5 sonnet to be 3 dollars per million input tokens and 15 dollars per million output tokens
5580
```
5681

57-
When editing other local repositories you will need to provide the initial arg `-fs=<path>` to set the agent's virtual filesystem working
58-
directory to the repository you want to edit.
82+
When editing other repositories you will need use the `ss` command to run the agent with its virtual filesystem working
83+
directory set to the current shell directory.
84+
85+
### index
86+
87+
`npm run index` or `ss index`
88+
89+
This runs the agent which indexes a repository, and stores the summary index docs under `.sophia/docs`
90+
91+
### slack
92+
93+
`npm run slack` or `ss slack` starts the Slack chatbot. The chatbot will have the functions available defined in `src/modules/slack/slackChatBotService.ts`
5994

6095
### swe
6196

62-
`npm run swe` runs the SoftwareDeveloperAgent configured in `src/cli/swe.ts`
97+
`npm run swe` or `ss swe` runs the SoftwareDeveloperAgent configured in `src/cli/swe.ts`
6398

6499
Without arguments the prompt is read from `src/cli/swe-in` otherwise it uses the provided arguments for the prompt.
65100

@@ -69,7 +104,7 @@ This agent can be used for process automation and handling requests within the l
69104

70105
### gen
71106

72-
`npm run gen` runs the script at `src/cli/gen.ts`
107+
`npm run gen` or `ss gen` runs the script at `src/cli/gen.ts`
73108

74109
This simply generates text from a prompt. As with the other scripts you can provide arguments for a quick prompt.
75110
Otherwise, prepare the prompt in `src/cli/gen-in` and don't provide any other arguments.
@@ -90,19 +125,17 @@ Make sure the directory you save the files to is in the .gitignore.
90125

91126
### scrape
92127

93-
`npm run scrape <url>` runs the PublicWeb.getWebPage function which uses a headless browser to scrape a web page, and then converts
128+
`npm run scrape <url>` or `ss scrape <url>` runs the PublicWeb.getWebPage function which uses a headless browser to scrape a web page, and then converts
94129
it to a slim format by using the `@mozilla/readability` module to first extract the main contents of the page, and then the `turndown`
95130
package to convert the HTML to Markdown, further reducing the token count.
96131

97132
By default, it writes the output to `scrape.md`. Alternatively you can provide an argument for the file to write to.
98133

99134
### query
100135

101-
`npm run query <question>` runs the codebase query agent at *src/swe/discovery/codebaseQuery.ts* which can answer ad hoc
136+
`npm run query <question>` or `ss query <question>` runs the codebase query agent at *src/swe/discovery/fileSelectionAgent.ts* which can answer ad hoc
102137
questions about a codebase/folder contents.
103138

104-
105-
106139
## Development
107140

108141
### Running tests
@@ -116,25 +149,6 @@ npm run test
116149
```
117150

118151

119-
120-
121-
## CLI usage optimizations
122-
123-
### Helper CLI script
124-
125-
To run Sophia agents in other folders and repositories, the script at `bin/path/ss` allows you to invoke the Sophia package.json scripts from any directory.
126-
127-
To use this you in your shell config files (e.g. ~/.bashrc, ~/.zshrc)
128-
129-
- Set the `SOPHIA_HOME` variable to the path of the Sophia repository.
130-
- Add `$SOPHIA_HOME/bin/path` to the `PATH` variable.
131-
132-
Then from any folder you can run commands like:
133-
134-
`ss query what test frameworks does this repository use`
135-
136-
Where *query* is the Sophia package.json script. For all the examples in the CLI scripts section above you can replace `npm run` with `ss`
137-
138152
### Speech-to-text
139153

140154
Speech-to-text is useful writing longer prompts with additional details to guide the agents.

docs/docs/index.md

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,36 @@
44
<img src="https://public.trafficguard.ai/sophia/banner.png" alt="Sophia banner"/>
55
</p>
66
<p align="center">
7-
<em><b>The open TypeScript platform for AI agents and LLM based workflows</b></em><br/>
7+
<em><b><span style="font-size: x-large">The open TypeScript platform for AI agents, workflows & chat</span></b></em><br/>
88
<small>The Ancient Greek word <em><b>sophía (σοφία)</b></em> variously translates to "clever, skillful, intelligent, wise"</small>
99
</p>
1010

11-
Sophia is a full-featured platform for developing and running agents, LLM based workflows and chatbots.
11+
Sophia is a full-featured platform for developing and running autonomous agents, LLM based workflows, Slack chatbots, AI chat and more.
1212

1313
Included are capable software engineering agents, which have assisted building the platform.
1414

15-
## Key features
15+
## High level features
1616

1717
- [Advanced Autonomous agents](https://sophia.dev/autonomous-agents)
18+
- Faster/cheaper actions by generated function calling code (with sandboxed execution)
19+
- Complex tasks supported with memory, function call history, live files, file store etc.
20+
- Cost management with configurable Human-in-the-loop settings and cost tracking
21+
- Persistent state management. Restart from completion/error/human-in-loop
1822
- [Software developer agents](https://sophia.dev/software-engineer/)
23+
- Local repository editing
24+
- Ticket-to-pull request workflow
25+
- Repository indexing and ad-hoc query agents
26+
- Leverages [Aider](https://aider.chat/) for diff editing
1927
- [Pull request code review agent](https://sophia.dev/code-review/)
2028
- [AI chat interface](https://sophia.dev/chat/)
2129
- [Slack chatbot](https://sophia.dev/chatbot/)
22-
- Supports many LLM services - OpenAI, Anthropic (native & Vertex), Gemini, Groq, Fireworks, Together.ai, DeepSeek, Ollama, Cerebras, X.ai
30+
- Supports many LLM services - OpenAI, Anthropic (native & Vertex), Gemini, Groq, Fireworks, Together.ai, DeepSeek, Ollama, Cerebras, X.ai and more.
31+
- Simple LLM interface wrapping the [Vercel ai](https://sdk.vercel.ai/) package to add tracing and cost tracking.
2332
- Multi-agent [extend-reasoning implementations](https://github.com/TrafficGuard/sophia/tree/main/src/llm/multi-agent) of the LLM interface
24-
- Configurable Human-in-the-loop settings
2533
- Functional callable tools (Filesystem, Jira, Slack, Perplexity, Google Cloud, Gitlab, GitHub etc)
26-
- CLI and Web UI interface
27-
- Run locally or deployed on the cloud with multi-user/SSO
2834
- OpenTelemetry based observability
2935
- Leverages the extensive Python AI ecosystem through executing Python scripts/packages
3036

31-
## Autonomous agents
32-
33-
- Reasoning/planning inspired from Google's [Self-Discover](https://arxiv.org/abs/2402.03620) and other papers
34-
- Memory and function call history for complex workflows
35-
- Iterative planning with hierarchical task decomposition
36-
- Sandboxed execution of generated code for multi-step function calling and logic
37-
- LLM function schemas auto-generated from source code
38-
- Human-in-the-loop for budget control, agent initiated questions and error handling
39-
40-
Full details at the [Autonomous agent docs](https://sophia.dev/autonomous-agents)
41-
42-
## Software developer agents
43-
44-
- Code Editing Agent for local repositories
45-
- Auto-detection of project initialization, compile, test and lint
46-
- Task file selection agent selects the relevant files
47-
- Design agent creates the implementation plan.
48-
- Code editing loop with compile, lint, test, fix (editing delegates to [Aider](https://aider.chat/))
49-
- Compile error analyser can search online, add additional files and packages
50-
- Final review of the changes with an additional code editing loop if required.
51-
- Software Engineer Agent (For ticket to Pull Request workflow):
52-
- Find the appropriate repository from GitLab/GitHub
53-
- Clone and create branch
54-
- Call the Code Editing Agent
55-
- Create merge request
56-
- Code Review agent:
57-
- Configurable code review guidelines
58-
- Posts comments on GitLab merge requests at the appropriate line with suggested changes
59-
- Repository ad hoc query agent
60-
- Codebase awareness - optional index creation used by the task file selection agent
61-
62-
Full details at the [Software developer agents](https://sophia.dev/software-engineer/) docs.
63-
6437
## Flexible run/deploy options
6538

6639
- Run from the repository or the provided Dockerfile in single user mode.

docs/docs/software-engineer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AI Coding Agents
22

3-
The Sophia software/coding agents build upon the project [Aider](https://aider.chat/), providing additional layers around it for more autonomous use cases.
3+
The Sophia software/coding agents build upon the project [Aider](https://aider.chat/), providing additional agents around it for quality and automation.
44

55
## Code Editing Agent
66

docs/mkdocs.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,20 @@ nav:
3939
- 'Setup': setup.md
4040
- 'CLI': cli.md
4141
- 'Environment variables': environment-variables.md
42-
- 'Observability': observability.md
43-
- Concepts:
44-
- functions.md
45-
- agent-concepts.md
42+
- 'Observability / Tracing': observability.md
43+
- 'LLMs': llms.md
4644
- Agents:
45+
- agent-concepts.md
4746
- autonomous-agents.md
4847
- software-engineer.md
4948
- code-review.md
50-
- chatbot.md
5149
- examples.md
52-
- integrations.md
53-
- chat.md
50+
- Function Calling:
51+
- functions.md
52+
- integrations.md
53+
- Chat:
54+
- chat.md
55+
- chatbot.md
5456
- roadmap.md
5557
- Blog:
5658
- blog/index.md

0 commit comments

Comments
 (0)