Aan de slagGa gratis aan de slag

OpenAI models in LangChain!

OpenAI's GPT-series models are some of the highest performing LLMs around. They are available via OpenAI's API, which you can easily interact with using LangChain.

Normally, using OpenAI's models would require a personal API key used for billing the cost of the models. In this course, you do not need to create or provide an OpenAI API key. The "<OPENAI_API_TOKEN>" placeholder will send valid requests to the API. If you make large number of requests in a short period, you may encounter a RateLimitError. If you see this, please pause for a moment and try again.

The ChatOpenAI class has already been imported.

Deze oefening maakt deel uit van de cursus

Developing LLM Applications with LangChain

Cursus bekijken

Oefeninstructies

  • Define an OpenAI chat model using a LangChain class; leave the API key placeholder as it is.
  • Invoke the LLM you defined to respond to the prompt provided (feel free to experiment with other prompts here).

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Define the LLM
llm = ____(model="gpt-4o-mini", api_key="")

# Predict the words following the text in question
prompt = 'Three reasons for using LangChain for LLM application development.'
response = ____(prompt)

print(response.content)
Code bewerken en uitvoeren