Last active
July 6, 2024 16:00
-
-
Save elijahbenizzy/d9e1904e122e242460ac73d8639b511c 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 llm_client() -> openai.AsyncOpenAI: | |
return openai.AsyncOpenAI() | |
def joke_prompt(topic: str) -> str: | |
return ( | |
f"Tell me a short joke about {topic}" | |
) | |
def joke_messages( | |
joke_prompt: str) -> List[dict]: | |
return [{"role": "user", | |
"content": joke_prompt}] | |
async def joke_response( | |
llm_client: openai.AsyncOpenAI, | |
joke_messages: List[dict]) -> str: | |
response = await ( | |
llm_client.chat.completions.create( | |
model="gpt-3.5-turbo", | |
messages=joke_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