generated from IMMM-SFA/metarepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
496 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
|
||
from langchain_openai import AzureChatOpenAI | ||
from langchain_core.prompts import ChatPromptTemplate | ||
|
||
|
||
try: | ||
# This code will raise a NameError because 'my_variable' is not defined | ||
os.environ["AZURE_OPENAI_API_KEY"] | ||
except Error as e: | ||
# This block will execute if an Error occurs | ||
print(f"No AZURE_OPENAI_API_KEY environment variable was found: {e}") | ||
|
||
llm = AzureChatOpenAI( | ||
azure_deployment="gpt-4o", | ||
api_version="2024-02-01", | ||
temperature=0.7, | ||
max_tokens=250, | ||
timeout=None, | ||
max_retries=2, | ||
# other params... | ||
) | ||
|
||
prompt = ChatPromptTemplate.from_messages( | ||
[ | ||
( | ||
"system", | ||
"You are a friendly {language} expert performing a code review to provide helpful feedback to the programmer.", | ||
), | ||
("human", "{input}"), | ||
] | ||
) | ||
|
||
chain = prompt | llm | ||
chain.invoke( | ||
{ | ||
"language": "Python", | ||
"input": "Go through all the scripts in this repository and provide detailed feedback and suggestions on how to make the scripts easier to read, cleaner, and more reproducible.", | ||
} | ||
) | ||
|
||
print(chain) | ||
print(chain.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
langchain_openai==0.3.0 | ||
langchain_core==0.3.29 |
Oops, something went wrong.