Skip to content

Commit

Permalink
利用されていない変数を削除
Browse files Browse the repository at this point in the history
  • Loading branch information
mt-osho-san committed Nov 15, 2024
1 parent 9e68a22 commit 050b802
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/backend/lambda/diary_create/diary_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def lambda_handler(event, context):
content = body["content"]

# DynamoDB にアイテムを保存
diary_id = save_to_dynamodb(user_id, date, content)
save_to_dynamodb(user_id, date, content)

# Flower Lambda を呼び出して花の ID を取得
flower_id = invoke_flower_lambda(user_id, date, content)
Expand Down
34 changes: 14 additions & 20 deletions src/backend/lambda/flower_select/flower_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ def lambda_handler(event, context):

return {
"statusCode": 200,
"body": json.dumps({
"message": "Flower ID saved to DynamoDB.",
"flower_id": flower_id
}),
"body": json.dumps(
{"message": "Flower ID saved to DynamoDB.", "flower_id": flower_id}
),
"headers": {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
Expand Down Expand Up @@ -110,15 +109,13 @@ def save_to_dynamodb(user_id, date, flower_id):
}

update_expression = "set flower_id = :flower"
expression_attribute_values = {
':flower': flower_id
}
expression_attribute_values = {":flower": flower_id}

try:
response = table.update_item(
table.update_item(
Key=item,
UpdateExpression=update_expression,
ExpressionAttributeValues=expression_attribute_values
ExpressionAttributeValues=expression_attribute_values,
)

except Exception as e:
Expand Down Expand Up @@ -161,20 +158,17 @@ def select_flower_using_api(api_key, query):
Exception: API呼び出しが失敗またはエラーを返した場合。
"""
logger.info("select flower using api")
BASE_URL = 'https://api.dify.ai/v1'
BASE_URL = "https://api.dify.ai/v1"

headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
url = f'{BASE_URL}/chat-messages'
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
url = f"{BASE_URL}/chat-messages"

data = {
'query': query,
'inputs': {},
'response_mode': 'blocking',
'user': "user",
'auto_generate_name': True
"query": query,
"inputs": {},
"response_mode": "blocking",
"user": "user",
"auto_generate_name": True,
}
try:
response = requests.post(url, headers=headers, json=data)
Expand Down

0 comments on commit 050b802

Please sign in to comment.