krishnaik06 / Complete-Langchain-Tutorials

GNU General Public License v2.0
320 stars 268 forks source link

Call Depreceated use Invoke Instead #7

Open get-rishabh opened 7 months ago

get-rishabh commented 7 months ago

Getting the following Error from Terminal, while my browser is stuck at a infinite loop:

LangChainDeprecationWarning: The function call was deprecated in LangChain 0.1.7 and will be removed in 0.2.0. Use invoke instead. My Code:

Untitled

Shailendra-08 commented 6 months ago

Same is happing with me its does not generting any response what i do

These is my code

import streamlit as st from langchain.prompts import PromptTemplate from langchain_community.llms import CTransformers

Function To get response from LLAma 2 model

def getLLamaresponse(input_text,no_words,blog_style):

### LLama2 model
llm=CTransformers(model='model/llama-2-7b-chat.ggmlv3.q8_0.bin',
                  model_type='llama',
                  config={'max_new_tokens':256,
                          'temperature':0.01})

## Prompt Template

template="""
    Write a blog for {blog_style} job profile for a topic {input_text}
    within {no_words} words.
        """

prompt=PromptTemplate(input_variables=["blog_style","input_text",'no_words'],
                      template=template)

## Generate the ressponse from the LLama 2 model
response=llm.invoke(prompt.format(blog_style=blog_style,input_text=input_text,no_words=no_words))
print(response)
return response

st.set_page_config(page_title="Generate Blogs", page_icon='🤖', layout='centered', initial_sidebar_state='collapsed')

st.header("Generate Blogs 🤖")

input_text=st.text_input("Enter the Blog Topic")

creating to more columns for additonal 2 fields

col1,col2=st.columns([5,5])

with col1: no_words=st.text_input('No of Words') with col2: blog_style=st.selectbox('Writing the blog for', ('Researchers','Data Scientist','Common People'),index=0)

submit=st.button("Generate")

Final response

if submit: st.write(getLLamaresponse(input_text,no_words,blog_style))