Spaces:
Running
Running
vlff李飞飞
commited on
Commit
•
caaf00f
1
Parent(s):
513e437
update oai
Browse files- browser_qwen/background_副本.js +59 -0
- run_server.py +12 -12
browser_qwen/background_副本.js
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var database;
|
2 |
+
|
3 |
+
function send_data(msg){
|
4 |
+
chrome.storage.local.get(['database_host'], function(result) {
|
5 |
+
if (result.database_host) {
|
6 |
+
console.log('database_host currently is ' + result.database_host);
|
7 |
+
database = "http://"+result.database_host+":7866/endpoint";
|
8 |
+
} else {
|
9 |
+
database = "http://127.0.0.1:7866/endpoint";
|
10 |
+
}
|
11 |
+
fetch(database, {
|
12 |
+
method: "POST",
|
13 |
+
headers: {
|
14 |
+
"Content-Type": "application/json",
|
15 |
+
},
|
16 |
+
body: JSON.stringify(msg),
|
17 |
+
})
|
18 |
+
.then((response) => response.json())
|
19 |
+
.then((data) => {
|
20 |
+
console.log(data.result);
|
21 |
+
});
|
22 |
+
});
|
23 |
+
}
|
24 |
+
|
25 |
+
chrome.runtime.onMessage.addListener(async (msg, sender) => {
|
26 |
+
if (msg.flag == "open_tab_and_cache_from_content"){
|
27 |
+
var url = "";
|
28 |
+
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
|
29 |
+
url = tabs[0].url;
|
30 |
+
console.log(url);
|
31 |
+
if (msg.data) {
|
32 |
+
chrome.storage.sync.get(['data'], function(result) {
|
33 |
+
chrome.storage.sync.set({ data: result.data }, function() {
|
34 |
+
send_data({ 'content' : msg.data, 'query': '', 'url':url, 'task':'cache', 'type':msg.type});
|
35 |
+
});
|
36 |
+
});
|
37 |
+
}
|
38 |
+
});
|
39 |
+
}
|
40 |
+
if (msg.flag == "open_popup_and_send_url_from_popup"){
|
41 |
+
if (msg.data) {
|
42 |
+
chrome.storage.sync.get(['data'], function(result) {
|
43 |
+
chrome.storage.sync.set({ data: result.data }, function() {
|
44 |
+
send_data({ 'url' : msg.data, 'task':'pop_url'});
|
45 |
+
});
|
46 |
+
});
|
47 |
+
}
|
48 |
+
}
|
49 |
+
// if (msg.flag == "set_addr"){
|
50 |
+
// if (msg.data) {
|
51 |
+
// chrome.storage.sync.get(['data'], function(result) {
|
52 |
+
// chrome.storage.sync.set({ data: result.data }, function() {
|
53 |
+
// send_data({ 'addr' : msg.data, 'task':'set_addr'});
|
54 |
+
// });
|
55 |
+
// });
|
56 |
+
// }
|
57 |
+
// }
|
58 |
+
});
|
59 |
+
Add to Qwen's Reading List
|
run_server.py
CHANGED
@@ -12,7 +12,7 @@ from qwen_agent.utils.utils import get_local_ip
|
|
12 |
from qwen_server.schema import GlobalConfig
|
13 |
os.environ["TRANSFORMERS_CACHE"] = ".cache/huggingface/"
|
14 |
os.environ["HF_HOME"] = ".cache/huggingface/"
|
15 |
-
os.environ["MPLCONFIGDIR"] = ".cache/
|
16 |
|
17 |
def parse_args():
|
18 |
parser = argparse.ArgumentParser()
|
@@ -117,17 +117,17 @@ def main():
|
|
117 |
sys.executable,
|
118 |
os.path.join(os.getcwd(), 'qwen_server/database_server.py')
|
119 |
]),
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
def signal_handler(_sig, _frame):
|
133 |
for v in servers.values():
|
|
|
12 |
from qwen_server.schema import GlobalConfig
|
13 |
os.environ["TRANSFORMERS_CACHE"] = ".cache/huggingface/"
|
14 |
os.environ["HF_HOME"] = ".cache/huggingface/"
|
15 |
+
os.environ["MPLCONFIGDIR"] = ".cache/huggingface/"
|
16 |
|
17 |
def parse_args():
|
18 |
parser = argparse.ArgumentParser()
|
|
|
117 |
sys.executable,
|
118 |
os.path.join(os.getcwd(), 'qwen_server/database_server.py')
|
119 |
]),
|
120 |
+
# 'workstation':
|
121 |
+
# subprocess.Popen([
|
122 |
+
# sys.executable,
|
123 |
+
# os.path.join(os.getcwd(), 'qwen_server/workstation_server.py')
|
124 |
+
# ]),
|
125 |
+
# 'assistant':
|
126 |
+
# subprocess.Popen([
|
127 |
+
# sys.executable,
|
128 |
+
# os.path.join(os.getcwd(), 'qwen_server/assistant_server.py')
|
129 |
+
# ]),
|
130 |
+
}
|
131 |
|
132 |
def signal_handler(_sig, _frame):
|
133 |
for v in servers.values():
|