Skip to content

Commit

Permalink
Add python-dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
djpapzin committed Aug 14, 2024
1 parent ffe850e commit e33e0cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 5 additions & 6 deletions Projects/2. Large Language Models and LangChain/chat_models.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
from langchain.chat_models import ChatGemini # Import ChatGemini instead of ChatOpenAI
from langchain_google_genai import GoogleGenerativeAI # Import GoogleGenerativeAI from langchain_google_genai
from langchain.schema import ( # Import HumanMessage and SystemMessage from langchain.schema
HumanMessage,
SystemMessage
)
import getpass
from dotenv import load_dotenv # Import load_dotenv
import os

if "GEMINI_API_KEY" not in os.environ:
os.environ["GEMINI_API_KEY"] = getpass.getpass("Provide your GEMINI API Key")
load_dotenv() # Load environment variables from .env file

chat = ChatGemini(model_name="gemini-1.5-pro-exp-0801", temperature=0) # Create a ChatGemini object with the specified model name and temperature
llm = GoogleGenerativeAI(model="gemini-pro", google_api_key=os.getenv("GOOGLE_API_KEY")) # Create GoogleGenerativeAI instance

messages = [ # Create a list of messages
SystemMessage(content="You are a helpful assistant that translates English to French."), # Create a SystemMessage with the content "You are a helpful assistant that translates English to French."
HumanMessage(content="Translate the following sentence: I love programming.") # Create a HumanMessage with the content "Translate the following sentence: I love programming."
]

chat(messages) # Call the chat object with the list of messages
llm(messages) # Call the llm object with the list of messages
3 changes: 2 additions & 1 deletion Projects/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ streamlit==1.23.1
beautifulsoup4==4.11.2
audio-recorder-streamlit==0.0.8
streamlit-chat==0.0.2.2
langchain-google-genai
langchain-google-genai
python-dotenv

0 comments on commit e33e0cd

Please sign in to comment.