forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/bino-dev' into bino
- Loading branch information
Showing
12 changed files
with
355 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { | ||
IAgentRuntime, | ||
State, | ||
ModelClass, | ||
composeContext, | ||
generateText, | ||
elizaLogger, | ||
} from "@elizaos/core"; | ||
|
||
import { | ||
locationExtractionTemplate, | ||
newsExtractionTemplate, | ||
} from "../template"; | ||
import { parseTagContent } from "./parsers"; | ||
|
||
const NUM_RECENT_MESSAGES = 7; | ||
|
||
export async function extractLocationQuestion( | ||
state: State, | ||
runtime: IAgentRuntime | ||
): Promise<string> { | ||
const locationExtractionContext = composeContext({ | ||
state: { | ||
...state, | ||
recentMessages: getLastMessages(state, NUM_RECENT_MESSAGES), | ||
}, | ||
template: | ||
// @ts-ignore | ||
runtime.character.templates?.locationExtractionTemplate || | ||
locationExtractionTemplate, | ||
}); | ||
const location = await generateText({ | ||
runtime, | ||
context: locationExtractionContext, | ||
modelClass: ModelClass.SMALL, | ||
}); | ||
|
||
const parsedLocation = parseTagContent(location, "extracted_location"); | ||
|
||
elizaLogger.log("Extracted location is: ", parsedLocation); | ||
|
||
return parsedLocation; | ||
} | ||
|
||
export async function extractNewsQuery( | ||
state: State, | ||
runtime: IAgentRuntime | ||
): Promise<string> { | ||
const newsExtractionContext = composeContext({ | ||
state: { | ||
...state, | ||
recentMessages: getLastMessages(state, NUM_RECENT_MESSAGES), | ||
}, | ||
template: | ||
// @ts-ignore | ||
runtime.character.templates?.newsExtractionTemplate || | ||
newsExtractionTemplate, | ||
}); | ||
const newsQuery = await generateText({ | ||
runtime, | ||
context: newsExtractionContext, | ||
modelClass: ModelClass.SMALL, | ||
}); | ||
|
||
const parsedNewsQuery = parseTagContent(newsQuery, "extracted_query"); | ||
|
||
elizaLogger.log("Extracted news query is: ", parsedNewsQuery); | ||
|
||
return parsedNewsQuery; | ||
} | ||
|
||
function getLastMessages(state: State, numMessages: number): string { | ||
return state.recentMessages.split("\n").slice(-numMessages, -1).join("\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.