Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { AgentRegistry } from './render-registry';

export class ActiveAgentObject extends AgentObject {
// arguments
agentJson: AgentObject;
config: AgentObjectData;
appContextValue: AppContextValue;
registry: AgentRegistry;
Expand Down Expand Up @@ -75,6 +76,7 @@ export class ActiveAgentObject extends AgentObject {
//

this.config = config;
this.agentJson = new AgentObject(config);
this.appContextValue = appContextValue;
this.registry = registry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { loadMessagesFromDatabase } from '../util/loadMessagesFromDatabase';

export class ConversationObject extends EventTarget {
agent: ActiveAgentObject; // the current agent
currentAgentPlayer: Player; // the current agent's player
agentsMap: Map<string, Player>; // note: agents does not include the current agent
scene: SceneObject | null;
getHash: GetHashFn; // XXX this can be a string, since conversation hashes do not change (?)
Expand Down Expand Up @@ -46,6 +47,11 @@ export class ConversationObject extends EventTarget {
this.scene = scene;
this.getHash = getHash;
this.mentionsRegex = mentionsRegex;
this.currentAgentPlayer = new Player(agent.id, {
id: agent.id,
name: agent.agentJson.name,
bio: agent.agentJson.bio,
});
this.messageCache = new MessageCacheConstructor({
loader: async () => {
const supabase = this.agent.appContextValue.useSupabase();
Expand Down Expand Up @@ -97,6 +103,21 @@ export class ConversationObject extends EventTarget {
getAgent() {
return this.agent;
}

setCurrentAgentPlayer(player: Player) {
this.currentAgentPlayer = player;
}

getCurrentAgentPlayer() {
return this.currentAgentPlayer;
}

appendCurrentAgentSpecs(agentSpec: object) {
this.currentAgentPlayer.setPlayerSpec({
...this.currentAgentPlayer.getPlayerSpec(),
...agentSpec,
});
}
// setAgent(agent: ActiveAgentObject) {
// this.agent = agent;
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,23 @@ const ScenePrompt = () => {
};
const CharactersPrompt = () => {
const conversation = useConversation();
const agent = useAgent();
const name = useName();
const bio = usePersonality();
if (conversation) {
const agents = conversation.getAgents();
const currentAgentSpec = {
id: agent.id,
name,
bio,
};
const currentAgentPlayerSpec = conversation.getCurrentAgentPlayer().getPlayerSpec();
const agentSpecs = agents.map((agent) => {
const agentSpec = agent.getPlayerSpec() as any;
return {
name: agentSpec?.name,
const agentSpecs = agent.getPlayerSpec() as any;
const agentSpec = {
id: agent.playerId,
bio: agentSpec?.bio,
};
name: agentSpecs?.name,
bio: agentSpecs?.bio,
}
return agentSpec;
});

const formatAgent = (agent: any) => {
return [
`Name: ${agent.name}`,
`UserId: ${agent.id}`,
`Name: ${agent.name}`,
`Bio: ${agent.bio}`,
].join('\n');
};
Expand All @@ -150,7 +144,7 @@ const CharactersPrompt = () => {
# Your Character
` +
'\n\n' +
formatAgent(currentAgentSpec) +
formatAgent(currentAgentPlayerSpec) +
(agents.length > 0
? (
'\n\n' +
Expand Down