LangChain access address: https://learn.activeloop.ai/courses/langchain
What is Colab?
With Colaboratory (Colab for short), you can write and execute Python code in the browser and:
- No configuration required
- Free use of GPU
- Share easily
Whether you're a student , data scientist , or AI researcher , Colab can help you get your work done easier.
How to install modules on Colab?
# 例如安装openai
!pip install openai
Note, remember to bring [!] when installing the module.
【1】Install langchain
!pip install langchain
【2】Install openai
!pip install openai
After the environment is ready, test run the program:
from langchain.llms import OpenAI
API_KEY = "your Openai key"
# Before executing the following code, make sure to have
# your OpenAI key saved in the “OPENAI_API_KEY” environment variable.
llm = OpenAI(model="text-davinci-003", temperature=0.9,openai_api_key=API_KEY)
'''
export OPENAI_API_KEY="..."
'''
text = "Suggest a personalized workout routine for someone looking to improve cardiovascular endurance and prefers outdoor activities."
print(llm(text))
Notice:
# Before executing the following code, make sure to have
# your OpenAI key saved in the “OPENAI_API_KEY” environment variable.
If environment variables are used, export OPENAI_API_KEY="..."
but:
llm = OpenAI(model="text-davinci-003", temperature=0.9)
operation result:
1. Swimming - Swimming is an excellent low-impact exercise that is perfect for improving cardiovascular endurance. It can be done outdoors at a local lake, pool, or beach.
2. Running - Running is a great way to improve cardiovascular endurance, and it can be done outdoors in a variety of terrain, ranging from asphalt to trails to beach sand.
3. Biking - Biking can be done indoors on a stationary bike, or it can be done outdoors for a change of scenery. It is a great way to improve cardiovascular endurance, while also exploring your local area.
4. Hiking - Hiking is a great low-impact way to improve cardiovascular endurance, while also taking in the beauty of nature. Hikes can be done on trails or up mountains, depending on the individual's preference.
5. Kayaking - Kayaking is a great way to improve cardiovascular endurance while exploring lakes or rivers. It is an excellent full-body workout and it can be done outdoors with the group or solo.
6. Rowing - Rowing is a great way to improve aerobic endurance and it is often done outdoors on a lake or ocean. Rowing is a great full-body workout and it can be