Skip to content

Commit fdd2c7f

Browse files
Add ClothingRecommenderBot and PythonRunnerBot examples to README (#106)
* Add the PythonRunnerBot and ClothingRecommenderBot to README * Fix linting flake8 linting * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix flake8 errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Specify the absolute path to pyproject.toml * bump pycln to 2.4.0 to solve issues with finding pyproject.toml * clean up pre-commit-config --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 952fac7 commit fdd2c7f

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
args: [--py37-plus]
88

99
- repo: https://github.com/hadialqattan/pycln
10-
rev: v2.4.0
10+
rev: v2.5.0
1111
hooks:
1212
- id: pycln
1313
args: [--config=pyproject.toml]

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,23 @@ A correct implementation would look like https://poe.com/AllCapsBotDemo
138138
[here](https://creator.poe.com/docs/server-bots-functional-guides#updating-bot-settings).
139139

140140
A correct implementation would look like https://poe.com/TurboVsClaudeBotDemo
141+
142+
### ClothingRecommenderBot
143+
144+
- An example bot that takes in a user-uploaded image, analyzes it with Claude-3.5-Sonnet
145+
to recommend a new top, and then generates an image of the new clothing with Imagen-3
146+
to return to the user.
147+
- This is a good starting point for handling user-uploaded attachments, and also
148+
returning attachments with your bot.
149+
- To deploy, run `modal deploy new_top_recommender.py`
150+
151+
A correct implementation would look like https://poe.com/TopRecommender
152+
153+
### PythonRunnerBot
154+
155+
- An example bot that generates code based on the user query, runs it with the @Python
156+
bot, and attempts to debug it if there's any issue.
157+
- This is a good starting point for chaining requests to various text models.
158+
- To deploy, run `modal deploy python_runner.py`
159+
160+
A correct implementation would look like https://poe.com/PythonCodeRunner

new_top_recommender.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ async def get_response(
113113
is_inline=True,
114114
)
115115
yield fp.PartialResponse(
116-
text=f"\n\nHere's an image of the recommended top![new_top][{attachment_response.inline_ref}]"
116+
text=(
117+
"\n\nHere's an image of the recommended top![new_top]["
118+
f"{attachment_response.inline_ref}]"
119+
)
117120
)
118121

119122
async def get_settings(self, setting: fp.SettingsRequest) -> fp.SettingsResponse:

python_runner.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ async def get_response(
4747
# Let’s define a prompt that instructs Claude to produce Python code:
4848
gen_code_prompt = (
4949
"You are a helpful coding assistant. The user wants some Python code. "
50-
"Please provide only the Python code (no markdown fences) needed to accomplish the following request:\n\n"
50+
"Please provide only the Python code (no markdown fences) needed to "
51+
"accomplish the following request:\n\n"
5152
f"{user_message}\n\n"
52-
"Do not include any comments or other text in the code. Do not offer to explain the code."
53+
"Do not include any comments or other text in the code. Do not offer to "
54+
"explain the code."
5355
)
5456

5557
# Wrap the code in triple backticks for nice formatting
@@ -65,7 +67,8 @@ async def get_response(
6567
yield fp.PartialResponse(text=msg.text)
6668
yield fp.PartialResponse(text="\n```")
6769

68-
# Clean up code snippet by removing triple backticks in case Claude ignored the instructions.
70+
# Clean up code snippet by removing triple backticks
71+
# This is incase Claude ignored the instructions.
6972
code_snippet = re.sub(r"```+", "", code_snippet).strip()
7073

7174
# -------------
@@ -87,15 +90,18 @@ async def get_response(
8790
# -------------
8891
if has_error:
8992
yield fp.PartialResponse(
90-
text=f"\nWe got an error when running the code. Asking Claude-3.5-Sonnet to debug...\n"
93+
text="\nWe got an error when running the code. Asking "
94+
"Claude-3.5-Sonnet to debug...\n"
9195
)
9296

9397
debug_prompt = (
9498
"The following Python code produced an error. "
9599
f"Original code:\n{code_snippet}\n\n"
96100
f"Error:\n{python_result}\n\n"
97-
"Please provide only the Python code (no markdown fences) needed to fix the error."
98-
"Do not include any comments or other text in the code. Do not offer to explain the code."
101+
"Please provide only the Python code (no markdown fences) needed to "
102+
"fix the error."
103+
" Do not include any comments or other text in the code. "
104+
"Do not offer to explain the code."
99105
)
100106
debug_code_snippet = ""
101107
yield fp.PartialResponse(text="```python\n")
@@ -148,8 +154,9 @@ async def get_response(
148154
"But we got an error. So we debugged it and ran the following code:\n"
149155
f"{debug_code_snippet}\n\n"
150156
"The output of the code was:\n"
151-
f"{python_debug_result}"
152-
"Please summarize the output of the code, and whether it fulfilled the original request."
157+
f"{python_debug_result}\n\n"
158+
"Please summarize the output of the code, and whether it fulfilled the "
159+
"original request."
153160
)
154161

155162
async for msg in fp.stream_request(
@@ -175,8 +182,9 @@ async def get_response(
175182
"The code that was generated and run was:\n"
176183
f"{code_snippet}\n\n"
177184
"The output of the code was:\n"
178-
f"{python_result}"
179-
"Please summarize the output of the code, and whether it fulfilled the original request."
185+
f"{python_result}\n\n"
186+
"Please summarize the output of the code, and whether it fulfilled the "
187+
"original request."
180188
)
181189

182190
async for msg in fp.stream_request(

0 commit comments

Comments
 (0)