Spaces:
Sleeping
Sleeping
| import openai | |
| import backoff | |
| default_system_message = "You are a instruction-following bot and you give the user exactly what they want, in the format they want, and nothing else. You have set verbose=0." | |
| def get_chatgpt_answer(user_msg: str, system_msg: str=default_system_message, temp: float=0.2) -> str: | |
| completion = openai.ChatCompletion.create( | |
| model='gpt-3.5-turbo-0613', | |
| # model="gpt-3.5-turbo", | |
| messages=[ | |
| {"role": "system", "content": system_msg}, | |
| {"role": "user", "content": user_msg}, | |
| ], | |
| temperature=temp, | |
| ) | |
| result = completion['choices'][0]['message']['content'] | |
| return result | |
| def get_chatgpt_serious_answer(user_msg: str) -> str: | |
| completion = openai.ChatCompletion.create( | |
| # model='gpt-3.5-turbo-0613', | |
| model="gpt-3.5-turbo", | |
| messages=[ | |
| {"role": "system", "content": "You are a instruction-following bot and you give the user exactly what they want, in the format they want, and nothing else. You have set verbose=0."}, | |
| {"role": "user", "content": user_msg}, | |
| ], | |
| temperature=0.0, | |
| frequency_penalty=0.2, | |
| #n=3, | |
| #top_p=0.7, | |
| ) | |
| result = completion['choices'][0]['message']['content'] | |
| return result |