That1BrainCell commited on
Commit
e42b52b
·
verified ·
1 Parent(s): 41f609d

Upload embedding.py

Browse files
Files changed (1) hide show
  1. embedding.py +9 -17
embedding.py CHANGED
@@ -78,7 +78,6 @@ def imporve_text(text):
78
  Please rewrite the following text to make it short, concise, and of high quality.
79
  Ensure that all essential information and key points are retained.
80
  Focus on improving clarity, coherence, and word choice without altering the original meaning.
81
- Do not add your own information or titles.
82
 
83
  text = {text}
84
  '''
@@ -111,23 +110,15 @@ def feature_extraction(tag, history , context):
111
  return result.content
112
 
113
  def feature_extraction_image(url):
114
-
115
- vision = ChatGoogleGenerativeAI(model="gemini-1.5-flash",google_api_key='AIzaSyBzbZQBffHFK3N-gWnhDDNbQ9yZnZtaS2E',temperature = 0.1)
116
- # result = gemini.invoke('''Hello''')
117
- # Markdown(result.content)
118
- # print(result)
119
-
120
- text = 'None'
121
- message = HumanMessage(content=[
122
- {"type": "text", "text": "Please, Describe this image in detail"},
123
- {"type": "image_url", "image_url": url}
124
- ])
125
  try:
126
- model = random.choice([vision,vision1,vision2,vision3])
127
- text = model.invoke([message])
 
128
  except:
129
- return text
130
- return text.content
131
 
132
  def detailed_feature_extraction(find, context):
133
 
@@ -375,4 +366,5 @@ text_splitter_small = RecursiveCharacterTextSplitter(
375
  )
376
 
377
  if __name__ == '__main__':
378
- pass
 
 
78
  Please rewrite the following text to make it short, concise, and of high quality.
79
  Ensure that all essential information and key points are retained.
80
  Focus on improving clarity, coherence, and word choice without altering the original meaning.
 
81
 
82
  text = {text}
83
  '''
 
110
  return result.content
111
 
112
  def feature_extraction_image(url):
113
+ text = ' '
114
+ model = genai.GenerativeModel('gemini-1.5-flash-001')
 
 
 
 
 
 
 
 
 
115
  try:
116
+ res = model.generate_content(['Describe this image to me',url])
117
+ text = res.text
118
+
119
  except:
120
+ pass
121
+ return text
122
 
123
  def detailed_feature_extraction(find, context):
124
 
 
366
  )
367
 
368
  if __name__ == '__main__':
369
+ print(get_embed_chroma('https://www.galaxys24manual.com/wp-content/uploads/pdf/galaxy-s24-manual-SAM-S921-S926-S928-OS14-011824-FINAL-US-English.pdf'))
370
+ # print(get_image_embeddings(Product='Samsung Galaxy S24'))