Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): enable strict null checks #1878

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/client-direct/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export class DirectClient {
});

const response = await generateMessageResponse({
// @ts-expect-error todo
runtime: runtime,
context,
modelClass: ModelClass.LARGE,
Expand Down Expand Up @@ -323,13 +324,14 @@ export class DirectClient {
res.status(404).send("Agent not found");
return;
}

// @ts-expect-error todo
const images = await generateImage({ ...req.body }, agent);
const imagesRes: { image: string; caption: string }[] = [];
if (images.data && images.data.length > 0) {
for (let i = 0; i < images.data.length; i++) {
const caption = await generateCaption(
{ imageUrl: images.data[i] },
// @ts-expect-error todo
agent
);
imagesRes.push({
Expand Down Expand Up @@ -520,6 +522,7 @@ export class DirectClient {
});

const response = await generateMessageResponse({
// @ts-expect-error todo
runtime: runtime,
context,
modelClass: ModelClass.LARGE,
Expand Down
4 changes: 4 additions & 0 deletions packages/client-discord/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ export class DiscordClient extends EventEmitter {

const messageContent = reaction.message.content;
const truncatedContent =
// @ts-expect-error todo
messageContent.length > 50
// @ts-expect-error todo
? messageContent.substring(0, 50) + "..."
: messageContent;

Expand All @@ -336,7 +338,9 @@ export class DiscordClient extends EventEmitter {
`${reaction.message.id}-${user.id}-${emoji}-removed-${this.runtime.agentId}`
);

// @ts-expect-error todo
const userName = reaction.message.author.username;
// @ts-expect-error todo
const name = reaction.message.author.displayName;

await this.runtime.ensureConnection(
Expand Down
1 change: 1 addition & 0 deletions packages/client-slack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class SlackClient extends EventEmitter {
this.character = runtime.character;

const token = runtime.getSetting("SLACK_BOT_TOKEN");
// @ts-expect-error todo
this.signingSecret = runtime.getSetting("SLACK_SIGNING_SECRET");

if (!token) throw new Error("SLACK_BOT_TOKEN is required");
Expand Down
1 change: 1 addition & 0 deletions packages/client-telegram/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const TelegramClientInterface: Client = {

const tg = new TelegramClient(
runtime,
// @ts-expect-error todo
runtime.getSetting("TELEGRAM_BOT_TOKEN")
);

Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,28 @@ export type EmbeddingConfig = {
};

export const getEmbeddingConfig = (): EmbeddingConfig => ({
// @ts-expect-error todo
dimensions:
settings.USE_OPENAI_EMBEDDING?.toLowerCase() === "true"
// @ts-expect-error todo
? getEmbeddingModelSettings(ModelProviderName.OPENAI).dimensions
: settings.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true"
// @ts-expect-error todo
? getEmbeddingModelSettings(ModelProviderName.OLLAMA).dimensions
: settings.USE_GAIANET_EMBEDDING?.toLowerCase() === "true"
// @ts-expect-error todo
? getEmbeddingModelSettings(ModelProviderName.GAIANET)
.dimensions
: 384, // BGE
model:
settings.USE_OPENAI_EMBEDDING?.toLowerCase() === "true"
// @ts-expect-error todo
? getEmbeddingModelSettings(ModelProviderName.OPENAI).name
: settings.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true"
// @ts-expect-error todo
? getEmbeddingModelSettings(ModelProviderName.OLLAMA).name
: settings.USE_GAIANET_EMBEDDING?.toLowerCase() === "true"
// @ts-expect-error todo
? getEmbeddingModelSettings(ModelProviderName.GAIANET).name
: "BGE-small-en-v1.5",
provider:
Expand Down Expand Up @@ -135,14 +142,17 @@ export function getEmbeddingZeroVector(): number[] {
let embeddingDimension = 384; // Default BGE dimension

if (settings.USE_OPENAI_EMBEDDING?.toLowerCase() === "true") {
// @ts-expect-error todo
embeddingDimension = getEmbeddingModelSettings(
ModelProviderName.OPENAI
).dimensions; // OpenAI dimension
} else if (settings.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true") {
// @ts-expect-error todo
embeddingDimension = getEmbeddingModelSettings(
ModelProviderName.OLLAMA
).dimensions; // Ollama mxbai-embed-large dimension
} else if (settings.USE_GAIANET_EMBEDDING?.toLowerCase() === "true") {
// @ts-expect-error todo
embeddingDimension = getEmbeddingModelSettings(
ModelProviderName.GAIANET
).dimensions; // GaiaNet dimension
Expand Down Expand Up @@ -224,6 +234,7 @@ export async function embed(runtime: IAgentRuntime, input: string) {
settings.SMALL_GAIANET_SERVER_URL ||
settings.MEDIUM_GAIANET_SERVER_URL ||
settings.LARGE_GAIANET_SERVER_URL,
// @ts-expect-error todo
apiKey: settings.GAIANET_API_KEY || runtime.token,
dimensions: config.dimensions,
});
Expand All @@ -247,6 +258,7 @@ export async function embed(runtime: IAgentRuntime, input: string) {
endpoint:
runtime.character.modelEndpointOverride ||
getEndpoint(runtime.character.modelProvider),
// @ts-expect-error todo
apiKey: runtime.token,
dimensions: config.dimensions,
});
Expand Down
Loading
Loading