Skip to content

Commit

Permalink
import ekoai
Browse files Browse the repository at this point in the history
  • Loading branch information
veasion committed Dec 18, 2024
1 parent 18eec6b commit 2dd3814
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 67 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"dependencies": {
"antd": "^5.22.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"test-eko-veasion": "^1.0.1"
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/chrome": "0.0.158",
Expand Down
56 changes: 4 additions & 52 deletions src/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,18 @@
import { Eko } from "test-eko-veasion";
import { baidu } from "./script";
import { Eko } from "ekoai";

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

async function testMessage() {
let window = await chrome.windows.create({
type: "normal",
state: "maximized",
url: null,
} as any as chrome.windows.CreateData);
let tab = await chrome.tabs.create({
url: "https://www.baidu.com",
windowId: window.id,
});
await new Promise((resolve: any) => setTimeout(() => resolve(), 2000));
let tabId = tab.id;
let result = await chrome.tabs.sendMessage(tabId as number, {
type: "eko:message",
event: "test",
params: 123456,
});
console.log("test result: ", result);
return result;
}

// function baidu(name: string) {
// let element: any = document.querySelector("#kw");
// element.value = "你好";
// alert("哈哈: " + name);
// }

async function testScript() {
let window = await chrome.windows.create({
type: "normal",
state: "maximized",
url: null,
} as any as chrome.windows.CreateData);
let tab = await chrome.tabs.create({
url: "https://www.baidu.com",
windowId: window.id,
});
await new Promise((resolve: any) => setTimeout(() => resolve(), 2000));
let tabId = tab.id;
let result = await chrome.scripting.executeScript({
target: { tabId: tabId as number },
func: baidu,
args: ["veasion"],
});
return result;
}

chrome.runtime.onMessage.addListener(async function (
request,
sender,
sendResponse
) {
if (request.type == "run") {
await testScript();
await testWebSearch();
}
});
6 changes: 0 additions & 6 deletions src/background/script.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/content/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
declare const eko: any;

eko.sub('test', async function (params: any) {
console.log('============= test =========', params);
return 'test:ok';
})
4 changes: 2 additions & 2 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ module.exports = {
patterns: [
{ from: "public", to: "../" },
{
from: 'node_modules/test-eko-veasion/dist/extension.js',
from: 'node_modules/ekoai/dist/extension.js',
to: "../eko/extension.js"
},
{
from: 'node_modules/test-eko-veasion/dist/extension/script',
from: 'node_modules/ekoai/dist/extension/script',
to: "../eko/script"
}
],
Expand Down

0 comments on commit 2dd3814

Please sign in to comment.