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