Skip to content

feat: Add Currency Conversion Widget#1027

Open
haosenwang1018 wants to merge 2 commits intoItzCrazyKns:masterfrom
haosenwang1018:feat/currency-widget
Open

feat: Add Currency Conversion Widget#1027
haosenwang1018 wants to merge 2 commits intoItzCrazyKns:masterfrom
haosenwang1018:feat/currency-widget

Conversation

@haosenwang1018
Copy link

@haosenwang1018 haosenwang1018 commented Mar 6, 2026

This PR adds a new currency conversion widget to Perplexica.

Features

  • Real-time exchange rates from exchangerate-api.com (free tier)
  • Support for 20+ currencies: USD, EUR, GBP, JPY, CAD, AUD, CHF, CNY, etc.
  • Natural language query support (e.g., "Convert 100 USD to EUR")
  • Currency name normalization (e.g., "dollars" → "USD")
  • Related rates shown for popular currencies as context

Example Queries

  • "Convert 100 USD to EUR"
  • "What's the exchange rate from JPY to GBP?"
  • "How much is 50 euros in dollars?"

Changes

  • New currencyWidget.ts following existing widget patterns
  • Updated classifier to detect currency conversion queries
  • Integrated with search pipeline

Testing

  • Follows existing widget architecture (Weather, Stock, Calculator)
  • Includes proper TypeScript types
  • Error handling for API failures

Fixes #XXX (if there's a related issue)


Summary by cubic

Adds a currency conversion widget that answers FX queries with real-time rates. Also adds DeepSeek as a new model provider for chat and embeddings.

  • New Features
    • Currency conversion widget: real-time rates from exchangerate-api.com, supports 20+ currencies, natural language queries with name/symbol normalization, and related popular rates. Integrated via showCurrencyWidget in the classifier and registered in the widget executor.
    • DeepSeek provider: chat (streaming, tool calls, object generation) and embeddings. Includes default models (deepseek-chat, deepseek-reasoner, deepseek-embedding) with provider config and registration.

Written for commit 67239a3. Summary will update on new commits.

Contributor added 2 commits March 6, 2026 04:07
Add DeepSeek as a new model provider option, including:
- DeepSeek LLM implementation with streaming and object generation
- DeepSeek Embedding implementation for document/query embeddings
- Provider configuration with default models (deepseek-chat, deepseek-reasoner)
- Registration in the providers index

DeepSeek provides high-quality language models at competitive pricing
and uses an OpenAI-compatible API for easy integration.
Add a new currency conversion widget that provides real-time exchange rates:
- New currencyWidget.ts with support for 20+ currencies
- Uses exchangerate-api.com for free, reliable exchange rate data
- Includes currency symbol and name normalization (e.g., dollars -> USD)
- Provides related rates for popular currencies as additional context
- Integrated with classifier to detect currency conversion queries
- Supports natural language queries like 'Convert 100 USD to EUR'

This widget follows the existing widget pattern and integrates seamlessly
with the search pipeline, showing currency conversions alongside other results.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/lib/models/providers/deepseek/deepseekLLM.ts">

<violation number="1" location="src/lib/models/providers/deepseek/deepseekLLM.ts:106">
P2: Inconsistent JSON parsing between streaming and non-streaming paths - `JSON.parse(tc.function.arguments)` can throw on malformed model output. The streaming path uses tolerant `parse` from `partial-json`, and `generateObject` uses `repairJson`, but `generateText` uses raw `JSON.parse` with no fallback. This creates a reliability regression where non-streaming calls can crash on valid but slightly malformed model responses.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

return {
name: tc.function.name,
id: tc.id,
arguments: JSON.parse(tc.function.arguments),
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Inconsistent JSON parsing between streaming and non-streaming paths - JSON.parse(tc.function.arguments) can throw on malformed model output. The streaming path uses tolerant parse from partial-json, and generateObject uses repairJson, but generateText uses raw JSON.parse with no fallback. This creates a reliability regression where non-streaming calls can crash on valid but slightly malformed model responses.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/models/providers/deepseek/deepseekLLM.ts, line 106:

<comment>Inconsistent JSON parsing between streaming and non-streaming paths - `JSON.parse(tc.function.arguments)` can throw on malformed model output. The streaming path uses tolerant `parse` from `partial-json`, and `generateObject` uses `repairJson`, but `generateText` uses raw `JSON.parse` with no fallback. This creates a reliability regression where non-streaming calls can crash on valid but slightly malformed model responses.</comment>

<file context>
@@ -0,0 +1,228 @@
+                return {
+                  name: tc.function.name,
+                  id: tc.id,
+                  arguments: JSON.parse(tc.function.arguments),
+                };
+              }
</file context>
Fix with Cubic

Copy link

@xkonjin xkonjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review pass:

  • Main risk area here is input validation, path handling, and malformed payload behavior.
  • I didn’t see targeted regression coverage in the diff; please add or point CI at a focused test for the changed path in classifier.ts, types.ts, currencyWidget.ts (+6 more).
  • Before merge, I’d smoke-test the behavior touched by classifier.ts, types.ts, currencyWidget.ts (+6 more) with malformed input / retry / rollback cases, since that’s where this class of change usually breaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants