Skip to content

Commit

Permalink
new app
Browse files Browse the repository at this point in the history
  • Loading branch information
gyliu513 committed Nov 5, 2024
1 parent 47b02bd commit 0a6e7fc
Show file tree
Hide file tree
Showing 5 changed files with 534 additions and 30 deletions.
2 changes: 2 additions & 0 deletions aws/bedrock1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from traceloop.sdk import Traceloop
from traceloop.sdk.decorators import task, workflow

Traceloop.init(app_name="bedrock_101_quickstart")

# Traceloop.init(app_name="joke_generation_service")
bedrock_runtime = boto3.client(service_name="bedrock-runtime", region_name="us-east-1")

Expand Down
7 changes: 4 additions & 3 deletions aws/react-bedrock3.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class ChatBot:
def __init__(self, system=""):
self.client = boto3.client(service_name="bedrock-runtime", region_name="us-west-2")
self.client = boto3.client(service_name="bedrock-runtime", region_name="us-east-1")
self.system = system
self.messages = []
def __call__(self, message):
Expand All @@ -45,7 +45,6 @@ def execute(self):

model_id = "anthropic.claude-v2"


try:
# Invoke the model with the request.
response = self.client.invoke_model(modelId=model_id, body=request)
Expand Down Expand Up @@ -150,7 +149,9 @@ def query(question, max_turns=3):
i += 1
result = bot(next_prompt)
# print(result)
actions = [action_re.match(a) for a in result.split('\n') if action_re.match(a)]
actions = None
if result != None:
actions = [action_re.match(a) for a in result.split('\n') if action_re.match(a)]
if actions:
# There is an action to run
action, action_input = actions[0].groups()
Expand Down
Loading

0 comments on commit 0a6e7fc

Please sign in to comment.