Skip to content

Commit

Permalink
chore: update with develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
swizzmagik committed Jan 15, 2025
1 parent 906dddf commit cb43a30
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 186 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/defaultCharacter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const defaultCharacter: Character = {
username: "eliza",
plugins: [],
clients: [],
modelProvider: ModelProviderName.ANTHROPIC,
modelProvider: ModelProviderName.LLAMALOCAL,
settings: {
secrets: {},
voice: {
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export function parseJSONObjectFromText(
jsonData = JSON.parse(objectMatch[0]);
} catch (e) {
console.error("Error parsing JSON:", e);
console.log("text", text);
return null;
}
}
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,22 @@ export interface IImageDescriptionService extends Service {
): Promise<{ title: string; description: string }>;
}

export interface ITranscriptionService extends Service {
transcribeAttachment(audioBuffer: ArrayBuffer): Promise<string | null>;
transcribeAttachmentLocally(
audioBuffer: ArrayBuffer
): Promise<string | null>;
transcribe(audioBuffer: ArrayBuffer): Promise<string | null>;
transcribeLocally(audioBuffer: ArrayBuffer): Promise<string | null>;
}

export interface IVideoService extends Service {
isVideoUrl(url: string): boolean;
fetchVideoInfo(url: string): Promise<Media>;
downloadVideo(videoInfo: Media): Promise<string>;
processVideo(url: string, runtime: IAgentRuntime): Promise<Media>;
}

export interface ITextGenerationService extends Service {
initializeModel(): Promise<void>;
queueMessageCompletion(
Expand Down Expand Up @@ -1404,6 +1420,8 @@ export interface ITeeLogService extends Service {

export enum ServiceType {
IMAGE_DESCRIPTION = "image_description",
TRANSCRIPTION = "transcription",
VIDEO = "video",
TEXT_GENERATION = "text_generation",
BROWSER = "browser",
SPEECH_GENERATION = "speech_generation",
Expand Down
7 changes: 0 additions & 7 deletions packages/core/src/uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ export function stringToUuid(target: string | number): UUID {
throw TypeError("Value must be string");
}

// Return early if string already matches UUID format
const uuidRegex =
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
if (uuidRegex.test(target)) {
return target as UUID;
}

const _uint8ToHex = (ubyte: number): string => {
const first = ubyte >> 4;
const second = ubyte - (first << 4);
Expand Down
13 changes: 9 additions & 4 deletions packages/plugin-node/src/services/transcription.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { createClient, DeepgramClient } from "@deepgram/sdk";
import {
elizaLogger,
IAgentRuntime,
ITranscriptionService,
Service,
ServiceType,
settings,
TranscriptionProvider,
} from "@elizaos/core";
import { Service, ServiceType } from "@elizaos/core";
import { exec } from "child_process";
import { File } from "formdata-node";
import fs from "fs";
Expand All @@ -15,7 +17,6 @@ import os from "os";
import path from "path";
import { fileURLToPath } from "url";
import { promisify } from "util";
import { createClient, DeepgramClient } from "@deepgram/sdk";

// const __dirname = path.dirname(new URL(import.meta.url).pathname); #compatibility issues with windows
const __filename = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -356,7 +357,9 @@ export class TranscriptionService
await this.saveDebugAudio(audioBuffer, "openai_input_original");

const arrayBuffer = new Uint8Array(audioBuffer).buffer;
const convertedBuffer = Buffer.from(await this.convertAudio(arrayBuffer)).buffer;
const convertedBuffer = Buffer.from(
await this.convertAudio(arrayBuffer)
).buffer;

await this.saveDebugAudio(
convertedBuffer,
Expand Down Expand Up @@ -409,7 +412,9 @@ export class TranscriptionService
await this.saveDebugAudio(audioBuffer, "local_input_original");

const arrayBuffer = new Uint8Array(audioBuffer).buffer;
const convertedBuffer = Buffer.from(await this.convertAudio(arrayBuffer)).buffer;
const convertedBuffer = Buffer.from(
await this.convertAudio(arrayBuffer)
).buffer;

await this.saveDebugAudio(convertedBuffer, "local_input_converted");

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-node/src/services/video.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
elizaLogger,
IAgentRuntime,
ITranscriptionService,
IVideoService,
Media,
Service,
ServiceType,
stringToUuid,
elizaLogger,
} from "@elizaos/core";
import ffmpeg from "fluent-ffmpeg";
import fs from "fs";
Expand Down
Loading

0 comments on commit cb43a30

Please sign in to comment.