mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-10 07:55:21 +02:00
Merge branch 'main' of github.com:maybe-finance/maybe into zachgoll/ai-streaming-updates
This commit is contained in:
commit
56d78b50ce
9 changed files with 31 additions and 15 deletions
|
@ -128,7 +128,7 @@ class Assistant
|
|||
<<~PROMPT
|
||||
## Your identity
|
||||
|
||||
You are a financial assistant for an open source personal finance application called "Maybe", which is short for "Maybe Finance".
|
||||
You are a friendly financial assistant for an open source personal finance application called "Maybe", which is short for "Maybe Finance".
|
||||
|
||||
## Your purpose
|
||||
|
||||
|
@ -151,6 +151,7 @@ class Assistant
|
|||
|
||||
- Format all responses in markdown
|
||||
- Format all monetary values according to the user's preferred currency
|
||||
- Format dates in the user's preferred format
|
||||
|
||||
#### User's preferred currency
|
||||
|
||||
|
@ -164,20 +165,21 @@ class Assistant
|
|||
- Default format: #{preferred_currency.default_format}
|
||||
- Separator: #{preferred_currency.separator}
|
||||
- Delimiter: #{preferred_currency.delimiter}
|
||||
- Date format: #{preferred_date_format}
|
||||
|
||||
### Rules about financial advice
|
||||
|
||||
You are NOT a licensed financial advisor and therefore, you should not provide any financial advice. Instead,
|
||||
you should focus on educating the user about personal finance and their own data so they can make informed decisions.
|
||||
You are NOT a licensed financial advisor and therefore, you should not provide any specific investment advice (such as "buy this stock", "sell that bond", "invest in crypto", etc.).
|
||||
|
||||
Instead, you should focus on educating the user about personal finance using their own data so they can make informed decisions.
|
||||
|
||||
- Do not provide financial and/or investment advice
|
||||
- Do not suggest investments or financial products
|
||||
- Do not make assumptions about the user's financial situation. Use the functions available to get the data you need.
|
||||
- Do not make assumptions about the user's financial situation. Use the functions available to get the data you need.
|
||||
|
||||
### Function calling rules
|
||||
|
||||
- Use the functions available to you to get user financial data and enhance your responses
|
||||
- For functions that require dates, use the current date as your reference point: #{Date.current}
|
||||
- For functions that require dates, use the current date as your reference point: #{Date.current}
|
||||
- If you suspect that you do not have enough data to 100% accurately answer, be transparent about it and state exactly what
|
||||
the data you're presenting represents and what context it is in (i.e. date range, account, etc.)
|
||||
PROMPT
|
||||
|
@ -196,6 +198,10 @@ class Assistant
|
|||
Money::Currency.new(chat.user.family.currency)
|
||||
end
|
||||
|
||||
def preferred_date_format
|
||||
chat.user.family.date_format
|
||||
end
|
||||
|
||||
def artificial_thinking_delay
|
||||
1
|
||||
end
|
||||
|
|
|
@ -61,13 +61,12 @@ class Provider
|
|||
# Override to set class-level error transformation for methods using `with_provider_response`
|
||||
def default_error_transformer(error)
|
||||
if error.is_a?(Faraday::Error)
|
||||
Error.new(
|
||||
self.class::Error.new(
|
||||
error.message,
|
||||
details: error.response&.dig(:body),
|
||||
provider: self.class.name
|
||||
)
|
||||
else
|
||||
Error.new(error.message, provider: self.class.name)
|
||||
self.class::Error.new(error.message)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
class Provider::Openai < Provider
|
||||
include LlmProvider
|
||||
|
||||
# Subclass so errors caught in this provider are raised as Provider::Openai::Error
|
||||
Error = Class.new(Provider::Error)
|
||||
|
||||
MODELS = %w[gpt-4o]
|
||||
|
||||
def initialize(access_token)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
class Provider::Synth < Provider
|
||||
include ExchangeRateProvider, SecurityProvider
|
||||
|
||||
# Subclass so errors caught in this provider are raised as Provider::Synth::Error
|
||||
Error = Class.new(Provider::Error)
|
||||
|
||||
def initialize(api_key)
|
||||
@api_key = api_key
|
||||
end
|
||||
|
|
|
@ -20,9 +20,7 @@ class Security < ApplicationRecord
|
|||
symbol: ticker,
|
||||
name: name,
|
||||
logo_url: logo_url,
|
||||
exchange_acronym: exchange_acronym,
|
||||
exchange_operating_mic: exchange_operating_mic,
|
||||
exchange_country_code: country_code
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,15 @@ module Security::Provided
|
|||
response = provider.search_securities(symbol, country_code: country_code, exchange_operating_mic: exchange_operating_mic)
|
||||
|
||||
if response.success?
|
||||
response.data
|
||||
response.data.map do |provider_security|
|
||||
# Need to map to domain model so Combobox can display via to_combobox_option
|
||||
Security.new(
|
||||
ticker: provider_security.symbol,
|
||||
name: provider_security.name,
|
||||
logo_url: provider_security.logo_url,
|
||||
exchange_operating_mic: provider_security.exchange_operating_mic,
|
||||
)
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Security::SynthComboboxOption
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :symbol, :name, :logo_url, :exchange_acronym, :exchange_country_code, :exchange_operating_mic
|
||||
attr_accessor :symbol, :name, :logo_url, :exchange_operating_mic
|
||||
|
||||
def id
|
||||
"#{symbol}|#{exchange_operating_mic}" # submitted by combobox as value
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
<p class="text-secondary text-xs mb-4"><%= t(".preview") %></p>
|
||||
|
||||
<%= styled_form_with model: @user do |form| %>
|
||||
<%= styled_form_with model: @user, data: { turbo: false } do |form| %>
|
||||
<%= form.hidden_field :onboarded_at, value: Time.current %>
|
||||
<%= form.hidden_field :redirect_to, value: "home" %>
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<%= csp_meta_tag %>
|
||||
|
||||
<%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %>
|
||||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
||||
|
||||
<%= javascript_importmap_tags %>
|
||||
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue