-
Notifications
You must be signed in to change notification settings - Fork 0
feat(rag): add Ollama embeddings + Gemini 2.5 agent support #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
| import uuid | ||
| from collections.abc import AsyncIterator | ||
| from datetime import UTC, datetime, timedelta | ||
| from typing import Any, Literal | ||
| from typing import Any, Literal, cast | ||
|
|
||
| import structlog | ||
| from pydantic_ai import Agent | ||
|
|
@@ -263,8 +263,8 @@ async def chat( | |
| pending_approval = False | ||
|
|
||
| # The structured output might indicate approval is needed | ||
| # NOTE: PydanticAI's result.data type is generic, cast to Any for attribute access | ||
| result_data: Any = result.data # type: ignore[attr-defined] | ||
| # NOTE: PydanticAI v1.48.0 uses result.output (not result.data) | ||
| result_data: Any = result.output | ||
|
Comment on lines
+266
to
+267
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, find the stream_chat implementation in service.py
grep -n "stream_chat\|get_data\|result\.output" app/features/agents/service.py | head -20Repository: w7-mgfcode/ForecastLabAI Length of output: 408 🏁 Script executed: # Check the dependencies to confirm PydanticAI version
fd -e "requirements.txt" -e "pyproject.toml" -e "poetry.lock" -e "setup.py" | head -5 | xargs grep -l "pydantic" 2>/dev/nullRepository: w7-mgfcode/ForecastLabAI Length of output: 52 🌐 Web query:
💡 Result: In PydanticAI (pydantic-ai) v1.48.0, the object you get from What to use in v1.48.0
Where it’s documented
About
|
||
|
|
||
| # Check for pending_action in result data (primary trigger) | ||
| # The agent tools should return a pending_action dict with action_type and arguments | ||
|
|
@@ -662,13 +662,31 @@ def _serialize_messages( | |
| List of serializable dictionaries. | ||
| """ | ||
| import dataclasses | ||
| from datetime import datetime | ||
|
|
||
| def json_safe(obj: object) -> object: | ||
| """Convert non-JSON-serializable objects to JSON-safe types.""" | ||
| if isinstance(obj, datetime): | ||
| return obj.isoformat() | ||
| if isinstance(obj, dict): | ||
| return {k: json_safe(v) for k, v in obj.items()} | ||
| if isinstance(obj, list): | ||
| return [json_safe(item) for item in obj] | ||
| # Primitive JSON types pass through | ||
| if isinstance(obj, (str, int, float, bool, type(None))): | ||
| return obj | ||
| # Fallback: convert unknown types to string representation | ||
| return str(obj) | ||
|
|
||
| serialized: list[dict[str, Any]] = [] | ||
| for msg in messages: | ||
| if dataclasses.is_dataclass(msg) and not isinstance(msg, type): | ||
| # Convert dataclass to dict, handling nested types | ||
| try: | ||
| msg_dict = dataclasses.asdict(msg) | ||
| # Convert datetime objects to ISO strings | ||
| # Cast is safe: json_safe preserves dict structure | ||
| msg_dict = cast(dict[str, Any], json_safe(msg_dict)) | ||
| # Add kind discriminator for deserialization | ||
| if hasattr(msg, "kind"): | ||
| msg_dict["kind"] = msg.kind | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle empty env-var values when exporting API keys.
If the env var exists but is an empty string, the code will skip setting the real key and downstream clients will still see a blank value. Consider treating empty as “missing.”
🛠️ Proposed fix
🤖 Prompt for AI Agents