You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(venv) PS C:\Users*****\GPT-Projects\FreeSideProjects\auto_job__find__chatgpt__rpa\auto_job_find> python write_response.py
OpenAI version is compatible.
Loaded existing assistant ID.
Loaded existing assistant ID.
DevTools listening on ws://127.0.0.1:50547/devtools/browser/a*****-d868-4ed7-9605-91d8c12b7873
[2120:13720:0105/091745.511:ERROR:device_event_log_impl.cc(192)] [09:17:45.503] USB: usb_service_win.cc:104 SetupDiGetDeviceProperty({{A*****-DF1C-4EFD-0-6E0}, 6}) failed: 找不到元素。 (0x490)
An error occurred: Message:
Stacktrace:
(No symbol) [0x00007FF*****]
(No symbol) [0x00007FF6*****]
(No symbol) [0x00007FF6*****]
(No symbol) [0x00007FF6A*****97C]
(No symbol) [0x00007FF6A*****7]
(No symbol) [0x00007FF6A5*****F]
(No symbol) [0x00007FF6A*****]
(No symbol) [0x00007FF6*****]
(No symbol) [0x00007FF*****]
(No symbol) [0x00007FF6A*****]
GetHandleVerifier [0x00007F*****B+3695259]
GetHandleVerifier [0x00007*****37+4057191]
GetHandleVerifier [0x0000*****5E4E3+4023827]
GetHandleVerifier [0x00007*****304F9+689705]
(No symbol) [0x0000*****048]
(No symbol) [0x00007F*****044]
(No symbol) [0x00007FF*****C9]
(No symbol) [0x000*****C4]
BaseThreadInitThunk [0x0*****+29]
RtlUserThreadStart [0x000*****58+40]
import json
import os
import time
from selenium.webdriver.support import expected_conditions as EC
import openai
from openai import OpenAI
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import functions
import finding_jobs
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
Check OpenAI version compatibility
from packaging import version
from dotenv import load_dotenv
load_dotenv()
required_version = version.parse("1.1.1")
current_version = version.parse(openai.version)
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
if current_version < required_version:
raise ValueError(
f"Error: OpenAI version {openai.version} is less than the required version 1.1.1"
)
else:
print("OpenAI version is compatible.")
Initialize OpenAI client
client = OpenAI(api_key=OPENAI_API_KEY)
Create or load assistant
assistant_id = functions.create_assistant(
client) # this function comes from "functions.py"
def create_thread(client):
# Function to create a new thread and return its ID
try:
response = client.beta.threads.create() # No assistant_id needed
thread_id = response.id
return thread_id
except Exception as e:
print(f"Error creating thread: {e}")
return None
def chat(user_input, assistant_id, thread_id=None):
if thread_id is None:
thread_id = create_thread(client)
if thread_id is None:
return json.dumps({"error": "Failed to create a new thread"})
print(f"Received message: {user_input} in thread {thread_id}")
# Run the Assistant
try:
# Add the user's message to the thread
client.beta.threads.messages.create(
thread_id=thread_id,
role="user",
content=user_input
)
# Start the Assistant Run
run = client.beta.threads.runs.create(
thread_id=thread_id,
assistant_id=assistant_id
)
# Check if the Run requires action (function call)
while True:
run_status = client.beta.threads.runs.retrieve(
thread_id=thread_id,
run_id=run.id
)
if run_status.status == 'completed':
break
elif run_status.status == 'requires_action':
# Here you can handle specific actions if your assistant requires them
# ...
time.sleep(1) # Wait for a second before checking again
# Retrieve and return the latest message from the assistant
messages = client.beta.threads.messages.list(thread_id=thread_id)
assistant_message = messages.data[0].content[0].text.value
# 将换行符替换为一个空格
formatted_message = assistant_message.replace("\n", " ")
# response_data = json.dumps({"response": assistant_message, "thread_id": thread_id})
return formatted_message
except Exception as e:
print(f"An error occurred: {e}")
error_response = json.dumps({"error": str(e)})
return error_response
具体描述:
运行write_response.py后,会弹出让我扫码Boss直聘的页面,然后扫码进入后就停留在
操作环境:Win11系统;网络环境:全局proxy。
报错讯息:
(venv) PS C:\Users*****\GPT-Projects\FreeSideProjects\auto_job__find__chatgpt__rpa\auto_job_find> python write_response.py
OpenAI version is compatible.
Loaded existing assistant ID.
Loaded existing assistant ID.
DevTools listening on ws://127.0.0.1:50547/devtools/browser/a*****-d868-4ed7-9605-91d8c12b7873
[2120:13720:0105/091745.511:ERROR:device_event_log_impl.cc(192)] [09:17:45.503] USB: usb_service_win.cc:104 SetupDiGetDeviceProperty({{A*****-DF1C-4EFD-0-6E0}, 6}) failed: 找不到元素。 (0x490)
An error occurred: Message:
Stacktrace:
之前也一直报"failed: 找不到元素。 (0x490)"这个错误,我咨询过GPT-4后,已经把write_response.py改成:
import json
import os
import time
from selenium.webdriver.support import expected_conditions as EC
import openai
from openai import OpenAI
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import functions
import finding_jobs
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
Check OpenAI version compatibility
from packaging import version
from dotenv import load_dotenv
load_dotenv()
required_version = version.parse("1.1.1")
current_version = version.parse(openai.version)
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
if current_version < required_version:
raise ValueError(
f"Error: OpenAI version {openai.version} is less than the required version 1.1.1"
)
else:
print("OpenAI version is compatible.")
Initialize OpenAI client
client = OpenAI(api_key=OPENAI_API_KEY)
Create or load assistant
assistant_id = functions.create_assistant(
client) # this function comes from "functions.py"
def create_thread(client):
# Function to create a new thread and return its ID
try:
response = client.beta.threads.create() # No assistant_id needed
thread_id = response.id
return thread_id
except Exception as e:
print(f"Error creating thread: {e}")
return None
def open_browser_with_options(url, browser_type):
# 假设这是您原始代码中的函数,用于初始化 WebDriver
def chat(user_input, assistant_id, thread_id=None):
if thread_id is None:
thread_id = create_thread(client)
if thread_id is None:
return json.dumps({"error": "Failed to create a new thread"})
def send_response_to_chat_box(driver, response):
# 定位聊天输入框
chat_box = driver.find_element(By.XPATH, "//*[@id='chat-input']")
def send_response_and_go_back(driver, response):
# 调用函数发送响应
send_response_to_chat_box(driver, response)
def send_job_descriptions_to_chat(assistant_id, url, browser_type, label):
# 开始浏览并获取工作描述
finding_jobs.open_browser_with_options(url, browser_type)
finding_jobs.log_in()
if name == 'main':
assistant_id = functions.create_assistant(client)
url = "https://www.zhipin.com/web/geek/job-recommend?ka=header-job-recommend"
browser_type = "chrome"
label = "AI产品经理" # 想要选择的下拉菜单项
send_job_descriptions_to_chat(assistant_id, url, browser_type,label)
如何解决,还望告知。谢谢。
The text was updated successfully, but these errors were encountered: