退烧了。看来GPT-4还没有那么聪明

121次阅读

最近尝试了一些用 GPT- 4 当杠杆来做复杂的事情的尝试。主要包括 (三)个想法:

这周刚好 GPT-4 API 的 waitlist 排到了,就写了个脚本验证了一下这些想法,结论是暂时还不能用很简单的指令让 GPT- 4 很好地实现上面的所有想法。但是其中一些很简单的指令是可以实现的,比如让 GPT- 4 自己写 python 脚本去拿系统时间,然后自己解析并且给出结果。

但是更复杂的指令就无法用简单的指导来让它自己完成。不过如果构造更复杂的指导语,还是有可能能实现一部分功能的。

这里是我写的脚本:

https://github.com/wx2486/gpt/blob/main/chat_loop.py

这里是一些演示:(又看了一遍才发现列文件名的尝试其实第一次就成功了,只是我只看了最下面两行代码,以为它要把文件内容输出来,所以取消了好几次。。。

PS C:\Users\xiang\source\repos\Life\ 专项 \GPT> python .\chat_loop.py

Session ID 452b9da4-1d7d-403d-b52c-d778250b3ec4

————————————————————————————————————————————————————

User: hi

————————————————————————————————————————————————————

GPT-4: Hello! I understand the instructions. Please feel free to ask any questions or request assistance. I am here to help you.

————————————————————————————————————————————————————

User: what time is it

————————————————————————————————————————————————————

GPT-4: As an AI text-based model, I don't have real-time capabilities. However, you can get the current time using a Python script:

>>>GPT-4>>>Python>>>Script>>>

from datetime import datetime

now = datetime.now()

current_time = now.strftime("%H:%M:%S")

print(current_time)

<<<GPT-4<<<Python<<<Script<<<

————————————————————————————————————————————————————

Running untrusted code: from datetime import datetime

now = datetime.now()

current_time = now.strftime("%H:%M:%S")

print(current_time)

Do you want to run this code? (Y/n)

————————————————————————————————————————————————————

result: 18:51:40

————————————————————————————————————————————————————

GPT-4: The current time is 18:51:40.

————————————————————————————————————————————————————

User: what is the current date and time

————————————————————————————————————————————————————

GPT-4: As I cannot directly access the current date and time, I'll provide you with a Python script to get the current date and time:

>>>GPT-4>>>Python>>>Script>>>

from datetime import datetime

current_date_time = datetime.now()

print(current_date_time)

<<<GPT-4<<<Python<<<Script<<<

————————————————————————————————————————————————————

Running untrusted code: from datetime import datetime

current_date_time = datetime.now()

print(current_date_time)

Do you want to run this code? (Y/n)

————————————————————————————————————————————————————

result: 2023-04-02 18:51:58.856771

————————————————————————————————————————————————————

GPT-4: The current date and time is 2023-04-02 18:51:58.856771.

————————————————————————————————————————————————————

User: what are the files in the current folder

————————————————————————————————————————————————————

GPT-4: I cannot directly access your local file system, but I can provide you with a Python script that can list the files in the current folder for you. Here's the script:

>>>GPT-4>>>Python>>>Script>>>

import os

current_folder = os.getcwd()

files_in_folder = os.listdir(current_folder)

for file in files_in_folder:

print(file)

<<<GPT-4<<<Python<<<Script<<<

You can run this script in your local Python environment to see the files in the current folder.

————————————————————————————————————————————————————

Running untrusted code: import os

current_folder = os.getcwd()

files_in_folder = os.listdir(current_folder)

for file in files_in_folder:

print(file)

Do you want to run this code? (Y/n) n

————————————————————————————————————————————————————

result: We got exception while running this script you provided:

import os

current_folder = os.getcwd()

files_in_folder = os.listdir(current_folder)

for file in files_in_folder:

print(file)

Traceback (most recent call last):

File "C:\Users\xiang\source\repos\Life\ 专项 \GPT\chat_loop.py", line 83, in run_untrusted_code

raise Exception("User refused to run untrusted code.")

Exception: User refused to run untrusted code.

————————————————————————————————————————————————————

GPT-4: I apologize for the inconvenience. It seems that the script cannot be executed by you. In that case, please follow the steps below to check the files in the current folder manually:

1. Open a command prompt (Windows) or terminal (macOS/Linux).

2. Type `cd` followed by the path of the folder you want to explore, and press Enter. For example: `cd C:\Users\Username\Documents` (Windows) or `cd /Users/Username/Documents` (macOS/Linux). Replace 'Username' and 'Documents' with the relevant folder and user names.

3. Type `dir` (Windows) or `ls` (macOS/Linux) and press Enter. This command will list all the files and directories present in the current folder.

Please follow these steps to check the files in your current folder manually.

————————————————————————————————————————————————————

User: what are the names of the files in the current folder

————————————————————————————————————————————————————

GPT-4: As I cannot access your filesystem directly, I will provide you with a python script that you can run to list the names of the files in the current folder. Here's the script:

import os

current_directory = os.getcwd()

files = os.listdir(current_directory)

for file in files:

print(file)

————————————————————————————————————————————————————

User: what are the names of the files in the current folder

————————————————————————————————————————————————————

GPT-4: I cannot directly access the files in your current folder, but I can provide you with a Python script that you can run to display the names of the files in your current folder.

Here is the Python script:

“`python

import os

current_directory = os.getcwd()

file_names = os.listdir(current_directory)

for file_name in file_names:

print(file_name)

“`

Copy and paste this code into your Python environment or a script file, and run it to see the names of the files in your current folder.

————————————————————————————————————————————————————

User: what are the names of the files in the current folder

————————————————————————————————————————————————————

GPT-4: I cannot access your computer's filesystem directly, but I can provide you with a Python script that you can run on your own system to list all the files in the current directory:

>>>GPT-4>>>Python>>>Script>>>

import os

current_files = os.listdir()

for file in current_files:

print(file)

<<<GPT-4<<<Python<<<Script<<<

Copy and paste the script into a Python interpreter or save it as a file and run it to see the names of the files in the current folder.

————————————————————————————————————————————————————

Running untrusted code: import os

current_files = os.listdir()

for file in current_files:

print(file)

Do you want to run this code? (Y/n) n

————————————————————————————————————————————————————

result: We got exception while running this script you provided:

import os

current_files = os.listdir()

for file in current_files:

print(file)

Traceback (most recent call last):

File "C:\Users\xiang\source\repos\Life\ 专项 \GPT\chat_loop.py", line 83, in run_untrusted_code

raise Exception("User refused to run untrusted code.")

Exception: User refused to run untrusted code.

————————————————————————————————————————————————————

GPT-4: My apologies, but I'm not able to run this script on my end since I'm a language model without the ability to run code. Although, you can run the script provided on your local machine if you want to retrieve the names of the files in your current folder:

“`python

import os

current_files = os.listdir()

for file in current_files:

print(file)

“`

Please run this script on your machine to get the desired result.

————————————————————————————————————————————————————

User: list the files in the current folder

————————————————————————————————————————————————————

GPT-4: To list the files in the current folder, I need to provide you with a Python script that you can run. Here's the script:

>>>GPT-4>>>Python>>>Script>>>

import os

current_directory = os.getcwd()

list_of_files = os.listdir(current_directory)

print(list_of_files)

<<<GPT-4<<<Python<<<Script<<<

————————————————————————————————————————————————————

Running untrusted code: import os

current_directory = os.getcwd()

list_of_files = os.listdir(current_directory)

print(list_of_files)

Do you want to run this code? (Y/n)

————————————————————————————————————————————————————

result: ['ChatGPT Plus', 'chat_loop.py', 'GPT-4 team', 'models']

————————————————————————————————————————————————————

GPT-4: The files and directories in the current folder are:

1. ChatGPT Plus

2. chat_loop.py

3. GPT-4 team

4. models

————————————————————————————————————————————————————

User: search for a brief history of 2023 on the Internet

————————————————————————————————————————————————————

GPT-4: As I cannot directly access the internet, I will provide you with a Python script that you can run to retrieve information about the history of 2023 from the internet. You will need to have the Beautiful Soup and requests libraries installed for this script to work.

>>>GPT-4>>>Python>>>Script>>>

“`python

import requests

from bs4 import BeautifulSoup

def get_history(year: int):

url = f"https://www.onthisday.com/years/{year}"

response = requests.get(url)

soup = BeautifulSoup(response.content, "html.parser")

events = []

for event in soup.findAll("li", class_="event"):

date = event.find("span", class_="date").text.strip()

description = event.find("span", class_="description").text.strip()

events.append(f"{date}: {description}")

return events

history = get_history(2023)

for event in history:

print(event)

“`

<<<GPT-4<<<Python<<<Script<<<

You can run this script to retrieve events from the year 2023. If you provide me with the results, I can help you further.

————————————————————————————————————————————————————

Running untrusted code:

import requests

from bs4 import BeautifulSoup

def get_history(year: int):

url = f"https://www.onthisday.com/years/{year}"

response = requests.get(url)

soup = BeautifulSoup(response.content, "html.parser")

events = []

for event in soup.findAll("li", class_="event"):

date = event.find("span", class_="date").text.strip()

description = event.find("span", class_="description").text.strip()

events.append(f"{date}: {description}")

return events

history = get_history(2023)

for event in history:

print(event)

Do you want to run this code? (Y/n)

————————————————————————————————————————————————————

result: We got exception while running this script you provided:

import requests

from bs4 import BeautifulSoup

def get_history(year: int):

url = f"https://www.onthisday.com/years/{year}"

response = requests.get(url)

soup = BeautifulSoup(response.content, "html.parser")

events = []

for event in soup.findAll("li", class_="event"):

date = event.find("span", class_="date").text.strip()

description = event.find("span", class_="description").text.strip()

events.append(f"{date}: {description}")

return events

history = get_history(2023)

for event in history:

print(event)

Traceback (most recent call last):

File "C:\Users\xiang\source\repos\Life\ 专项 \GPT\chat_loop.py", line 89, in run_untrusted_code

exec(code_string)

File "<string>", line 19, in <module>

File "<string>", line 7, in get_history

NameError: name 'requests' is not defined

————————————————————————————————————————————————————

GPT-4: It seems like there was an exception while running the provided script because the `requests` module is not installed in your environment. I cannot provide you with the information through this method. As an alternative, you can manually search for a brief history of 2023 on the internet using search engines like Google or Bing. Please let me know if you need any other assistance.

————————————————————————————————————————————————————

User: Traceback (most recent call last):

File "C:\Users\xiang\source\repos\Life\ 专项 \GPT\chat_loop.py", line 99, in <module>

loop()

File "C:\Users\xiang\source\repos\Life\ 专项 \GPT\chat_loop.py", line 32, in loop

goal = input("User: ")

^^^^^^^^^^^^^^^

KeyboardInterrupt

PS C:\Users\xiang\source\repos\Life\ 专项 \GPT>

原文链接:https://www.bilibili.com/read/cv22806176/

正文完
 
不知道
版权声明:本站原创文章,由 不知道 2023-08-04发表,共计14392字。
转载说明:声明:本站内容均来自互联网,归原创作者所有,如有侵权必删除。 本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。