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'
통해 모델을 선택하여 GPT4 브라우저 및 플러그인을 지원합니다.
참고 : 이 비공식 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
실제로 langchain.llms.base
에서 LLM
클래스를 확장합니다. 따라서 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
로 개발자 도구를 엽니 다.Application
> Storage
> Cookies
> https://chat.openai.com
에서 __Secure-next-auth.session-token
쿠키를 찾으십시오.Cookie Value
필드에서 값을 복사하십시오. 처음에는 poe.com (GPT4Free에서 구현 된 개인 API)을 시도했지만 입력 컨텍스트 창이 OpenAI ChatGpt 중 하나보다 작음을 알았습니다. 그리고 Bing의 GPT4도 마찬가지입니다.
이 Python 패키지를 설치하려면 다음 명령을 실행하십시오.
pip install gpt4-openai-api
이러한 종속성은 직접 다운로드됩니다.
undetected-chromedriver
(셀레늄 브라우저)markdownify
langchain