Upload embedding.py
Browse files- 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 |
-
|
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 |
-
|
127 |
-
text =
|
|
|
128 |
except:
|
129 |
-
|
130 |
-
return text
|
131 |
|
132 |
def detailed_feature_extraction(find, context):
|
133 |
|
@@ -375,4 +366,5 @@ text_splitter_small = RecursiveCharacterTextSplitter(
|
|
375 |
)
|
376 |
|
377 |
if __name__ == '__main__':
|
378 |
-
|
|
|
|
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'))
|