[PR #931] fix: guard against empty choices and None message in memory tutorial apps #14079

Open
opened 2026-07-11 19:31:40 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Shubhamsaboo/awesome-llm-apps/pull/931
Author: @SHAI-manpreet-likhari
Created: 7/6/2026
Status: 🔄 Open

Base: mainHead: fix/guard-empty-openai-response-memory-tutorials


📝 Commits (1)

  • 1231337 fix: guard against empty choices and None message in memory tutorial apps

📊 Changes

4 files changed (+11 additions, -1 deletions)

View changed files

📝 advanced_llm_apps/llm_apps_with_memory_tutorials/ai_arxiv_agent_memory/ai_arxiv_agent_memory.py (+2 -0)
📝 advanced_llm_apps/llm_apps_with_memory_tutorials/ai_travel_agent_memory/travel_agent_memory.py (+2 -0)
📝 advanced_llm_apps/llm_apps_with_memory_tutorials/llm_app_personalized_memory/llm_app_memory.py (+3 -1)
📝 advanced_llm_apps/llm_apps_with_memory_tutorials/multi_llm_memory/multi_llm_memory.py (+4 -0)

📄 Description

Summary

  • Four apps in advanced_llm_apps/llm_apps_with_memory_tutorials/ accessed response.choices[0].message.content without checking that choices is non-empty or that content is not None.
  • This can cause an IndexError when the API returns an empty choices list (content filter, quota exceeded, or transient error), or silently pass None into downstream memory/UI code.
  • Applies the same guard pattern used in #820 (merged) for the same class of bug in DeepSeek API calls.

Files changed

  • ai_arxiv_agent_memory/ai_arxiv_agent_memory.py
  • ai_travel_agent_memory/travel_agent_memory.py
  • llm_app_personalized_memory/llm_app_memory.py
  • multi_llm_memory/multi_llm_memory.py (both the OpenAI and Claude branches)

Test plan

  • python -m py_compile passes on all 4 modified files
  • Manual smoke test of each Streamlit app with a valid API key (not run in this environment — no API keys available)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Shubhamsaboo/awesome-llm-apps/pull/931 **Author:** [@SHAI-manpreet-likhari](https://github.com/SHAI-manpreet-likhari) **Created:** 7/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/guard-empty-openai-response-memory-tutorials` --- ### 📝 Commits (1) - [`1231337`](https://github.com/Shubhamsaboo/awesome-llm-apps/commit/1231337ba212fc2c79cc2feb3b5468ca2b815d07) fix: guard against empty choices and None message in memory tutorial apps ### 📊 Changes **4 files changed** (+11 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `advanced_llm_apps/llm_apps_with_memory_tutorials/ai_arxiv_agent_memory/ai_arxiv_agent_memory.py` (+2 -0) 📝 `advanced_llm_apps/llm_apps_with_memory_tutorials/ai_travel_agent_memory/travel_agent_memory.py` (+2 -0) 📝 `advanced_llm_apps/llm_apps_with_memory_tutorials/llm_app_personalized_memory/llm_app_memory.py` (+3 -1) 📝 `advanced_llm_apps/llm_apps_with_memory_tutorials/multi_llm_memory/multi_llm_memory.py` (+4 -0) </details> ### 📄 Description ## Summary - Four apps in `advanced_llm_apps/llm_apps_with_memory_tutorials/` accessed `response.choices[0].message.content` without checking that `choices` is non-empty or that `content` is not `None`. - This can cause an `IndexError` when the API returns an empty `choices` list (content filter, quota exceeded, or transient error), or silently pass `None` into downstream memory/UI code. - Applies the same guard pattern used in #820 (merged) for the same class of bug in DeepSeek API calls. ## Files changed - `ai_arxiv_agent_memory/ai_arxiv_agent_memory.py` - `ai_travel_agent_memory/travel_agent_memory.py` - `llm_app_personalized_memory/llm_app_memory.py` - `multi_llm_memory/multi_llm_memory.py` (both the OpenAI and Claude branches) ## Test plan - [x] `python -m py_compile` passes on all 4 modified files - [ ] Manual smoke test of each Streamlit app with a valid API key (not run in this environment — no API keys available) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-07-11 19:31:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/awesome-llm-apps#14079