Skip to content

Commit

Permalink
sanitize bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aembryonic committed Dec 4, 2024
1 parent 7f615e8 commit 4066e91
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core_server/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@
OPENAI_MAIN_MODEL=(str, "gpt-4o"),
OPENAI_SMALL_MODEL=(str, "gpt-4o-mini"),
BEDROCK_MAIN_MODEL=(str, "anthropic.claude-3-5-sonnet-20240620-v1:0"),
BEDROCK_SMALL_MODEL=(str, "anthropic.claude-3-5-haiku-20241022-v1:0"),
BEDROCK_SMALL_MODEL=(str, "us.amazon.nova-micro-v1:0")
)
4 changes: 2 additions & 2 deletions nlp_scripts/model_prediction/llm/model_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dataclasses import make_dataclass, field, dataclass
from pydantic import BaseModel, Field, create_model
from concurrent.futures import ThreadPoolExecutor
from langchain_aws import ChatBedrock
from langchain_aws import ChatBedrock, ChatBedrockConverse
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableParallel
from langchain_openai import ChatOpenAI
Expand Down Expand Up @@ -283,7 +283,7 @@ def __predict_entry(self, excerpt: str):

def select_model_instance(model_name: str):

if self.model_family == "bedrock": model = ChatBedrock(model_id=model_name, temperature=0)
if self.model_family == "bedrock": model = ChatBedrockConverse(model_id=model_name, temperature=0)
elif self.model_family == "openai": model = ChatOpenAI(model=model_name, temperature=0)

return model
Expand Down
1 change: 1 addition & 0 deletions nlp_scripts/model_prediction/llm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def manage_description(name, description):
def _sanitize_keys_with_uniqueness(key, max_length: int = 64):

sanitized = re.sub(r'[^a-zA-Z0-9_-]', '_', key)
sanitized = re.sub(r'^_+', '', sanitized) # pydantic model keys can't start with _
sanitized = sanitized[:max_length]

return sanitized
Expand Down

0 comments on commit 4066e91

Please sign in to comment.