-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
34 lines (21 loc) · 945 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streamlit as st
from langchain.prompts import PromptTemplate
from langchain.llms import CTransformers
## Function To get response from LLAma 2 model
def getLLamaresponse(input_text,no_words,blog_style):
### LLama2 model
llm=CTransformers(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(prompt.format(blog_style=blog_style,input_text=input_text,no_words=no_words))
print(response)
return response