#PS D:\Robin Sir\ChatBot-Starter-main

1 messages ยท Page 1 of 1 (latest)

rugged quail
#

hello

#

hello

#

okay, u havent installed a library

#
from flask import Flask, rendertemplate, request, jsonify


from transformers import AutoModelForCausalLM, AutoTokenizer
import torch


tokenizer = AutoTokenizer.frompretrained("microsoft/DialoGPT-medium")
model = AutoModelForCausalLM.frompretrained("microsoft/DialoGPT-medium")


app = Flask(name)

@app.route('/')
def home():
    return rendertemplate('chat.html')


@app.route("/get", methods=["GET", "POST"])
def chat():
    msg = request.form["msg"]
    input = msg
    return get_Chat_response(input)


def get_Chat_response(text):

    # Let's chat for 5 lines
    for step in range(5):
        # encode the new user input, add the eos_token and return a tensor in Pytorch
        new_user_input_ids = tokenizer.encode(str(text) + tokenizer.eos_token, return_tensors='pt')

        # append the new user input tokens to the chat history
        bot_input_ids = torch.cat([chat_history_ids, new_user_input_ids], dim=-1) if step > 0 else new_user_input_ids

        # generated a response while limiting the total chat history to 1000 tokens, 
        chat_history_ids = model.generate(bot_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id)

        # pretty print last ouput tokens from bot
        return tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)


if __name == '__main':
    app.run()
#

maybe u check

if __name == '__main':

this line

#

it shud be

if __name__ == '__main__'
#

and as @opal summit told already, its an issue with torch

stoic laurel
#

PS D:\Robin Sir\ankaramessi> & "d:/Robin Sir/ankaramessi/myenv/Scripts/python.exe" "d:/Robin Sir/ankaramessi/app.py"
Traceback (most recent call last):
File "d:\Robin Sir\ankaramessi\app.py", line 1, in <module>
from flask import Flask, rendertemplate, request, jsonify
ImportError: cannot import name 'rendertemplate' from 'flask' (D:\Robin Sir\ankaramessi\myenv\Lib\site-packages\flask_init_.py)
PS D:\Robin Sir\ankaramessi>

opal summit
#

hmmmm

#

are you generating your code by AI?

#

by any chance?

stoic laurel
#

No

#

ok can I Create the same think by traing Pdfs

#

in bangla language

opal summit
#

because you have a lot of unresolved packages...

stoic laurel
#

this is my full code file

opal summit
stoic laurel
#

one youtube

#

it run well but when i close this file and again i run its show me this plms

opal summit
#

same problem as before

#

you're trying to import modules that you don't have or don't exist

#

double check what the video said

#

or maybe pick another video if it's exactly the same

stoic laurel
#

I want to make a chatbot by using pdf i want to same in fontend but not in backend

rugged quail
#

ok

rugged quail
stoic laurel
#

I want to make a bangla chatbot by using multipule pdfs

rugged quail
#

oh

#

what model?

stoic laurel
#

I don't have any idea can you please help me

rugged quail
stoic laurel
#

this is a pdf which is a bangla book I want like user can ask qustion and the bot giving ansewer from the book

#

I have done the font end by html and css but i can't make the bot

rugged quail
#

okay

#

okay

#

u can try some LLMs for this

#

maybe Llama 3

opal summit
#

NotebookLM looks good for this kinda?

rugged quail
#

I'd say Pop AI is better

opal summit
#

never heard of Pop AI

#

i'll keep that in mind next time i need to use NotebookLM

#

to try and compare the two :>

rugged quail
#

๐Ÿ‘

rugged quail