Skip to content

Commit e68c61e

Browse files
edwinjosechittilappillyautofix-ci[bot]lucaseduoli
authored
fix: refactor Ollama model fetching to use async and filter capabilities (#10550)
* Refactor Ollama model fetching to use async and filter capabilities Replaces synchronous requests for Ollama model fetching with asynchronous httpx calls and adds filtering to only include models with 'completion' capability. Updates the LanguageModelComponent to support async validation and fetching of Ollama models, improving reliability and accuracy of available model options. * Update language_model.py * Add Notion integration components Introduces several Notion-related components for Langflow, including AddContentToPage, NotionDatabaseProperties, NotionListPages, NotionPageContent, NotionPageCreator, NotionPageUpdate, and NotionSearch. Updates the component index to register these new tools, enabling Notion API interactions such as page creation, content retrieval, database property listing, and more. * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Update LanguageModelComponent code in starter projects Refactored the LanguageModelComponent code in Basic Prompt Chaining.json to improve formatting and readability. No functional changes were made; only code style and structure were updated. * Refactor Ollama model fetching logic Moves Ollama model fetching and URL validation logic from the LanguageModelComponent class to shared utility functions in model_utils. Updates references in starter project JSONs to use the new utility functions for improved code reuse and maintainability. * Update component_index.json * Update Nvidia Remix.json * Handle message state for streaming responses Adds logic to skip processing text content when message state is 'complete' in OpenAI response streaming, ensuring only content_blocks are processed for tool calls. Updates LCModelComponent to set state to 'partial' during streaming and only update the database with 'complete' state, without sending a new message event, as the frontend already has all streamed content. * fixed test * Changed embedding model component * removed default values * fixed ruff * fixed starter projects --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
1 parent 324efcc commit e68c61e

30 files changed

Lines changed: 376 additions & 93 deletions

src/backend/base/langflow/api/v1/openai_responses.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,30 @@ async def openai_stream_generator() -> AsyncGenerator[str, None]:
171171
sender = data.get("sender", "")
172172
content_blocks = data.get("content_blocks", [])
173173

174+
# Get message state from properties
175+
properties = data.get("properties", {})
176+
message_state = properties.get("state") if isinstance(properties, dict) else None
177+
174178
await logger.adebug(
175-
"[OpenAIResponses][stream] add_message: sender=%s sender_name=%s text_len=%d",
179+
(
180+
"[OpenAIResponses][stream] add_message: "
181+
"sender=%s sender_name=%s text_len=%d state=%s"
182+
),
176183
sender,
177184
sender_name,
178185
len(text) if isinstance(text, str) else -1,
186+
message_state,
179187
)
180188

189+
# Skip processing text content if state is "complete"
190+
# All content has already been streamed via token events
191+
if message_state == "complete":
192+
await logger.adebug(
193+
"[OpenAIResponses][stream] skipping add_message with state=complete"
194+
)
195+
# Still process content_blocks for tool calls, but skip text content
196+
text = ""
197+
181198
# Look for Agent Steps in content_blocks
182199
for block in content_blocks:
183200
if block.get("title") == "Agent Steps":

src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/backend/base/langflow/initial_setup/starter_projects/Custom Component Generator.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/backend/base/langflow/initial_setup/starter_projects/Financial Report Parser.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)