NeuralNine / neuralintents

A simple interface for working with intents and chatbots.
MIT License
253 stars 137 forks source link

no output. #48

Open rahul55552003 opened 3 months ago

rahul55552003 commented 3 months ago

hello, the model training is done successfully. but when i type 'hello', there is no response. i have also changed the line in assistants.py with " self.model.add(InputLayer(input_shape=(X.shape[1],))) " as suggested by some user. can you please help me guys. iam new to this and iam stuck. i dont know how to resolve this. thank you for your patience.

intents.json

`from neuralintents import BasicAssistant import matplotlib.pyplot as plt import pandas as pd import pandas_datareader as web import mplfinance as mpf from tensorflow.keras.layers import Dense, Dropout

import pickle import sys import datetime as dt

{

GenericAssistant = BasicAssistant,

train_model = fit_model,

request() = process_input().

#

def myfunction():

pass

#

mappings = {

'greetings': myfunction

}

Initialize the assistant with the intents file

assistant = BasicAssistant('intents.json', intent_methods = mappings)

#

Train the model using the new method

assistant.fit_model()

#

Request user input to interact with the assistant

assistant.process_input()

}

{ YOU CAN DELETE THIS LINE ONCE THE PORTFOLIO FILE IS CREATED :

portfolio = {'AAPL': 20, 'TSLA': 5, 'GS': 10}

# #

with open('portfolio.pkl', 'wb') as f:

pickle.dump(portfolio, f)

}

with open('portfolio.pkl', 'rb') as f: portfolio = pickle.load(f)

print(portfolio)

def save_portfolio(): with open('portfolio.pkl', 'wb') as f: pickle.dump(portfolio, f)

def add_portfolio(): ticker = input("Which Stock Do You Want to add: ") amount = input("How many shares do you want to add: ")

if ticker in portfolio.keys():
    portfolio[ticker] += amount
else:
    portfolio[ticker] = amount

save_portfolio()

def remove_portfolio(): ticker = input("Which stock do you want to sell: ") amount = input("How many shares do you want to sell: ")

if ticker in portfolio.keys():
    if amount <= portfolio[ticker]:
        portfolio[ticker] -= amount
        save_portfolio()
    else:
        print("You dont have enough shares!")
else:
    print(f"You dont own any shares of {ticker}")

def show_portfolio(): print("Your portfolio: ") for ticker in portfolio.keys(): print(f"You own {portfolio[ticker]} shares of {ticker}")

def portfolio_worth(): sum = 0 for ticker in portfolio.keys(): data = web.DataReader(ticker, 'yahoo') price = data['Close'].iloc[-1] sum += price print(f"Your portfolio is worth {sum} USD")

def portfolio_gains(): starting_date = input("Enter a date for comparision (YYYY-MM-DD): ")

sum_now = 0
sum_then = 0

try:
    for ticker in portfolio.keys():
        data = web.DataReader(ticker, 'yahoo')
        price_now = data['Close'].iloc[-1]
        price_then = data.loc[data.index == starting_date]['Close'].values[0]
        sum_now += price_now
        sum_then += price_then

    print(f"Relative Gains: {((sum_now - sum_then) / sum_then) * 100}%")
    print(f"Absolute Gains: {sum_now - sum_then} USD")

except IndexError:
    print("There was no trading on this day.")

def plot_chart(): ticker = input("Choose a ticker symbol: ") starting_string = input("Choose a stating date (DD/MM/YYYY): ")

plt.style.use('dark_background')

start = dt.datetime.strptime(starting_string, "%d/%m/Y")
end = dt.datetime.now()

data = web.DataReader(ticker, 'yahoo', start, end)

colors = mpf.make_marketcolors(up='#00ff00', down='ff0000', wick='inherit', edge='inherit', volume='in')
mpf_style = mpf.make_mpf_style(base_mpf_style='nightclouds', marketcolors=colors)
mpf.plot(data, type='candle', style=mpf_style, volume=True)

def bye(): print("Good Bye") sys.exit(0)

mappings = { 'plot_chart': plot_chart, 'add_portfolio': add_portfolio, 'remove_portfolio': remove_portfolio, 'show_portfolio': show_portfolio, 'portfolio_worth': portfolio_worth, 'portfolio_gains': portfolio_gains, 'bye': bye }

Define any custom hidden layers if needed

hidden_layers = [

Dense(128, activation='relu'),

Dropout(0.5),

Dense(64, activation='relu')

]

Correct constructor call

assistant = BasicAssistant('intents.json', model_name="financial_assistant_model")

assistant.fit_model() assistant.save_model()

while True: message = input("") assistant.process_input(message)

Test the model prediction

test_input = "Add a stock to my portfolio"

predicted_response = assistant.process_input(test_input)

print(predicted_response)

`