Dagger
Search

getAdvice

This module harnesses the power of artificial intelligence to provide tailored financial advice, making it an essential tool for users seeking guidance on budget management and financial planning. Using LangChain coupled with OpenAI's powerful GPT models, this module processes transactional data and user interactions to generate actionable insights and advice.

The integration of LangChain with OpenAI allows the module to maintain conversation states, making it possible to deliver advice that not only reflects current financial data but also adapts based on historical spending patterns and ongoing user feedback. This dynamic approach helps users make informed decisions that align with their financial goals.

Functions: - `generate`: The primary function of the module, it takes in user transaction data and uses an AI model to generate financial advice. This function is designed to simulate a financial advisor, providing insights into weekly spending, budget adherence, and management of shared expenses.

Args: - `data (str)`: A JSON string containing detailed transaction data for the current and previous weeks. This data should include amounts, categories, and other relevant transaction metadata. - `openai (Secret)`: A Secret object that stores the OpenAI API key, which is used to authenticate with the OpenAI service and access its AI models.

Returns: - The function outputs a JSON string that includes tailored financial advice. This advice is generated based on a comparison of current spending against historical data, with considerations for budget limits and shared financial responsibilities.

Example Use Case: A user submits transaction data through the Dagger CLI using the following command: `dagger call generate --data='{"current_week": {"Groceries": "$150", "Utilities": "$120"}, "previous_weeks": {"Groceries": "$130", "Utilities": "$110"}}' --openai=env:OPENAI_SECRET` The function then processes this data, engages in an AI-driven dialogue to understand context and user preferences, and outputs customized advice on how to better manage expenses.

This module is ideal for applications requiring advanced financial analysis, such as personal finance apps, budgeting tools, and financial advisory services. It empowers users to achieve better financial discipline and smarter spending habits through AI-driven insights and recommendations.

Installation

dagger install github.com/EmmS21/daggerverse/getAdvice@v0.0.1

Entrypoint

Return Type
GetAdvice !
Example
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
NameTypeDefault ValueDescription
dataString !-No description provided
openaiSecret !-A reference to a secret value, which can be handled more safely than the value itself.
connectionSecret !-A reference to a secret value, which can be handled more safely than the value itself.
Example
dagger -m github.com/EmmS21/daggerverse/getAdvice@9d246c4a9126edf943f703651ae5fdb7cd774584 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
NameTypeDefault ValueDescription
feedbackString !-No description provided
dataString !-No description provided
openaiSecret !-A reference to a secret value, which can be handled more safely than the value itself.
connectionSecret !-A reference to a secret value, which can be handled more safely than the value itself.
Example
dagger -m github.com/EmmS21/daggerverse/getAdvice@9d246c4a9126edf943f703651ae5fdb7cd774584 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)
}