|
import pytesseract |
|
|
|
import google.generativeai as palm |
|
api_key = 'AIzaSyB4lQJM89q1EQDNtKoh8E5wf-ks0E6Q_Uc' |
|
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') |
|
|
|
prompt = "take this peace of information and give all the information in point wise better format also give some recomendation related to them' " + text |
|
|
|
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 |