File size: 1,627 Bytes
a576a00
 
 
 
 
e283888
a576a00
 
 
56d29f4
e283888
a576a00
 
 
e283888
 
e3bfd01
e283888
c721b0c
6fc7c84
0373920
 
 
6fc7c84
 
 
 
 
e283888
25af997
e283888
25af997
e283888
1bb8b5f
25af997
 
e283888
 
12c393f
e283888
 
1bb8b5f
e283888
 
 
 
 
 
002a4bb
e128883
e283888
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

from annotated_text import annotation
from json import JSONDecodeError
import logging
from markdown import markdown
import requests

import streamlit as st

from utils.haystack import query, start_haystack
from utils.ui import reset_results, set_initial_state, sidebar

set_initial_state()

sidebar()

st.write("# ๐Ÿ”Ž Ask Me Anything")

st.session_state["api_key_configured"] = True

st.caption("Example 1 - I see negative comments for my number! they're lies, how do I remove them?")
st.caption("Example 2 - I'm free user and i see there is a Mr. Number Premium thing. What do I get?")
st.caption("Example 3 - It doesn't work on Android. The app is not blocking calls!!!")
prompt = st.text_input("Your question", on_change=reset_results)

st.write("")
st.write("")
run_pressed = st.button("Ask")
    
if st.session_state.get("api_key_configured"):
    # Get results for query
    if run_pressed and prompt:
        reset_results()
        st.session_state.prompt = prompt
        print(prompt)
        
        with st.spinner("๐Ÿ”Ž"):
            try:
                st.session_state.result = query(prompt, start_haystack(st.session_state.get("COHERE_API_KEY")))
            except JSONDecodeError as je:
                st.error(
                    "๐Ÿ›‘    Something went wrong! Database failure."
                )    
            except Exception as e:
                logging.exception(e)
                st.error("๐Ÿž    An error occurred during the request.")            
                
    if st.session_state.result:
        llm = st.session_state.result
        st.write(llm)