-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
7 additions
and
67 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
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(); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1 @@ | ||
declare const eko: any; | ||
|
||
eko.sub('test', async function (params: any) { | ||
console.log('============= test =========', params); | ||
return 'test:ok'; | ||
}) |
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