-
Notifications
You must be signed in to change notification settings - Fork 4
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
3 changed files
with
59 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
|
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,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?")) |
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,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) | ||
''' |