llm/bedrock.py aktualisiert
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import boto3
|
import boto3
|
||||||
import json
|
|
||||||
|
|
||||||
from config import AWS_REGION, BEDROCK_MODEL
|
from config import AWS_REGION, BEDROCK_MODEL
|
||||||
|
|
||||||
@@ -7,26 +6,20 @@ from config import AWS_REGION, BEDROCK_MODEL
|
|||||||
class BedrockClient:
|
class BedrockClient:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.client = boto3.client(
|
self.client = boto3.client(
|
||||||
service_name="bedrock-runtime",
|
"bedrock-runtime",
|
||||||
region_name=AWS_REGION
|
region_name=AWS_REGION
|
||||||
)
|
)
|
||||||
|
|
||||||
async def chat(self, messages, tools=None):
|
async def chat(self, messages, tools=None):
|
||||||
"""
|
|
||||||
Converse API für Amazon Nova / Bedrock Models
|
|
||||||
"""
|
|
||||||
|
|
||||||
request = {
|
request = {
|
||||||
"modelId": BEDROCK_MODEL,
|
"modelId": BEDROCK_MODEL,
|
||||||
"messages": messages,
|
"messages": messages,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tools nur hinzufügen wenn vorhanden
|
|
||||||
if tools:
|
if tools:
|
||||||
request["toolConfig"] = {
|
request["toolConfig"] = {
|
||||||
"tools": tools
|
"tools": tools
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.converse(**request)
|
return self.client.converse(**request)
|
||||||
|
|
||||||
return response
|
|
||||||
Reference in New Issue
Block a user