Spaces:
Sleeping
Sleeping
jjovalle99
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -50,14 +50,14 @@ try:
|
|
50 |
)
|
51 |
|
52 |
system_message = SystemMessage(content="You are a helpful assistant.")
|
53 |
-
human_template = """Based on the following context generate an
|
54 |
Context: {context}
|
55 |
|
56 |
-
|
57 |
|
58 |
Answer:"""
|
59 |
human_message = HumanMessagePromptTemplate.from_template(template=human_template)
|
60 |
-
llm = ChatOpenAI(model="gpt-
|
61 |
prompt = ChatPromptTemplate.from_messages(messages=[system_message, human_message])
|
62 |
parser = StrOutputParser()
|
63 |
prompt_chain = prompt | llm | parser
|
@@ -110,7 +110,7 @@ async def start_chat():
|
|
110 |
async def main(message: cl.Message):
|
111 |
retriever = cl.user_session.get("retriever")
|
112 |
retriever_chain = RunnableParallel(
|
113 |
-
{"context": retriever, "
|
114 |
)
|
115 |
|
116 |
out = cl.Message(content="")
|
|
|
50 |
)
|
51 |
|
52 |
system_message = SystemMessage(content="You are a helpful assistant.")
|
53 |
+
human_template = """Based on the following context generate an response for the user query. If the response is not available say I dont know.
|
54 |
Context: {context}
|
55 |
|
56 |
+
Query: {query}
|
57 |
|
58 |
Answer:"""
|
59 |
human_message = HumanMessagePromptTemplate.from_template(template=human_template)
|
60 |
+
llm = ChatOpenAI(model="gpt-4-0125-preview", streaming=True)
|
61 |
prompt = ChatPromptTemplate.from_messages(messages=[system_message, human_message])
|
62 |
parser = StrOutputParser()
|
63 |
prompt_chain = prompt | llm | parser
|
|
|
110 |
async def main(message: cl.Message):
|
111 |
retriever = cl.user_session.get("retriever")
|
112 |
retriever_chain = RunnableParallel(
|
113 |
+
{"context": retriever, "query": RunnablePassthrough()}
|
114 |
)
|
115 |
|
116 |
out = cl.Message(content="")
|