Skip to content

Commit cc3ea82

Browse files
committed
edit ai theme to be library
1 parent a99f66e commit cc3ea82

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

samples/agentic-strands/app/agent.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
from flask import Flask, request, jsonify, send_from_directory
44
import requests
55

6-
import json
76
import os
8-
import time
97
import dotenv
10-
from threading import Lock
118

129
dotenv.load_dotenv()
1310

1411
message = """
15-
You are an expert fashion stylist. Your goal is to help users find their personal style.
16-
Your task is to provide fashion advice and offer products based on the user's preferences.
17-
You can use the tools available to you to assist with this.
18-
Note that for any prompts you ask the user, make sure you actually explicitly state the question you are asking, and possible some sample answers so they know what to type.
19-
Keep the questions as simple as possible so the user doesn't have to type much. And don't ask more than 3 questions.
12+
You are a helpful library assistant.
13+
Your goal is to help users discover books available through the library's book API, based on the user's preferences.
14+
When a user makes a request, you should search the API and suggest books that match their query.
15+
16+
When interacting, ask the user clear questions to guide the search.
17+
Make sure to explicitly state the question you are asking,
18+
and provide simple sample answers so the user knows what to type.
19+
Keep it to a maximum of 3 simple questions.
2020
"""
2121

2222
app = Flask(__name__)
23-
latest_response = {"message": "Hello! I'm your fashion stylist assistant. How can I help you with your style today?"}
23+
latest_response = {"message": "Hello! I'm your library assistant. How can I help you with your reading today?"}
2424

2525
model = OpenAIModel(
2626
client_args={
@@ -63,12 +63,12 @@ def message_buffer_handler(**kwargs):
6363
print(f"Error in message_buffer_handler: {str(e)}")
6464

6565
@tool
66-
def search_for_fashion_books(query, filters=None) -> str:
66+
def search_for_books(query, filters=None) -> str:
6767
"""
68-
Search for detailed information about fashion books using the Open Library API.
68+
Search for detailed information about books using the Open Library API.
6969
7070
Args:
71-
query: The search term to look up fashion-related books.
71+
query: The search term to look up books.
7272
7373
Returns:
7474
A string summarizing the list of matching books, or a message if none are found.
@@ -81,7 +81,6 @@ def search_for_fashion_books(query, filters=None) -> str:
8181
headers = {}
8282
params = {
8383
"q": clean_query,
84-
"subject": "fashion",
8584
"page": 1,
8685
"limit": 10
8786
}
@@ -91,9 +90,9 @@ def search_for_fashion_books(query, filters=None) -> str:
9190
if response.ok:
9291
book_list = response.json()
9392
if book_list.get("num_found", 0) == 0:
94-
return "No fashion books found"
93+
return "No books found matching your query."
9594

96-
message = "Here are the fashion books I found:"
95+
message = "Here are the books I found:"
9796
for book in book_list.get("docs", []):
9897
title = book.get("title")
9998
author = book.get("author_name", ["Unknown"])[0]
@@ -107,22 +106,22 @@ def search_for_fashion_books(query, filters=None) -> str:
107106
return f"Error: {str(e)}"
108107

109108
TOOL_SPEC = {
110-
"name": "search_for_fashion_books",
111-
"description": "Get detailed information about fashion books from Open Library, based on a search query.",
109+
"name": "search_for_books",
110+
"description": "Get detailed information about books from Open Library, based on a search query.",
112111
"inputSchema": {
113112
"type": "object",
114113
"properties": {
115114
"query": {
116115
"type": "string",
117-
"description": "Search query for fashion books",
116+
"description": "Search query for books",
118117
}
119118
},
120119
"required": ["query"],
121120
},
122121
}
123122

124123
agent = Agent(
125-
tools=[search_for_fashion_books],
124+
tools=[search_for_books],
126125
model=model,
127126
callback_handler=message_buffer_handler,
128127
system_prompt=message

samples/agentic-strands/app/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Fashion Stylist AI</title>
5+
<title>Library Assistant AI</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<style>
88
body { font-family: Arial, sans-serif; margin: 40px; background: #f9f9f9; }
@@ -61,13 +61,13 @@
6161
</head>
6262
<body>
6363
<div class="container">
64-
<h1>Fashion Stylist AI</h1>
65-
<p>Chat with our AI fashion stylist to get personalized style advice.</p>
66-
64+
<h1>Library Assistant AI</h1>
65+
<p>Chat with our AI Library Assistant to get personalized book recommendations.</p>
66+
6767
<div class="chat-container" id="chat-container">
6868
<!-- Messages will appear here -->
6969
<div class="message agent-message">
70-
Hello! I'm your fashion stylist assistant. How can I help you with your style today?
70+
Hello! I'm your library assistant. How can I help you with your reading today?
7171
</div>
7272
</div>
7373

0 commit comments

Comments
 (0)