Skip to content

Commit

Permalink
chore(backend): update examples and docs
Browse files Browse the repository at this point in the history
Ref: #298
Signed-off-by: Tomas Dvorak <[email protected]>
  • Loading branch information
Tomas2D committed Feb 11, 2025
1 parent 06bf1e4 commit fcbe7d5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
13 changes: 7 additions & 6 deletions docs/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
- Non-Chat LLM class (`LLM`) has been removed.
- The`IBMvLLM` adapter has been removed.
- Parsers were moved from `bee-agent-framework/agents/parsers` to `bee-agent-framework/parsers`
- Parsers were moved from `bee-agent-framework/agents/parsers` to `bee-agent-framework/parsers`.

### Models

#### Before
#### ❌ Old Way

```ts
import { OllamaChatLLM } from "bee-agent-framework/adapters/ollama/chat";
Expand All @@ -38,7 +39,7 @@ const response = await model.generate(
console.log(response.getTextContent());
```

#### Now
#### ✅ New Way

```ts
import { ChatModel, UserMessage } from "bee-agent-framework/backend/core";
Expand Down Expand Up @@ -69,14 +70,14 @@ More examples can be found in [Backend Documentation Page](/docs/backend.md).

The `BaseMessage` class was replaced by `Message` and its subtypes (`UserMessage`, `AssistantMessage`, `SystemMessage`, `ToolMessage`).

#### Before
#### ❌ Old Way

```ts
import { BaseMessage } from "bee-agent-framework/llms/primitives/message";
const a = BaseMessage.of({ role: "user", text: "hello", meta: { createdAt: new Date() } });
```

#### Now
#### ✅ New Way

```ts
import { Message } from "bee-agent-framework/backend/core";
Expand Down Expand Up @@ -131,7 +132,7 @@ The same applies to the following static methods.
- `fromSerialized`
- `fromSnapshot`

#### Before
#### ❌ Old Way

```ts
import { TokenMemory } from "bee-agent-framework/memory/tokenMemory";
Expand All @@ -142,7 +143,7 @@ const json = a.serialize();
const b = TokenMemory.fromSerialized(json);
```

#### Now
#### ✅ New Way

```ts
import { TokenMemory } from "bee-agent-framework/memory/tokenMemory";
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
[
"adapters",
"agents",
"llms",
"backend",
"tools",
"cache",
"emitter",
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/google-vertex/backend/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class GoogleVertexClient extends BackendClient<
...this.settings,
project: this.settings?.project || getEnv("GOOGLE_VERTEX_PROJECT"),
baseURL: this.settings?.baseURL || getEnv("GOOGLE_VERTEX_ENDPOINT"),
location: this.settings?.baseURL || getEnv("GOOGLE_VERTEX_LOCATION"),
location: this.settings?.location || getEnv("GOOGLE_VERTEX_LOCATION"),
});
}
}
4 changes: 2 additions & 2 deletions src/backend/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ export abstract class ChatModel extends Serializable {
}

static async fromName(name: FullModelName | ProviderName, options?: ChatModelParameters) {
const { providerId, modelId = "" } = parseModel(name);
const { providerId, modelId } = parseModel(name);
const Target = await loadModel<ChatModel>(providerId, "chat");
return new Target(modelId, options);
return new Target(modelId || undefined, options);
}

protected abstract _create(
Expand Down
14 changes: 7 additions & 7 deletions tests/examples/examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ const exclude: string[] = [
"examples/playground/**/*.ts",
// prevents 'Too many requests' error on Free Tier
!getEnv("WATSONX_API_KEY") && [
"examples/llms/providers/watson*.ts",
"examples/backend/providers/watson*.ts",
"examples/agents/experimental/replan.ts",
"examples/agents/experimental/streamlit.ts",
"examples/agents/granite/*.ts",
"examples/agents/granite/single_turn.ts",
],
!getEnv("GROQ_API_KEY") && [
"examples/agents/sql.ts",
"examples/llms/providers/groq.ts",
"examples/backend/providers/groq.ts",
"examples/workflows/*",
],
!getEnv("OPENAI_API_KEY") && [
"examples/agents/bee_reusable.ts",
"examples/llms/providers/openai.ts",
"examples/backend/providers/openai.ts",
],
!getEnv("AZURE_OPENAI_API_KEY") && ["examples/llms/providers/azure_openai.ts"],
!getEnv("COHERE_API_KEY") && ["examples/llms/providers/langchain.ts"],
!getEnv("AZURE_OPENAI_API_KEY") && ["examples/backend/providers/azure-openai.ts"],
!getEnv("COHERE_API_KEY") && ["examples/backend/providers/langchain.ts"],
!getEnv("CODE_INTERPRETER_URL") && ["examples/tools/custom/python.ts"],
!getEnv("ELASTICSEARCH_NODE") && ["examples/agents/elasticsearch.ts"],
!getEnv("AWS_REGION") && ["examples/llms/providers/bedrock.ts"],
!getEnv("GOOGLE_APPLICATION_CREDENTIALS") && ["examples/llms/providers/vertexai.ts"],
!getEnv("AWS_REGION") && ["examples/backend/providers/amazon-bedrock.ts"],
!getEnv("GOOGLE_APPLICATION_CREDENTIALS") && ["examples/backend/providers/vertexai.ts"],
]
.filter(isTruthy)
.flat(); // list of examples that are excluded
Expand Down

0 comments on commit fcbe7d5

Please sign in to comment.