dinhquangson's picture
Update llm.py
e355701 verified
raw
history blame contribute delete
766 Bytes
import pytesseract
import google.generativeai as palm
api_key = 'AIzaSyB4lQJM89q1EQDNtKoh8E5wf-ks0E6Q_Uc' # put your API key here
palm.configure(api_key=api_key)
models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods]
model = models[0].name
def llm(img):
text = pytesseract.image_to_string(img, lang='vie+eng')
# generate text
prompt = "take this peace of information and give all the information in point wise better format also give some recomendation related to them' " + text
# print(prompt)
response = palm.generate_text(
prompt=prompt,
model=model,
temperature=0.3,
max_output_tokens=2000,
top_p=0.8,
top_k=40,
)
return response.result