File size: 766 Bytes
2e73be9
 
64daa4b
74637c6
64daa4b
 
 
2e73be9
 
64daa4b
2e73be9
bb45124
2e73be9
c8200a3
64daa4b
 
 
 
 
 
 
bb45124
e355701
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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