Skip to content

Commit

Permalink
ollama merged, handling direct client in new setup
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Nov 7, 2024
1 parent c1a1c1f commit 5764572
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start:service:all": "pnpm --dir packages/agent start:service:all --isRoot",
"stop:service:all": "pnpm --dir packages/agent stop:service:all --isRoot",
"start": "pnpm --dir packages/agent start --isRoot",
"dev": "concurrently \"pnpm --dir packages/core dev\" \"sleep 3 && pnpm --dir packages/agent dev\"",
"dev": "bash ./scripts/dev.sh",
"lint": "pnpm --dir packages/core lint && pnpm --dir packages/agent lint",
"prettier-check": "npx prettier --check .",
"prettier": "npx prettier --write .",
Expand Down
4 changes: 3 additions & 1 deletion packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,17 @@ const rl = readline.createInterface({
});

async function handleUserInput(input) {
console.log("input --> ", input)
if (input.toLowerCase() === "exit") {
rl.close();
return;
}

const agentId = characters[0].name.toLowerCase();
console.log("agnetId --> ", agentId)
try {
const response = await fetch(
`http://localhost:3000/${agentId}/message`,
`http://localhost:${serverPort}/${agentId}/message`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ export function loadCharacters(charactersArg: string): Character[] {
?.split(",")
.map((path) => path.trim())
.map((path) => {
if (path.startsWith("./characters")) {
return `.${path}`;
if (path.startsWith("../characters")) {
return `../${path}`;
}
if (path.startsWith("characters")) {
return `../${path}`;
return `../../${path}`;
}
if (path.startsWith("./characters")) {
return `../.${path}`;
}
return path;
});
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/clients/direct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class DirectClient {
private agents: Map<string, AgentRuntime>;

constructor() {
console.log("DirectClient constructor")
this.app = express();
this.app.use(cors());
this.agents = new Map();
Expand Down Expand Up @@ -121,6 +122,7 @@ class DirectClient {
this.app.post(
"/:agentId/message",
async (req: express.Request, res: express.Response) => {
console.log("DirectClient message")
const agentId = req.params.agentId;
const roomId = stringToUuid(
req.body.roomId ?? "default-room-" + agentId
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/clients/discord/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ function splitMessage(content: string): string[] {
}

function canSendMessage(channel) {
console.log("canSendMessage", channel);
// if it is a DM channel, we can always send messages
if (channel.type === ChannelType.DM) {
return {
Expand Down Expand Up @@ -444,8 +443,6 @@ export class MessageManager {
context
);

console.log("Response content:", responseContent);

responseContent.text = responseContent.text?.trim();
responseContent.inReplyTo = stringToUuid(
message.id + "-" + this.runtime.agentId
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/core/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,6 @@ export class AgentRuntime implements IAgentRuntime {

elizaLogger.success(`Normalized action: ${normalizedAction}`);

console.log("Actions are: ", this.actions);

let action = this.actions.find(
(a: { name: string }) =>
a.name
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/services/llama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class LlamaService implements ILlamaService {
presence_penalty: number,
max_tokens: number
): Promise<any> {
console.log("queueMessageCompletion", context, temperature, stop, frequency_penalty, presence_penalty, max_tokens);
return this.delegate.queueMessageCompletion(
context, temperature, stop, frequency_penalty, presence_penalty, max_tokens
);
Expand Down
4 changes: 4 additions & 0 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
echo "Passing arguments: $*"
npx concurrently --raw \
"pnpm --dir packages/core dev -- $*" \
"node -e \"setTimeout(() => process.exit(0), 5000)\" && pnpm --dir packages/agent dev -- $*"

0 comments on commit 5764572

Please sign in to comment.