This repository contains examples of using the LangChain library with OpenAI's API to create various natural language processing prompts. The examples demonstrate how to set up and invoke different types of prompts using the LangChain and OpenAI integration.
prompt1.py: Explains basic concepts in software engineering in a simple way.prompt2.py: Translates sentences into a specified target language.prompt3.py: Finds antonyms of given words using few-shot learning.
- Clone this repository.
- Install Python and the necessary libraries:
pip install langchain_openai - Set the OpenAI API key as an environment variable:
export OPENAI_API_KEY='your_api_key_here'
Execute the scripts with Python, for example:
python prompt1.py
prompt1.py: Uses aPromptTemplatewithLLMChainto generate explanations on software engineering topics.prompt2.py: Uses aPromptTemplatefor sentence translation, leveragingLLMChain.prompt3.py: EmploysFewShotPromptTemplatewithLLMChainto generate antonyms based on examples.
Contributions are welcome. Please fork the repository and submit pull requests.