Skip to content

Commit

Permalink
feat: modify ekoai
Browse files Browse the repository at this point in the history
  • Loading branch information
veasion committed Dec 20, 2024
1 parent 2dd3814 commit 2187f0e
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 10 deletions.
7 changes: 4 additions & 3 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["eko/extension.js", "js/content_script.js"],
"js": ["eko/extension_content_script.js", "js/content_script.js"],
"run_at": "document_idle"
}
],
"permissions": [
"alarms",
"tabs",
"windows",
"storage",
"scripting",
"activeTab",
"notifications",
"webRequest"
"notifications"
],
"host_permissions": [
"<all_urls>"
Expand Down
70 changes: 68 additions & 2 deletions src/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,68 @@
import { Eko } from "ekoai";
import { ExecutionContext } from "ekoai/types";
import { tools, utils } from "ekoai/extension";

let eko = new Eko("claude-3-5-sonnet-20241022");
let context = {
variables: new Map<string, unknown>(),
tools: [],
} as any as ExecutionContext;

async function testWebSearch() {
let eko = new Eko("claude-3-sonnet");
let result = await eko.testWebSearch("谢扬");
let webSearch = new tools.WebSearch();
let result = await webSearch.execute(context, { query: "谢扬" });
console.log("result: ", result);
return result;
}

async function testTabManagement(action: string) {
let tabManagement = new tools.TabManagement();
let result = await tabManagement.execute(context, { action });
console.log("result: ", action, result);
return result;
}

async function exportFile() {
let exportFile = new tools.ExportFile();
let result = await exportFile.execute(context, {
fileType: "csv",
content: "Name, Price\niPhone, $1000\nnotebook, $1.02",
});
console.log("result: ", result);
return result;
}

async function extractContent() {
let extract = new tools.ExtractContent();
let result = await extract.execute(context, {});
console.log("result: ", result);
return result;
}

async function openUrl(url: string, newWindow: boolean) {
let openUrl = new tools.OpenUrl();
let result = await openUrl.execute(context, { url, newWindow });
console.log("result: ", result);
return result;
}

async function screenshot() {
let screenshot = new tools.Screenshot();
let result = await screenshot.execute(context, {});
console.log("result: ", result);
return result;
}

async function computerWeb(
action: string,
coordinate?: [number, number],
text?: string
) {
let tabId = await utils.getCurrentTabId();
context.variables.set("tabId", tabId);
let pageSize = await utils.getPageSize(tabId);
let computer = new tools.ComputerWeb(pageSize);
let result = await computer.execute(context, { action, coordinate, text });
console.log("result: ", result);
return result;
}
Expand All @@ -14,5 +74,11 @@ chrome.runtime.onMessage.addListener(async function (
) {
if (request.type == "run") {
await testWebSearch();
// await testTabManagement("current_tab");
// await testTabManagement("tab_all");
// await exportFile();
// await extractContent();
// await openUrl('https://www.google.com', true);
// await screenshot();
}
});
6 changes: 3 additions & 3 deletions src/options/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const OptionsPage = () => {
};

const modelOptions = [
{ value: "claude-3-haiku", label: "Claude 3 Haiku" },
{ value: "claude-3-sonnet", label: "Claude 3 Sonnet (default)" },
{ value: "claude-3-opus", label: "Claude 3 Opus" },
{ value: "claude-3-5-haiku-20241022", label: "Claude 3.5 Haiku" },
{ value: "claude-3-5-sonnet-20241022", label: "Claude 3.5 Sonnet (default)" },
{ value: "claude-3-opus-20240229", label: "Claude 3 Opus" },
];

return (
Expand Down
4 changes: 2 additions & 2 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ module.exports = {
patterns: [
{ from: "public", to: "../" },
{
from: 'node_modules/ekoai/dist/extension.js',
to: "../eko/extension.js"
from: 'node_modules/ekoai/dist/extension_content_script.js',
to: "../eko/extension_content_script.js"
},
{
from: 'node_modules/ekoai/dist/extension/script',
Expand Down

0 comments on commit 2187f0e

Please sign in to comment.