Home

Awesome

<a id="banner"></a>

<p align="center"> <img src="https://public.trafficguard.ai/sophia/banner.png" alt="nous logo"/> </p> <p align="center"> <em>The open-source TypeScript platform for autonomous AI agents and LLM based workflows </em> </p> The Ancient Greek word <em><b>sophía (σοφία)</b></em> is the abstract noun of σοφός (sophós), which variously translates to "clever, skillful, intelligent, wise"

Documentation site

Home | Setup | Observability | Function calling | Autonomous AI Agent | AI Software Engineer | AI Code reviews | Tools/Integrations | Roadmap


The Sophia Story | Features | UI Examples | Code examples | Contributing

The Sophia Story

Sophia 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:

At TrafficGuard we process billions of events a month for our global clients, increasing their ad spend ROI 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.

With open source projects typically Python/GitHub focused, and the vendor AI tools being focused in their silos, we saw a need for TypeScript based tooling which can work across our entire tech stack, and understand the overall architecture.

Through its evolution we've designed sophia as a flexible platform for the TypeScript community to expand and support the use cases and integrations of your choice.

Our design choice of Firestore for the initial database implementation, with Cloud Run, provides a scale-to-zero solution with zero-cost using the free tier. With the intention to support uses cases such as your own custom personal assistant, always available via mobile.

Features

Key features include:

UI Examples

New Agent | Sample trace | Human in the loop notification | Agent requested feedback | List agents | Code review config

New Agent

New Agent UI

Sample trace

Sample trace in Google Cloud

Human in the loop notification

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

Agent requested feedback

Feedback requested

List agents

List agents

Code review configuration

Code review configuration

Code Examples

Sophia vs LangChain

Sophia doesn't use LangChain, for many reasons that you can read online

Let's compare the LangChain document example for Multiple Chains to the equivalent Sophia implementation.

LangChain

import { PromptTemplate } from "@langchain/core/prompts";
import { RunnableSequence } from "@langchain/core/runnables";
import { StringOutputParser } from "@langchain/core/output_parsers";
import { ChatAnthropic } from "@langchain/anthropic";

const prompt1 = PromptTemplate.fromTemplate(
  `What is the city {person} is from? Only respond with the name of the city.`
);
const prompt2 = PromptTemplate.fromTemplate(
  `What country is the city {city} in? Respond in {language}.`
);

const model = new ChatAnthropic({});

const chain = prompt1.pipe(model).pipe(new StringOutputParser());

const combinedChain = RunnableSequence.from([
  {
    city: chain,
    language: (input) => input.language,
  },
  prompt2,
  model,
  new StringOutputParser(),
]);

const result = await combinedChain.invoke({
  person: "Obama",
  language: "German",
});

console.log(result);

Sophia

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}.`;

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

  console.log(result);
});

The Sophia 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:

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 schemas are automatically generated by having the @func decorator on class methods.

New Agent UI

Getting Started

Visit our documentation site for the getting started guide and more details.

Contributing

We warmly welcome contributions to the project through issues, pull requests or discussions

Contributed by TrafficGuard - 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.