You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Telegram电影推荐机器人响应异常求助:所有输入均返回错误提示

Telegram电影推荐机器人故障排查与修复

你的机器人所有输入都返回默认回复的问题,根源在handle_response函数的匹配逻辑:

你将用户输入转为全小写:

processed: str = text.lower()

但判断条件里用的是首字母大写的关键词(比如'Comedy'),全小写的字符串里不可能包含大写的关键词,导致所有匹配都失败。

修复后的handle_response函数

def handle_response(text: str):
    processed: str = text.lower()

    if 'comedy' in processed:
        return 'Super choice! Here are top 5 films: "Blazing Saddles"; "Airplane!"; "Monty Python and the Holy Grail"; "Animal House"; "Young Frankenstein"'

    if 'horror' in processed:
        return 'Wow! Love watching horrors? Here are some of Horror Movies from my collection: The Exorcist (1973); Halloween (1978); Paranormal Activity (2007); The Shining (1980); It Follows (2014)'

    if 'drama' in processed:
        return 'Nice choice! Here are some of Drama films I have: Citizen Kane (1941); The Godfather (1972); 12 Angry Men (1957); Casablanca (1942); Tokyo Story (1953)'

    return 'I did not understand...'

额外修正

顺便修正了喜剧列表里重复的《Monty Python and the Holy Grail》条目,让推荐列表符合Top5的预期。

内容的提问来源于stack exchange,提问作者Aaron Sukhanov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 23:27:48