dinhquangson commited on
Commit
bb45124
1 Parent(s): 1109b63

Update llm.py

Browse files
Files changed (1) hide show
  1. llm.py +7 -13
llm.py CHANGED
@@ -1,22 +1,16 @@
1
  import pytesseract
2
 
3
- import google.generativeai as palm
4
  api_key = 'AIzaSyB7-RzBwTAfVA-7ZGk2mEOQwOxshpwzhpM' # put your API key here
5
  palm.configure(api_key=api_key)
6
- models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods]
7
- model = models[0].name
8
 
9
  def llm(img):
10
  text = pytesseract.image_to_string(img, lang='vie')
11
  # generate text
12
- prompt = "take this peace of information and give all the information in point wise better format also give some recomendation related to them, if you don't get any nutrition content simply reply 'I don't seem have any knowledge of the perticular Nutrition Content' " + text
13
  # print(prompt)
14
- text = palm.generate_text(
15
- prompt=prompt,
16
- model=model,
17
- temperature=0.2,
18
- max_output_tokens=2000,
19
- top_p=0.8,
20
- top_k=40,
21
- )
22
- return text.result
 
1
  import pytesseract
2
 
3
+ import google.generativeai as genai
4
  api_key = 'AIzaSyB7-RzBwTAfVA-7ZGk2mEOQwOxshpwzhpM' # put your API key here
5
  palm.configure(api_key=api_key)
6
+ geminiModel = genai.GenerativeModel(model_name='gemini-pro')
7
+
8
 
9
  def llm(img):
10
  text = pytesseract.image_to_string(img, lang='vie')
11
  # generate text
12
+ prompt = "take this peace of information and give all the information in point wise better format also give some recomendation related to them' " + text
13
  # print(prompt)
14
+ response = model.generate_content(prompt)
15
+
16
+ return response.text