Spaces:
Sleeping
Sleeping
Update retriver.py
Browse files- retriver.py +19 -1
retriver.py
CHANGED
|
@@ -8,9 +8,27 @@ import streamlit as st
|
|
| 8 |
import os
|
| 9 |
# Initialize Pinecone client
|
| 10 |
pc = Pinecone(api_key=st.secrets["retrival_key"])
|
| 11 |
-
|
| 12 |
index = pc.Index("openai-serverless")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Azure OpenAI configuration
|
| 15 |
os.environ["AZURE_OPENAI_API_KEY"] = st.secrets["azure_api_key"]
|
| 16 |
os.environ["AZURE_OPENAI_ENDPOINT"] = "https://davidfearn-gpt4.openai.azure.com/"
|
|
|
|
| 8 |
import os
|
| 9 |
# Initialize Pinecone client
|
| 10 |
pc = Pinecone(api_key=st.secrets["retrival_key"])
|
|
|
|
| 11 |
index = pc.Index("openai-serverless")
|
| 12 |
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def read_file(file):
|
| 16 |
+
"""
|
| 17 |
+
Reads the content of a text file and returns it as a string.
|
| 18 |
+
|
| 19 |
+
:param approver: The type of approver.
|
| 20 |
+
:return: The content of the file as a string.
|
| 21 |
+
"""
|
| 22 |
+
fp = f"assets/{file}.md"
|
| 23 |
+
try:
|
| 24 |
+
with open(fp, 'r', encoding='utf-8') as file:
|
| 25 |
+
content = file.read()
|
| 26 |
+
return content
|
| 27 |
+
except FileNotFoundError:
|
| 28 |
+
print(f"The file at {fp} was not found.")
|
| 29 |
+
except IOError:
|
| 30 |
+
print(f"An error occurred while reading the file at {fp}.")
|
| 31 |
+
|
| 32 |
# Azure OpenAI configuration
|
| 33 |
os.environ["AZURE_OPENAI_API_KEY"] = st.secrets["azure_api_key"]
|
| 34 |
os.environ["AZURE_OPENAI_ENDPOINT"] = "https://davidfearn-gpt4.openai.azure.com/"
|