Skip to content

Commit

Permalink
Remove url rewriting in fastify
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcampagnolitg committed Oct 8, 2024
1 parent 5c1f964 commit aad1877
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
12 changes: 6 additions & 6 deletions docs/docs/agent-concepts.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Agent concepts

## Agent types
## Agent categories

### 1. Autonomous agents

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

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

Function calls may be to API integrations or create sub-agents.

### 2. Workflow agents

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

An autonomous agent may start a workflow agent via a function call, and a workflow may start an autonomous agent.

## Agent context

The codebase makes use of `AsyncLocalStorage`, which is similar to `ThreadLocal` in Java and `threading.local()` in Python,
to provide easy lookup of agent state, current user, tool configuration, and default LLMs.

This does require the agent code to run within a context
This requires the agent code to run within a AsyncLocalStorage context.
```typescript
export const agentContextStorage = new AsyncLocalStorage<AgentContext>();

Expand Down
6 changes: 0 additions & 6 deletions src/fastify/fastifyApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ export type RouteDefinition = (fastify: TypeBoxFastifyInstance) => Promise<void>

export const fastifyInstance: TypeBoxFastifyInstance = fastify({
maxParamLength: 256,
rewriteUrl: (req) => {
if (req.url.startsWith(UI_PREFIX)) {
return UI_PREFIX;
}
return req.url;
},
}).withTypeProvider<TypeBoxTypeProvider>();

export interface FastifyConfig {
Expand Down
1 change: 1 addition & 0 deletions src/llm/base-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export abstract class BaseLLM implements LLM {
return true;
}

/** Model id form the Vercel AI package */
aiModel(): LanguageModel {
throw new Error('Unsupported implementation');
}
Expand Down
9 changes: 4 additions & 5 deletions src/routes/agent/agent-start-route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Type } from '@sinclair/typebox';
import { LlmFunctions } from '#agent/LlmFunctions';
import { AgentType } from '#agent/agentContextTypes';
import { AgentExecution, startAgent } from '#agent/agentRunner';
import { send } from '#fastify/index';
import { functionFactory } from '#functionSchema/functionDecorators';
import { getLLM } from '#llm/llmFactory';
import { logger } from '#o11y/logger';
import { AppFastifyInstance } from '../../app';
import { AgentExecution, startAgent } from '#agent/agentRunner';
import { currentUser } from '#user/userService/userContext';
import { functionFactory } from '#functionSchema/functionDecorators';
import {AgentType} from "#agent/agentContextTypes";

import { AppFastifyInstance } from '../../app';

const v1BasePath = '/api/agent/v1';

Expand Down

0 comments on commit aad1877

Please sign in to comment.