Spaces:
Sleeping
Sleeping
Commit
Β·
5ccbefb
1
Parent(s):
61d1ad7
Update main.py
Browse files
main.py
CHANGED
|
@@ -27,6 +27,7 @@ from offres_emploi import Api
|
|
| 27 |
from offres_emploi.utils import dt_to_str_iso
|
| 28 |
import datetime
|
| 29 |
|
|
|
|
| 30 |
os.environ['ANTHROPIC_API_KEY'] = os.environ['ANTHROPIC_API_KEY']
|
| 31 |
index_name = os.environ['PINECONE_INDEX_NAME']
|
| 32 |
embeddings = HuggingFaceEmbeddings()
|
|
@@ -34,6 +35,10 @@ pinecone.init(
|
|
| 34 |
api_key=os.environ['PINECONE_API_KEY'],
|
| 35 |
environment=os.environ['PINECONE_ENVIRONMENT']
|
| 36 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
@cl.author_rename
|
| 39 |
def rename(orig_author: str):
|
|
@@ -101,7 +106,6 @@ async def chat_profile():
|
|
| 101 |
]
|
| 102 |
@cl.on_chat_start
|
| 103 |
async def start():
|
| 104 |
-
os.environ["TOKENIZERS_PARALLELISM"] = os.environ["TOKENIZERS_PARALLELISM"]
|
| 105 |
chat_profile = cl.user_session.get("chat_profile")
|
| 106 |
chatProfile = chat_profile.split(' - ')
|
| 107 |
|
|
@@ -136,10 +140,6 @@ async def start():
|
|
| 136 |
if value:
|
| 137 |
await cl.Message(author="πππ",content=settings["AgentName"]).send()
|
| 138 |
|
| 139 |
-
vectorstore = Pinecone.from_existing_index(
|
| 140 |
-
index_name=index_name, embedding=embeddings
|
| 141 |
-
)
|
| 142 |
-
|
| 143 |
from langchain_core.prompts.prompt import PromptTemplate
|
| 144 |
|
| 145 |
_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.
|
|
@@ -149,7 +149,7 @@ async def start():
|
|
| 149 |
Follow Up Input: {question}
|
| 150 |
Standalone question:"""
|
| 151 |
CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)
|
| 152 |
-
|
| 153 |
########## Chain with streaming ##########
|
| 154 |
message_history = ChatMessageHistory()
|
| 155 |
memory = ConversationBufferMemory(
|
|
|
|
| 27 |
from offres_emploi.utils import dt_to_str_iso
|
| 28 |
import datetime
|
| 29 |
|
| 30 |
+
os.environ["TOKENIZERS_PARALLELISM"] = os.environ["TOKENIZERS_PARALLELISM"]
|
| 31 |
os.environ['ANTHROPIC_API_KEY'] = os.environ['ANTHROPIC_API_KEY']
|
| 32 |
index_name = os.environ['PINECONE_INDEX_NAME']
|
| 33 |
embeddings = HuggingFaceEmbeddings()
|
|
|
|
| 35 |
api_key=os.environ['PINECONE_API_KEY'],
|
| 36 |
environment=os.environ['PINECONE_ENVIRONMENT']
|
| 37 |
)
|
| 38 |
+
vectorstore = Pinecone.from_existing_index(
|
| 39 |
+
index_name=index_name, embedding=embeddings
|
| 40 |
+
)
|
| 41 |
+
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 60,"filter": {'categorie': {'$eq': 'OF'}}})
|
| 42 |
|
| 43 |
@cl.author_rename
|
| 44 |
def rename(orig_author: str):
|
|
|
|
| 106 |
]
|
| 107 |
@cl.on_chat_start
|
| 108 |
async def start():
|
|
|
|
| 109 |
chat_profile = cl.user_session.get("chat_profile")
|
| 110 |
chatProfile = chat_profile.split(' - ')
|
| 111 |
|
|
|
|
| 140 |
if value:
|
| 141 |
await cl.Message(author="πππ",content=settings["AgentName"]).send()
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
from langchain_core.prompts.prompt import PromptTemplate
|
| 144 |
|
| 145 |
_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.
|
|
|
|
| 149 |
Follow Up Input: {question}
|
| 150 |
Standalone question:"""
|
| 151 |
CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)
|
| 152 |
+
|
| 153 |
########## Chain with streaming ##########
|
| 154 |
message_history = ChatMessageHistory()
|
| 155 |
memory = ConversationBufferMemory(
|