generated from aws-ia/terraform-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
changed to explicit map reduce function #177
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9938b45
changed order of pages in side nav. changed the llm langchain map red…
arvindsoni80 b1a3462
changed the example text
arvindsoni80 2e9d69c
changed to use pre-built image from public ECR since the image severa…
arvindsoni80 1fe42b8
Update cdk/examples/generative_ai_service/web-app/pages/2_llm_langcha…
arvindsoni80 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,3 +75,5 @@ __pycache__/ | |
|
||
# Customized ENV files | ||
.env* | ||
.venv/ | ||
output.json |
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
71 changes: 71 additions & 0 deletions
71
cdk/examples/generative_ai_service/web-app/pages/1_text_generation.py
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,71 @@ | ||
import streamlit as st | ||
import requests | ||
import json | ||
import time | ||
import boto3 | ||
|
||
st.set_page_config( | ||
page_title="text generation", | ||
layout="wide", | ||
page_icon=":technologist:" | ||
) | ||
|
||
st.header("Generative AI Demo - Text Generation :books:") | ||
st.caption("Using FLAN-T5-XL model from Hugging Face") | ||
|
||
def get_parameter(name): | ||
ssm = boto3.client('ssm') | ||
param = ssm.get_parameter(Name=name,WithDecryption=True) | ||
return param['Parameter']['Value'] | ||
|
||
runtime = boto3.client("runtime.sagemaker") | ||
|
||
conversation = """Customers were very excited about the wireless charging feature, but the launch has not lived up to their expectations. The phones are not reliably charging and that is frustrating since it is such a fundamental aspect of any electronic device.""" | ||
|
||
with st.spinner("Retrieving configurations..."): | ||
all_configs_loaded = False | ||
|
||
while not all_configs_loaded: | ||
try: | ||
# Retrive SageMaker Endpoint name from Parameter Store | ||
sm_endpoint = get_parameter("txt2txt_sm_endpoint") | ||
all_configs_loaded = True | ||
except: | ||
time.sleep(5) | ||
|
||
endpoint_name = st.sidebar.text_input("SageMaker Endpoint Name:",sm_endpoint) | ||
|
||
context = st.text_area("Input Context:", conversation, height=300) | ||
|
||
query = st.text_area("Input Query:", "Are customers happy?") | ||
st.caption("e.g., write a summary") | ||
|
||
if st.button("Generate Response", key=query): | ||
if endpoint_name == "" or query == "": | ||
st.error("Please enter a valid endpoint name and prompt!") | ||
else: | ||
with st.spinner("Wait for it..."): | ||
try: | ||
prompt = f"{context}\n{query}" | ||
response = runtime.invoke_endpoint( | ||
EndpointName=endpoint_name, | ||
Body=prompt, | ||
ContentType="application/x-text", | ||
) | ||
response_body = json.loads(response["Body"].read().decode()) | ||
generated_text = response_body["generated_text"] | ||
st.write(generated_text) | ||
|
||
except requests.exceptions.ConnectionError as errc: | ||
st.error("Error Connecting:",errc) | ||
|
||
except requests.exceptions.HTTPError as errh: | ||
st.error("Http Error:",errh) | ||
|
||
except requests.exceptions.Timeout as errt: | ||
st.error("Timeout Error:",errt) | ||
|
||
except requests.exceptions.RequestException as err: | ||
st.error("OOps: Something Else",err) | ||
|
||
st.success("Done!") |
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
File renamed without changes.
File renamed without changes.
94 changes: 0 additions & 94 deletions
94
cdk/examples/generative_ai_service/web-app/pages/text_generation.py
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove lines 58-59 if no longer building image from source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to be a temp measure for re:Invent