Skip to content

Commit

Permalink
Update model.py
Browse files Browse the repository at this point in the history
  • Loading branch information
viveksilimkhan1 authored Oct 25, 2023
1 parent 04f9c03 commit 3bd7b0a
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions spacy_llm/models/bedrock/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import json
import warnings
from enum import Enum
from typing import Any, Dict, Iterable, Optional, Type, List, Sized, Tuple

from confection import SimpleFrozenDict

from ...registry import registry
from typing import Any, Dict, Iterable, Optional, List

class Models(str, Enum):
# Completion models
Expand All @@ -29,7 +25,7 @@ def __init__(

# @property
def get_session_kwargs(self) -> Dict[str, Optional[str]]:

# Fetch and check the credentials
profile = os.getenv("AWS_PROFILE") if not None else ""
secret_key_id = os.getenv("AWS_ACCESS_KEY_ID")
Expand Down Expand Up @@ -65,22 +61,20 @@ def get_session_kwargs(self) -> Dict[str, Optional[str]]:
session_kwargs = {"profile_name":profile, "region_name":self._region, "aws_access_key_id":secret_key_id, "aws_secret_access_key":secret_access_key, "aws_session_token":session_token}
return session_kwargs

def __call__(self, prompts: Iterable[str]) -> Iterable[str]:
def __call__(self, prompts: Iterable[str]) -> Iterable[str]:
api_responses: List[str] = []
prompts = list(prompts)

def _request(json_data: str) -> str:
try:
import boto3
import botocore
except ImportError as err:
print("To use Bedrock, you need to install boto3. Use `pip install boto3` ")
raise err
from botocore.config import Config
session_kwargs = self.get_session_kwargs()
session = boto3.Session(**session_kwargs)
api_config = Config(retries = dict(max_attempts = self._max_retries))
print("Session:", session)
bedrock = session.client(service_name="bedrock-runtime", config=api_config)
accept = "application/json"
contentType = "application/json"
Expand Down

0 comments on commit 3bd7b0a

Please sign in to comment.