From 0b19227b6c43b5f19e95d80e398a122d574deff1 Mon Sep 17 00:00:00 2001
From: "abir.chebbi" <abir.chebbi@hes-so.ch>
Date: Mon, 16 Sep 2024 18:24:25 +0200
Subject: [PATCH] update the script

---
 Part1/create-S3-and-put-docs.py |  4 +++
 Part1/create-vector-db.py       |  3 ++
 Part1/delete-s3.py              |  5 +++-
 Part1/test.py                   | 52 ---------------------------------
 Part1/vectorise-store.py        |  2 ++
 Part2/chatbot.py                |  3 ++
 Part2/config.ini                | 10 +++----
 Part2/create_instance.py        |  2 ++
 8 files changed, 23 insertions(+), 58 deletions(-)
 delete mode 100644 Part1/test.py

diff --git a/Part1/create-S3-and-put-docs.py b/Part1/create-S3-and-put-docs.py
index 2728452..240cb63 100644
--- a/Part1/create-S3-and-put-docs.py
+++ b/Part1/create-S3-and-put-docs.py
@@ -1,3 +1,7 @@
+# Creator: Abir Chebbi (abir.chebbi@hesge.ch)
+
+
+
 import boto3
 import os
 import argparse
diff --git a/Part1/create-vector-db.py b/Part1/create-vector-db.py
index ca98882..91a2c8b 100644
--- a/Part1/create-vector-db.py
+++ b/Part1/create-vector-db.py
@@ -1,4 +1,7 @@
+# Creator: Abir Chebbi (abir.chebbi@hesge.ch)
 ## Source: https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-sdk.html
+
+
 import boto3
 import botocore
 import time
diff --git a/Part1/delete-s3.py b/Part1/delete-s3.py
index 7d07f21..efe9c49 100644
--- a/Part1/delete-s3.py
+++ b/Part1/delete-s3.py
@@ -1,6 +1,9 @@
+# Creator: Abir Chebbi (abir.chebbi@hesge.ch)
+
+
 import boto3
 
-BUCKET_NAME = 'cloud-lecture-2023'
+BUCKET_NAME = ''
 
 S3_CLIENT = boto3.client('s3')
 S3_RESOURCE = boto3.resource('s3')
diff --git a/Part1/test.py b/Part1/test.py
deleted file mode 100644
index 2b25ba2..0000000
--- a/Part1/test.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import boto3
-from opensearchpy import OpenSearch, RequestsHttpConnection, AWSV4SignerAuth
-from langchain_community.embeddings import BedrockEmbeddings
-
-# AWS and OpenSearch Configuration
-host = 'd7gvxdj7jpz3h3bj0xq6.us-east-1.aoss.amazonaws.com'  
-index_name = 'cloud_lecture'
-awsauth = AWSV4SignerAuth(boto3.Session().get_credentials(), 'us-east-1', 'aoss')
-
-# OpenSearch Client
-opensearch_client = OpenSearch(
-    hosts=[{'host': host, 'port': 443}],
-    http_auth=awsauth,
-    use_ssl=True,
-    verify_certs=True,
-    connection_class=RequestsHttpConnection,
-)
-
-# Embeddings Client
-bedrock_client = boto3.client(service_name="bedrock-runtime")
-
-def get_embedding(question, bedrock_client):
-    embeddings_model = BedrockEmbeddings(model_id="amazon.titan-embed-text-v1", client=bedrock_client)
-    embedding = embeddings_model.embed_query(question)
-    return embedding
-
-def knn_query(vector, index_name):
-    query_body = {
-        "size": 10,
-        "query": {
-            "knn": {
-                "vector_field": {
-                    "vector": vector,
-                    "k": 10
-                }
-            }
-        }
-    }
-    response = opensearch_client.search(index=index_name, body=query_body)
-    return response['hits']['hits']
-
-def main():
-    question = "What is FAAS?" 
-    print("Generating embedding for the question...")
-    question_embedding = get_embedding(question, bedrock_client)
-    print("Querying the index for similar contents...")
-    search_results = knn_query(question_embedding, index_name)
-    print(search_results[0])
-   
-
-if __name__ == "__main__":
-    main()
diff --git a/Part1/vectorise-store.py b/Part1/vectorise-store.py
index 225ecf3..3e5eda4 100644
--- a/Part1/vectorise-store.py
+++ b/Part1/vectorise-store.py
@@ -1,3 +1,5 @@
+# Creator: Abir Chebbi (abir.chebbi@hesge.ch)
+
 import boto3
 import os
 from langchain_community.document_loaders import PyPDFDirectoryLoader
diff --git a/Part2/chatbot.py b/Part2/chatbot.py
index d6722ea..1fca90d 100644
--- a/Part2/chatbot.py
+++ b/Part2/chatbot.py
@@ -1,3 +1,6 @@
+# Creator: Abir Chebbi (abir.chebbi@hesge.ch)
+
+
 import boto3
 import streamlit as st
 
diff --git a/Part2/config.ini b/Part2/config.ini
index a7868b4..68d9b69 100644
--- a/Part2/config.ini
+++ b/Part2/config.ini
@@ -1,10 +1,10 @@
 [aws]
-aws_access_key_id = AKIAVEKYIBTQKSG2R342
-aws_secret_access_key = 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
-region = us-east-1
+aws_access_key_id = 
+aws_secret_access_key = 
+region = 
 
 [opensearch]
-endpoint = ku7nut9wcogpz1nw15j0.us-east-1.aoss.amazonaws.com
-index_name = cloud-lecture
+endpoint =
+index_name =
 
 
diff --git a/Part2/create_instance.py b/Part2/create_instance.py
index c4a6ec8..ac6221e 100644
--- a/Part2/create_instance.py
+++ b/Part2/create_instance.py
@@ -1,3 +1,5 @@
+# Creator: Abir Chebbi (abir.chebbi@hesge.ch)
+
 import boto3
 import base64
 
-- 
GitLab