Skip to content
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

bedrock langchain #199

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions aws/bedrock1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


from dotenv import load_dotenv
load_dotenv()

Expand Down
27 changes: 27 additions & 0 deletions aws/langchain-bedrock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'''
(titan) gyliu@Guangyas-MacBook-Air .aws % cat credentials
[bedrock-admin]
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=

(titan) gyliu@Guangyas-MacBook-Air .aws % pwd
/Users/gyliu/.aws
'''

from dotenv import load_dotenv
load_dotenv()

from traceloop.sdk import Traceloop
from traceloop.sdk.decorators import task, workflow

Traceloop.init(app_name="joke_generation_service")

from langchain_aws import BedrockLLM

llm = BedrockLLM(
credentials_profile_name="bedrock-admin",
model_id="amazon.titan-text-express-v1",
region_name="us-west-2",
)

print(llm.invoke(input="What is the recipe of mayonnaise?"))
32 changes: 32 additions & 0 deletions haystack/hay-chat-bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from dotenv import load_dotenv
load_dotenv()

from haystack.telemetry import tutorial_running

tutorial_running(40)
'''
from haystack.dataclasses import ChatMessage
from haystack.components.generators.chat import OpenAIChatGenerator

messages = [
ChatMessage.from_system("Always respond in German even if some input data is in other languages."),
ChatMessage.from_user("What's Natural Language Processing? Be brief."),
]

chat_generator = OpenAIChatGenerator(model="gpt-3.5-turbo")
chat_generator.run(messages=messages)
'''
'''
from haystack.dataclasses import ChatMessage
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.components.generators.utils import print_streaming_chunk

messages = [
ChatMessage.from_system("Always respond in German even if some input data is in other languages."),
ChatMessage.from_user("What's Natural Language Processing? Be brief."),
]

chat_generator = OpenAIChatGenerator(model="gpt-3.5-turbo", streaming_callback=print_streaming_chunk)
response = chat_generator.run(messages=messages)
print(response)
'''
Loading