#PS D:\Robin Sir\ChatBot-Starter-main
1 messages ยท Page 1 of 1 (latest)
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
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>
because you have a lot of unresolved packages...
this is my full code file
yes, but where did you find this code?
one youtube
it run well but when i close this file and again i run its show me this plms
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
I want to make a chatbot by using pdf i want to same in fontend but not in backend
ok
maybe , try once
I want to make a bangla chatbot by using multipule pdfs
I don't have any idea can you please help me
Hmmmm what kind of pdfs are these?
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
NotebookLM looks good for this kinda?
I have used it befor,e Not convinced ๐ฆ
I'd say Pop AI is better

never heard of Pop AI
i'll keep that in mind next time i need to use NotebookLM
to try and compare the two :>
๐
you'll love it