Adresse d'accès à LangChain : https://learn.activeloop.ai/courses/langchain
Qu’est-ce que Colab ?
Avec Colaboratory (Colab en abrégé), vous pouvez écrire et exécuter du code Python dans le navigateur et :
- Aucune configuration requise
- Utilisation gratuite du GPU
- Partagez facilement
Que vous soyez étudiant , data scientist ou chercheur en IA , Colab peut vous aider à accomplir votre travail plus facilement.
Comment installer des modules sur Colab ?
# 例如安装openai
!pip install openai
Attention, pensez à apporter [!] lors de l'installation du module.
【1】Installer Langchain
!pip install langchain
【2】Installer openai
!pip install openai
Une fois l'environnement prêt, testez l'exécution du programme :
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))
Avis:
# Avant d'exécuter le code suivant, assurez-vous d'avoir
# votre clé OpenAI enregistrée dans la variable d'environnement « OPENAI_API_KEY ».
Si des variables d'environnement sont utilisées, exportez OPENAI_API_KEY="..."
mais:
llm = OpenAI(model="text-davinci-003", température=0,9)
résultat de l'opération :
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