getAdvice
This module leverages AI to provide personalized financial advice, aiding users in budget management and financial planning. By integrating LangChain with OpenAI's GPT models, the module processes transactional data and user interactions to deliver actionable insights and recommendations.Functions: generate This function simulates a financial advisor, providing insights on weekly spending, budget adherence, and management of shared expenses. It is designed to run twice a week to offer timely financial advice.
Args:
data (str): A JSON string containing transaction data for the current and previous weeks, including amounts, categories, and other relevant metadata. openai (Secret): A Secret object storing the OpenAI API key for authentication and access to OpenAI's AI models. connection (Secret): A Secret object storing the MongoDB connection string for database access.
Returns:
A JSON string with tailored financial advice, generated by comparing current spending against historical data and considering budget limits and shared financial responsibilities.
Example Use Case:
dagger call generate --data='{"current_week": {"Groceries": "$150", "Utilities": "$120"}, "previous_weeks": {"Groceries": "$130", "Utilities": "$110"}}' --openai=env:OPENAI_SECRET --connection=env:DB_CONNECTION
Function - update_prompt: This function updates the initial prompt based on user feedback and regenerates advice using the updated prompt. It is triggered each time the user provides feedback on the AI-generated advice.
Args:
feedback (str): User feedback on the previous advice, used to refine and improve future recommendations. data (str): A JSON string containing the same spending data as used in the generate function. openai (Secret): A Secret object storing the OpenAI API key for authentication and access to OpenAI's AI models. connection (Secret): A Secret object storing the MongoDB connection string for database access. Returns:
A JSON string with updated financial advice, incorporating user feedback and adjusting recommendations accordingly.
Example Use Case:
dagger call update_prompt --feedback='I prefer more savings tips.' --data='{"current_week": {"Groceries": "$150", "Utilities": "$120"}, "previous_weeks": {"Groceries": "$130", "Utilities": "$110"}}' --openai=env:OPENAI_SECRET --connection=env:DB_CONNECTION This command processes the feedback and data, uses the updated prompt to generate new advice, and outputs refined recommendations based on the user’s input.
Technical Details Both functions interact with MongoDB to manage conversation states and ensure personalized advice that evolves over time. The generate function establishes an initial context, while update_prompt modifies this context based on user feedback, ensuring advice remains relevant and personalized.
The module aims to empower users with AI-driven insights for better financial discipline and smarter spending habits, making it an invaluable tool for personal finance apps, budgeting tools, and financial advisory services.
Installation
dagger install github.com/EmmS21/daggerverse/getAdvice@v0.0.2
Entrypoint
Return Type
GetAdvice !
Example
dagger -m github.com/EmmS21/daggerverse/getAdvice@50e158a644959653ec0339e66cbdd7268a35f55c call \
func (m *myModule) example() *GetAdvice {
return dag.
GetAdvice()
}
@function
def example() -> dag.GetAdvice:
return (
dag.get_advice()
)
@func()
example(): GetAdvice {
return dag
.getAdvice()
}
Types
GetAdvice 🔗
generate() 🔗
Uses LangChain with OpenAI to generate financial advice based on the AI’s role as a financial advisor. This function manages conversation states for insights on weekly spending, budget adherence, and shared expenses management.
Args: data (str): A JSON string containing the spending data. openai_secret_key (str): The OpenAI API key.
Returns: Dict[str, Union[str, bool]]: A dictionary containing the generated advice or an error message.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
data | String ! | - | No description provided |
openai | Secret ! | - | A reference to a secret value, which can be handled more safely than the value itself. |
connection | Secret ! | - | A reference to a secret value, which can be handled more safely than the value itself. |
Example
dagger -m github.com/EmmS21/daggerverse/getAdvice@50e158a644959653ec0339e66cbdd7268a35f55c call \
generate --data string --openai env:MYSECRET --connection env:MYSECRET
func (m *myModule) example(ctx context.Context, data string, openai *Secret, connection *Secret) string {
return dag.
GetAdvice().
Generate(ctx, data, openai, connection)
}
@function
async def example(data: str, openai: dagger.Secret, connection: dagger.Secret) -> str:
return await (
dag.get_advice()
.generate(data, openai, connection)
)
@func()
async example(data: string, openai: Secret, connection: Secret): Promise<string> {
return dag
.getAdvice()
.generate(data, openai, connection)
}
updatePrompt() 🔗
Updates the initial prompt based on user feedback, then regenerates advice using the updated prompt.
Args: feedback (str): User feedback on the previous advice. data (str): A JSON string containing the spending data, same as in the generate function. openai (Secret): Secret object storing the OpenAI API key.
Returns: str: Updated financial advice.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
feedback | String ! | - | No description provided |
data | String ! | - | No description provided |
openai | Secret ! | - | A reference to a secret value, which can be handled more safely than the value itself. |
connection | Secret ! | - | A reference to a secret value, which can be handled more safely than the value itself. |
Example
dagger -m github.com/EmmS21/daggerverse/getAdvice@50e158a644959653ec0339e66cbdd7268a35f55c call \
update-prompt --feedback string --data string --openai env:MYSECRET --connection env:MYSECRET
func (m *myModule) example(ctx context.Context, feedback string, data string, openai *Secret, connection *Secret) string {
return dag.
GetAdvice().
UpdatePrompt(ctx, feedback, data, openai, connection)
}
@function
async def example(feedback: str, data: str, openai: dagger.Secret, connection: dagger.Secret) -> str:
return await (
dag.get_advice()
.update_prompt(feedback, data, openai, connection)
)
@func()
async example(feedback: string, data: string, openai: Secret, connection: Secret): Promise<string> {
return dag
.getAdvice()
.updatePrompt(feedback, data, openai, connection)
}