jeroenherczeg
commited on
Commit
•
a1bd586
1
Parent(s):
1bf76d8
Search
Browse files
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Question-Answering System
|
3 |
-
emoji:
|
4 |
colorFrom: purple
|
5 |
colorTo: purple
|
6 |
sdk: streamlit
|
|
|
1 |
---
|
2 |
title: Question-Answering System
|
3 |
+
emoji: ❔
|
4 |
colorFrom: purple
|
5 |
colorTo: purple
|
6 |
sdk: streamlit
|
app.py
CHANGED
@@ -3,36 +3,20 @@ import streamlit as st
|
|
3 |
|
4 |
|
5 |
st.markdown('''
|
6 |
-
Hey there, I wrote a book titled "**:
|
7 |
-
|
8 |
-
[Go to start](https://huggingface.co/spaces/jeroenherczeg/HORAG-LLM) - [Previous](#) - [Next](#) - [Read the book](https://herczeg.be)
|
9 |
''')
|
10 |
|
11 |
-
st.header('
|
12 |
|
13 |
client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"])
|
14 |
|
15 |
-
|
16 |
-
st.session_state["openai_model"] = "gpt-3.5-turbo"
|
17 |
-
|
18 |
-
if "messages" not in st.session_state:
|
19 |
-
st.session_state.messages = []
|
20 |
-
|
21 |
-
for message in st.session_state.messages:
|
22 |
-
with st.chat_message(message["role"]):
|
23 |
-
st.markdown(message["content"])
|
24 |
-
|
25 |
-
if prompt := st.chat_input("What is up?"):
|
26 |
-
st.session_state.messages = []
|
27 |
-
st.session_state.messages.append({"role": "user", "content": prompt})
|
28 |
-
with st.chat_message("user"):
|
29 |
-
st.markdown(prompt)
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
36 |
)
|
37 |
-
|
38 |
-
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
|
3 |
|
4 |
|
5 |
st.markdown('''
|
6 |
+
Hey there, I wrote a book titled "**:purple[Hands-On Retrieval-Augmented Generation]**," which includes this interactive example. If you\'re interested in exploring more practical applications of Retrieval-Augmented Generation, be sure to [check it out](https://retrieval-augmented-generation.com)!
|
|
|
|
|
7 |
''')
|
8 |
|
9 |
+
st.header('Question-Answering System', divider='rainbow')
|
10 |
|
11 |
client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"])
|
12 |
|
13 |
+
text_search = st.text_input("Ask a question", value="")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
if st.button("Ask"):
|
16 |
+
with st.spinner("Searching for an answer..."):
|
17 |
+
response = client.chat.completions.create(
|
18 |
+
model="gpt-3.5-turbo",
|
19 |
+
messages=[{"role": "user", "content": text_search}],
|
20 |
+
stream=False,
|
21 |
)
|
22 |
+
st.write(response)
|
|