คุณ เคยใช้กับการเข้าถึง GPT-4 API แต่ OpenAI ยุ่งเกินไปที่จะตอบกลับ ? ฉันด้วยนั่นคือเหตุผลที่ฉันสร้างแพ็คเกจนี้ มันใช้ Selenium WebDriver เพื่อเลียนแบบการโต้ตอบของผู้ใช้ใน chat.openai.com หากบัญชีมี ChatGPT Plus
ไดรเวอร์ จะใช้ GPT-4 มิฉะนั้นจะใช้ GPT-3.5 เริ่มต้น
รองรับทั้ง เบราว์เซอร์ GPT4, Dall-E 3 และปลั๊กอิน โดยเลือกรุ่นผ่าน GPT4OpenAI(token=token, model='gpt-4')
หรือ model='gpt-4-plugins'
หมายเหตุ: ห้องสมุด API ที่ไม่เป็นทางการนี้ไม่ได้รับการรับรองจาก OpenAI และละเมิดข้อกำหนดในการให้บริการ ใช้มันด้วยความเสี่ยงของคุณเอง ผู้สร้างจะไม่รับผิดชอบต่อผลใด ๆ โปรดปฏิบัติตาม TOS ของแพลตฟอร์มและการออกกำลังกายด้วยความระมัดระวังด้วยทรัพยากรที่ไม่เป็นทางการ
ตรรกะหลักถูกนำมาจาก Intelligenzaartificiale/Free-Auto-GPT
from gpt4_openai import GPT4OpenAI
# Token is the __Secure-next-auth.session-token from chat.openai.com
llm = GPT4OpenAI ( token = my_session_token , headless = False , model = 'gpt-4' )
# GPT3.5 will answer 8, while GPT4 should be smart enough to answer 10
response = llm ( 'If there are 10 books in a room and I read 2, how many books are still in the room?' )
print ( response )
รหัสนี้ใช้สำหรับการสาธิต GIF ด้านบน
from gpt4_openai import GPT4OpenAI
llm = GPT4OpenAI ( token = my_session_token , headless = False ,
model = 'gpt-4' # DALL-E 3 only works with gpt-4
)
img_bytes = llm . generate_image ( 'Generate an isometric image of a cute doggo inside a house.' , image_path = './img_save_path.png' )
from gpt4_openai import GPT4OpenAI
# Token is the __Secure-next-auth.session-token from chat.openai.com
llm = GPT4OpenAI ( token = my_session_token , headless = False , model = 'gpt-4-browsing' )
# ChatGPT will first browse the web for the name/age of her boyfriend, then return the answer
response = llm ( 'What is the age difference between Dua Lipa and her boyfriend?' )
print ( response )
GPT4OpenAI
จะขยายคลาส LLM
จาก langchain.llms.base
ดังนั้นคุณสามารถใช้ห้องสมุดนี้ภายในระบบนิเวศ Langchain ได้อย่างง่ายดาย ตัวอย่าง:
from gpt4_openai import GPT4OpenAI
from langchain import LLMChain
from langchain . prompts . chat import ( ChatPromptTemplate , SystemMessagePromptTemplate , AIMessagePromptTemplate , HumanMessagePromptTemplate )
template = "You are a helpful assistant that translates english to pirate."
system_message_prompt = SystemMessagePromptTemplate . from_template ( template )
example_human = HumanMessagePromptTemplate . from_template ( "Hi" )
example_ai = AIMessagePromptTemplate . from_template ( "Argh me mateys" )
human_message_prompt = HumanMessagePromptTemplate . from_template ( "{text}" )
chat_prompt = ChatPromptTemplate . from_messages ([ system_message_prompt , example_human , example_ai , human_message_prompt ])
# Token is the __Secure-next-auth.session-token from chat.openai.com
llm = GPT4OpenAI ( token = my_session_token )
chain = LLMChain ( llm = llm , prompt = chat_prompt )
print ( chain . run ( "My name is John and I like to eat pizza." ))
เอาต์พุตจะเป็น:
AI: Ahoy, me name be John an' I be likin' ta feast on some pizza, arr!
F12
__Secure-next-auth.session-token
ใน Application
> Storage
> Cookies
> https://chat.openai.com
Cookie Value
เริ่มแรกฉันลอง POE.com (API ส่วนตัวที่ใช้งานที่ GPT4Free) แต่สังเกตเห็นว่าหน้าต่างบริบทอินพุตมีขนาดเล็กกว่า OpenAI ChatGPT และเช่นเดียวกันกับ GPT4 ของ Bing
ในการติดตั้งแพ็คเกจ Python นี้เรียกใช้คำสั่งต่อไปนี้:
pip install gpt4-openai-api
การพึ่งพาเหล่านี้ได้รับการดาวน์โหลดโดยตรง:
undetected-chromedriver
(เบราว์เซอร์ซีลีเนียม)markdownify
langchain