묻고 답해요
158만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨초보자를 위한 ChatGPT API 활용법 - API 기본 문법부터 12가지 프로그램 제작 배포까지
ch2 기본 질문하기 실행하면 오류가 떠요
response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Tell me how to make a pizza"}])Output exceeds the size limit. Open the full output data in a text editor--------------------------------------------------------------------------- APIRemovedInV1 Traceback (most recent call last) Cell In[8], line 1 ----> 1 response = openai.ChatCompletion.create( 2 model="gpt-3.5-turbo", 3 messages=[{"role": "user", "content": "Tell me how to make a pizza"}]) File c:\workspace\inflearn_chatGPT-main\ch02\ch02_env\Lib\site-packages\openai\_utils\_proxy.py:22, in LazyProxy.__getattr__(self, attr) 21 def getattr(self, attr: str) -> object: ---> 22 return getattr(self.__get_proxied__(), attr) File c:\workspace\inflearn_chatGPT-main\ch02\ch02_env\Lib\site-packages\openai\_utils\_proxy.py:43, in LazyProxy.__get_proxied__(self) 41 def __get_proxied__(self) -> T: 42 if not self.should_cache: ---> 43 return self.__load__() 45 proxied = self.__proxied 46 if proxied is not None: File c:\workspace\inflearn_chatGPT-main\ch02\ch02_env\Lib\site-packages\openai\lib\_old_api.py:33, in APIRemovedInV1Proxy.__load__(self) 31 @override 32 def load(self) -> None: ---> 33 raise APIRemovedInV1(symbol=self._symbol) APIRemovedInV1:... Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28 A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
-
해결됨초보자를 위한 ChatGPT API 활용법 - API 기본 문법부터 12가지 프로그램 제작 배포까지
ch04에서 01_summerize_text_app.py 실행
유익한 내용으로 강의를 제공해주셔서 감사합니다. CH04에서01_summerize_text_app.py##### 기본 정보 불러오기 #### # Streamlit 패키지 추가 import streamlit as st # OpenAI 패키기 추가 import openai ##### 기능 구현 함수 ##### def askGpt(prompt): messages_prompt = [{"role": "system", "content": prompt}] response = openai.ChatCompletion.create(model='gpt-3.5-turbo', messages=messages_prompt) gptResponse = response["choices"][0]["message"]["content"] return gptResponse ##### 메인 함수 ##### def main(): st.set_page_config(page_title="요약 프로그램") # 사이드바 with st.sidebar: # Open AI API 키 입력받기 open_apikey = st.text_input(label='OPENAI API 키', placeholder='Enter Your API Key', value='',type='password') # 입력받은 API 키 표시 if open_apikey: openai.api_key = open_apikey st.markdown('---') st.header("📃요약 프로그램") st.markdown('---') text = st.text_area("요약 할 글을 입력하세요") if st.button("요약"): prompt = f''' **Instructions** : - You are an expert assistant that summarizes text into **Korean language**. - Your task is to summarize the **text** sentences in **Korean language**. - Your summaries should include the following : - Omit duplicate content, but increase the summary weight of duplicate content. - Summarize by emphasizing concepts and arguments rather than case evidence. - Summarize in 3 lines. - Use the format of a bullet point. -text : {text} ''' st.info(askGpt(prompt)) if __name__=="__main__": main() 실행하여도다음과 같은 에러가 나옵니다.2023-11-07 13:03:41.719 Uncaught app exceptionTraceback (most recent call last):File "C:\inflearn_chatGPT\ch04\venv\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 534, in runscriptexec(code, module.__dict__)File "C:\inflearn_chatGPT\ch04\01_summerize_text_app.py", line 45, in <module>main()File "C:\inflearn_chatGPT\ch04\01_summerize_text_app.py", line 42, in mainst.info(askGpt(prompt))File "C:\inflearn_chatGPT\ch04\01_summerize_text_app.py", line 10, in askGptresponse = openai.ChatCompletion.create(model='gpt-3.5-turbo', messages=messages_prompt)AttributeError: module 'openai' has no attribute 'ChatCompletion'구글링및 chatgpt한테 직접 물어보니가,pip install --upgrade openai를 해라고 했는데,그것을 하여도오류가 계속 나옵니다. 오류를 해결하였습니다.openai 패키지에서 ChatCompletion 함수가 없다는게 말이 안된다고 생각합니다.그래서 가상환경(ch02_env)에서 실행해봤더니,실행이 되었습니다. 가상환경 ch02_env에 설치된 openai의 버전은 0.28.1이고가상환경 ch04_env에 설치된 oepnai의 버전은 1.1.1입니다. 즉, 강의를 원활하게 수강하기 위해서0.28.1버전을 사용해야할것같습니다.