-
-
Save Winston-503/f72e571a67ae1e0461120d6db76e3b35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ask_chatgpt(input_text: str) -> str: | |
""" Call OpenAI's gpt-3.5-turbo model API with prompt by 'generate_prompt()' function """ | |
openai.api_key = os.getenv('OPENAI_API_KEY') | |
prompt = generate_prompt(input_text) | |
messages = [{"role": "user", "content": prompt}] | |
response = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=messages | |
) | |
return response.choices[0].message["content"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment