mirror of
https://github.com/aljazceru/Tutorial-Codebase-Knowledge.git
synced 2025-12-18 15:04:20 +01:00
15 lines
473 B
Python
15 lines
473 B
Python
from openai import OpenAI
|
|
|
|
# Learn more about calling the LLM: https://the-pocket.github.io/PocketFlow/utility_function/llm.html
|
|
def call_llm(prompt):
|
|
client = OpenAI(api_key="YOUR_API_KEY_HERE")
|
|
r = client.chat.completions.create(
|
|
model="gpt-4o",
|
|
messages=[{"role": "user", "content": prompt}]
|
|
)
|
|
return r.choices[0].message.content
|
|
|
|
if __name__ == "__main__":
|
|
prompt = "What is the meaning of life?"
|
|
print(call_llm(prompt))
|